-
Notifications
You must be signed in to change notification settings - Fork 224
Refactor scores #23
base: master
Are you sure you want to change the base?
Refactor scores #23
Conversation
* Define scores on create Enemy, Mystery * Enemy, Mystery w super(groups) * Render scores once on changing, not every frame
spaceinvaders.py
Outdated
self.row = row | ||
self.column = column | ||
super(Enemy, self).__init__(*groups) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are params in super-constructor of Sprite
class. I thought, it's ok to use it.
sprite.py
:
class Sprite(object):
...
def __init__(self, *groups):
self.__g = {} # The groups the sprite is in
if groups:
self.add(*groups)
...
def add(self, *groups):
...
for group in groups:
...
group.add_internal(self)
...
The Enemy.row
and Enemy.column
are used in Sprite.__init__
and needs to go first.
EnemyGroup.add_internal(...):
def add_internal(self, *sprites):
...
for s in sprites:
self.enemies[s.row][s.column] = s
Yes, not clear enough. May be, add some comment or ever eliminate (*groups)
usage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little bit of a feng shui in the 1e87cac Replace unobvious Sprite(*groups) w Sprite.add(*groups)
.
spaceinvaders.py
Outdated
sprite.Sprite.__init__(self) | ||
self.image = IMAGES['mystery'] | ||
self.image = transform.scale(self.image, (75, 35)) | ||
def __init__(self, *groups): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is *groups
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See prev comment. Also, an adding to groups in init
is little bit shortie:
Mystery(self.allSprites, self.mysteryGroup)
# Instead of
newShip = Mystery()
self.allSprites.add(newShip)
self.mysteryGroup.add(newShip)
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little bit of a feng shui in the 1e87cac Replace unobvious Sprite(*groups) w Sprite.add(*groups)
.
Enemy, Mystery w super(groups)