Skip to content

Instantly share code, notes, and snippets.

@bitcoin4cashqc
Last active February 20, 2019 01:03
Show Gist options
  • Select an option

  • Save bitcoin4cashqc/8f7e15d4ee70ab172b194306191920cc to your computer and use it in GitHub Desktop.

Select an option

Save bitcoin4cashqc/8f7e15d4ee70ab172b194306191920cc to your computer and use it in GitHub Desktop.
Help for collision check with Pyxel
collide = 4 # between [0 - Player_img_size]
def collideWithPlayer(Player,enemy):
"""return: (bool) collide with Player or not """
p_pos = Player.getPos() # where the position is x y
playr_x, playr_y = p_pos.x, p_pos.y
playr_w, playr_h = Player.getSize() #where the size is w h
for pos in self.pos:
enemy_x, enemy_y = pos.x, pos.y
if ( abs(enemy_x - playr_x) < playr_w - collide and abs(enemy_y - playr_y) < playr_h - collide ):
return True
else:
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment