Skip to content

Commit

Permalink
Merge pull request #48 from zacker150/master
Browse files Browse the repository at this point in the history
Changed FlappyBird.getGameState to match collision detection algorithm
  • Loading branch information
ntasfi authored May 11, 2018
2 parents 50aa299 + 11c01d1 commit cbdc536
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ple/games/flappybird/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,8 @@ def getGameState(self):
"""
pipes = []
for p in self.pipe_group:
if p.x > self.player.pos_x:
pipes.append((p, p.x - self.player.pos_x))
if p.x + p.width/2 > self.player.pos_x :
pipes.append((p, p.x + p.width/2 - self.player.pos_x ))

pipes.sort(key=lambda p: p[1])

Expand All @@ -334,11 +334,11 @@ def getGameState(self):
"player_y": self.player.pos_y,
"player_vel": self.player.vel,

"next_pipe_dist_to_player": next_pipe.x - self.player.pos_x,
"next_pipe_dist_to_player": next_pipe.x + next_pipe.width/2 - self.player.pos_x ,
"next_pipe_top_y": next_pipe.gap_start,
"next_pipe_bottom_y": next_pipe.gap_start + self.pipe_gap,

"next_next_pipe_dist_to_player": next_next_pipe.x - self.player.pos_x,
"next_next_pipe_dist_to_player": next_next_pipe.x + next_next_pipe.width/2 - self.player.pos_x ,
"next_next_pipe_top_y": next_next_pipe.gap_start,
"next_next_pipe_bottom_y": next_next_pipe.gap_start + self.pipe_gap
}
Expand Down

0 comments on commit cbdc536

Please sign in to comment.