seanmtracey / Games-with-Pygame

The code for my "Making games with PyGame" series for Raspberry Pi's The MagPi.
https://smt.codes/writings
85 stars 71 forks source link

TypeError Found #15

Closed ghost closed 5 years ago

ghost commented 5 years ago

In the drop game, this issue is occuring on my PC .

File "D:\Python\pygame\Games\Drop Box\dropSmash.py", line 52, in movePlayer if surface.get_at((player["x"], player["y"] + player["height"])) == (0,0,0,255): TypeError: integer argument expected, got float

seanmtracey commented 5 years ago

Hello! Which version of Python are you running the game with?

ghost commented 5 years ago

Sir it's python 3.7

On Fri 5 Apr, 2019, 1:07 PM Sean M. Tracey, notifications@github.com wrote:

Hello! Which version of Python are you running the game with?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/seanmtracey/Games-with-Pygame/issues/15#issuecomment-480178427, or mute the thread https://github.com/notifications/unsubscribe-auth/AsJbm8HPL60VChWi1vveZk_B5ZSGvWZxks5vdv0pgaJpZM4cbTep .

seanmtracey commented 5 years ago

Ooh, that is interesting. Do you know what values you're passing to surface.get_at when the error is thrown?

If not, no worries, you can cast the values being passed to integers with something like surface.get_at(( int(player["x"]), int(player["y"]) + int(player["height"]))) == (0,0,0,255) which should remedy the problem :)

ghost commented 5 years ago

Thank you very much sir, it worked

On Sun 7 Apr, 2019, 11:01 PM Sean M. Tracey, notifications@github.com wrote:

Ooh, that is interesting. Do you know what values you're passing to surface.get_at when the error is thrown?

If not, no worries, you can cast the values being passed to integers with something like surface.get_at(( int(player["x"]), int(player["y"]) + int(player["height"]))) == (0,0,0,255) which should remedy the problem :)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/seanmtracey/Games-with-Pygame/issues/15#issuecomment-480612541, or mute the thread https://github.com/notifications/unsubscribe-auth/AsJbm33IaKIcEswlnwskMPHP-5y8AewOks5veitogaJpZM4cbTep .

seanmtracey commented 5 years ago

Anytime! Happy coding :)