Last active
February 20, 2019 01:03
-
-
Save bitcoin4cashqc/8f7e15d4ee70ab172b194306191920cc to your computer and use it in GitHub Desktop.
Help for collision check with Pyxel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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