Skip to content

Instantly share code, notes, and snippets.

@ZachMassia
Last active January 3, 2016 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZachMassia/8499592 to your computer and use it in GitHub Desktop.
Save ZachMassia/8499592 to your computer and use it in GitHub Desktop.
Traceback (most recent call last):
File "/home/zach/dev/python/scripting/lab2/part1.py", line 161, in <module>
app.run()
File "/home/zach/dev/python/scripting/lab2/basic_game/app.py", line 41, in run
self.game.update(self.clock.get_time())
File "/home/zach/dev/python/scripting/lab2/part1.py", line 36, in update
[m.update(dt) for m in self.marios.values()]
File "/home/zach/dev/python/scripting/lab2/part1.py", line 36, in <listcomp>
[m.update(dt) for m in self.marios.values()]
TypeError: Argument must be a dict with rectstyle keys.
import pygame
class Mario(object):
def __init__(self):
self.on_collision = lambda x: None
self.rect = pygame.Rect
self.enemies = dict() # format: { string: pygame.Rect }
def check_collisions(self):
cs = self.rect.collidedict(self.enemies)
if cs:
{self.on_collision(c) for c in cs}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment