diff --git a/__pycache__/events.cpython-37.pyc b/__pycache__/events.cpython-37.pyc index 2db02b3..8a7ba71 100644 Binary files a/__pycache__/events.cpython-37.pyc and b/__pycache__/events.cpython-37.pyc differ diff --git a/__pycache__/mygame.cpython-37.pyc b/__pycache__/mygame.cpython-37.pyc deleted file mode 100644 index 1e3c2e7..0000000 Binary files a/__pycache__/mygame.cpython-37.pyc and /dev/null differ diff --git a/__pycache__/sprites.cpython-37.pyc b/__pycache__/sprites.cpython-37.pyc index 26701dc..a55588e 100644 Binary files a/__pycache__/sprites.cpython-37.pyc and b/__pycache__/sprites.cpython-37.pyc differ diff --git a/data/graphics/bullet.png b/data/graphics/bullet.png new file mode 100644 index 0000000..6e6b50d Binary files /dev/null and b/data/graphics/bullet.png differ diff --git a/events.py b/events.py index c5bb83d..1056e14 100644 --- a/events.py +++ b/events.py @@ -19,11 +19,13 @@ def collision_check(p): if p==1: players[0].colliding=True direction=players[1].facing + players[0].image=pygame.transform.rotate(players[0].image, players[0].facing*90-((direction+2)%4)*90) players[0].facing=(direction+2)%4 return True elif p==0: players[1].colliding=True direction=players[0].facing + players[1].image=pygame.transform.rotate(players[1].image, players[1].facing*90-((direction+2)%4)*90) players[1].facing=(direction+2)%4 return True else: diff --git a/mygame.py b/mygame.py index 2f1635d..a35a8ff 100644 --- a/mygame.py +++ b/mygame.py @@ -26,6 +26,21 @@ all_sprites.add(events.players) events.running=True +# debug text + +font=pygame.font.SysFont("Arial", 12) + +def draw_debug_text(): + text_sprites=pygame.sprite.Group() + texts=[ + font.render("P1 facing: " + str(events.players[0].facing), True, (100,100,100)), + font.render("P2 facing: " + str(events.players[1].facing), True, (100,100,100)) + ] + count=0 + for text in texts: + screen.blit(text, (0,count*12)) + count+=1 + # game loop while events.running: @@ -37,6 +52,7 @@ while events.running: all_sprites.update() screen.fill(BLACK) # draw + draw_debug_text() all_sprites.draw(screen) pygame.display.flip() pygame.quit() diff --git a/sprites.py b/sprites.py index 317cc50..5d97af0 100644 --- a/sprites.py +++ b/sprites.py @@ -16,7 +16,7 @@ def load_img(name): return image, image.get_rect() def load_sound(name): - sound_path=os.path.join('data\\sounds') + sound_path=os.path.join('data/sounds') sound=pygame.mixer.Sound(sound_path) return sound @@ -39,7 +39,6 @@ class Player(pygame.sprite.Sprite): self.friction=-0.25 self.facing=0 # where the player is looking (0-north, 1-east, 2-south, 3-west) self.colliding=False - def moveup(self): if self.facing!=0: self.image=pygame.transform.rotate(self.image, (self.facing*90)) @@ -49,25 +48,28 @@ class Player(pygame.sprite.Sprite): def movedown(self): if self.facing!=2: - self.image=pygame.transform.rotate(self.image, (self.facing*90)) + self.image=pygame.transform.rotate(self.image, (self.facing*90)-180) 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.image=pygame.transform.rotate(self.image, (self.facing*90)-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.image=pygame.transform.rotate(self.image, (self.facing*90)-270) self.facing=3 self.acc.x=-1.5 self.acc.y=0 + def shoot(self): + nothing + def stopmoving(self): self.acc=vec(0, 0)