Skip to content

Commit

Permalink
See recent changes README.
Browse files Browse the repository at this point in the history
  • Loading branch information
Art9681 committed Dec 30, 2012
1 parent 9a966d8 commit f3e633e
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 55 deletions.
112 changes: 59 additions & 53 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Left Mouse Click: Attack.
Right mouse click: Spawn item. (Select item from menu)

Recent changes:
-Added very basic enemy pathfinding.
-Added colliding map boundaries on left and right edges.
-The menu does not register events when it is not visible.
-Fixed player jumping multiple times in the air. Only jumps once now.
Expand Down
2 changes: 1 addition & 1 deletion levels.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def update(self, dt):
self.space.step(dt)
self.player.update()
self.block.update()
self.zombie.update()
self.zombie.update(self.player.body.position)

for sword in self.sword_group:
sword.update(self.player.body.position)
Expand Down
11 changes: 10 additions & 1 deletion npc.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,21 @@ def __init__(self):
def walk_right(self):
if self.enemy_img.image != self.enemy_anim_right:
self.enemy_img.image = self.enemy_anim_right
self.body.velocity.x = 100

def walk_left(self):
if self.enemy_img.image != self.enemy_anim_left:
self.enemy_img.image = self.enemy_anim_left
self.body.velocity.x = -100

def update(self):
def pathfind(self, player):
if player.x < self.body.position.x:
self.walk_left()
else:
self.walk_right()

def update(self, player):
#Bind the sprite's position to the pymunk object.
self.enemy_img.position = self.body.position
self.pathfind(player)

0 comments on commit f3e633e

Please sign in to comment.