This repository was archived by the owner on Sep 7, 2024. It is now read-only.
Open
Conversation
* Define scores on create Enemy, Mystery * Enemy, Mystery w super(groups) * Render scores once on changing, not every frame
leerob
reviewed
Jan 23, 2019
| def __init__(self, row, column, *groups): | ||
| self.row = row | ||
| self.column = column | ||
| super(Enemy, self).__init__(*groups) |
Author
There was a problem hiding this comment.
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?
Author
There was a problem hiding this comment.
A little bit of a feng shui in the 1e87cac Replace unobvious Sprite(*groups) w Sprite.add(*groups).
| sprite.Sprite.__init__(self) | ||
| self.image = IMAGES['mystery'] | ||
| self.image = transform.scale(self.image, (75, 35)) | ||
| def __init__(self, *groups): |
Author
There was a problem hiding this comment.
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)
...
Author
There was a problem hiding this comment.
A little bit of a feng shui in the 1e87cac Replace unobvious Sprite(*groups) w Sprite.add(*groups).
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Enemy, Mystery w super(groups)