Skip to content

Commit

Permalink
add player moving
Browse files Browse the repository at this point in the history
  • Loading branch information
firemark committed May 3, 2023
1 parent 61ec52f commit 13118e9
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/game/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ def draw(self):
x, y = self.cords
pyxel.blt(x, y, 0, 0, 0, self.WIDTH_SPRITE, self.HEIGHT_SPRITE)

def move_up(self):
self.cords[1] -= 10

def move_down(self):
self.cords[1] += 10

def move_left(self):
self.cords[0] -= 10

def move_right(self):
self.cords[0] += 10


class App:

Expand All @@ -27,8 +39,19 @@ def setup(self):
self.player = Player([128, 128])

def update(self):
self.keyboard()

def keyboard(self):
if pyxel.btnp(pyxel.KEY_Q):
pyxel.quit()
elif pyxel.btn(pyxel.KEY_UP):
self.player.move_up()
elif pyxel.btn(pyxel.KEY_DOWN):
self.player.move_down()
elif pyxel.btn(pyxel.KEY_LEFT):
self.player.move_left()
elif pyxel.btn(pyxel.KEY_RIGHT):
self.player.move_right()

def draw(self):
pyxel.cls(0)
Expand Down

0 comments on commit 13118e9

Please sign in to comment.