rex_noctis
Jul 22, 2018 - 12:17
I am making a game. In the def update(self): bit I have the code
player_hitbox = Rect(self.player.position-12, self.player.position-12, 24, 24)
if self.enemy1.frame.intersects(player_hitbox):
self.gameOver()
However, when I run the game, there is this error:
Traceback (most recent call last):
File "/var/containers/Bundle/Application/D2B5AEDE-2A6F-4263-8217-08037B4C2570/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/scene.py", line 199, in _draw
self.update()
File "/private/var/mobile/Containers/Shared/AppGroup/6311A336-2012-414A-9433-E66D7EBF131D/Pythonista3/Documents/impossibleGame.py", line 147, in update
player_hitbox = Rect(self.player.position-12, self.player.position-12, 24, 24)
TypeError: Unsupported operand type(s)
How can I get it so when the player’s hit box intersects enemy1’s frame, it runs self.gameOver()?