add beta sprite rotation

This commit is contained in:
Marcin Kostrzewski 2019-01-21 20:08:18 +01:00
parent 5d08b887f3
commit c2778d8b6d
6 changed files with 10 additions and 2 deletions

Binary file not shown.

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 761 B

After

Width:  |  Height:  |  Size: 556 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 580 B

View File

@ -20,8 +20,8 @@ clock=pygame.time.Clock()
# initialize two players
events.players.append(Player('asd', 50, 50, 5))
events.players.append(Player('qwe', 100, 100, 5))
events.players.append(Player('asd', 400, 100, 5))
events.players.append(Player('qwe', 400, 500, 5))
all_sprites.add(events.players)
events.running=True

View File

@ -41,21 +41,29 @@ class Player(pygame.sprite.Sprite):
self.colliding=False
def moveup(self):
if self.facing!=0:
self.image=pygame.transform.rotate(self.image, (self.facing*90))
self.facing=0
self.acc.y=-1.5
self.acc.x=0
def movedown(self):
if self.facing!=2:
self.image=pygame.transform.rotate(self.image, (self.facing*90))
self.facing=2
self.acc.y=1.5
self.acc.x=0
def moveright(self):
if self.facing!=1:
self.image=pygame.transform.rotate(self.image, (self.facing*90))
self.facing=1
self.acc.x=1.5
self.acc.y=0
def moveleft(self):
if self.facing!=3:
self.image=pygame.transform.rotate(self.image, (self.facing*90))
self.facing=3
self.acc.x=-1.5
self.acc.y=0