Skip to content
This repository was archived by the owner on Sep 7, 2024. It is now read-only.

Refactor scores#23

Open
Cthulhu2 wants to merge 2 commits intoleerob:masterfrom
Cthulhu2:refactor_scores
Open

Refactor scores#23
Cthulhu2 wants to merge 2 commits intoleerob:masterfrom
Cthulhu2:refactor_scores

Conversation

@Cthulhu2
Copy link
Copy Markdown

@Cthulhu2 Cthulhu2 commented Jan 23, 2019

  • Define scores on create Enemy, Mystery
  • Enemy, Mystery w super(groups)
  • Render scores once on changing, not every frame

* Define scores on create Enemy, Mystery
* Enemy, Mystery w super(groups)
* Render scores once on changing, not every frame
Comment thread spaceinvaders.py Outdated
def __init__(self, row, column, *groups):
self.row = row
self.column = column
super(Enemy, self).__init__(*groups)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be first?

Copy link
Copy Markdown
Author

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?

Copy link
Copy Markdown
Author

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).

Comment thread spaceinvaders.py Outdated
sprite.Sprite.__init__(self)
self.image = IMAGES['mystery']
self.image = transform.scale(self.image, (75, 35))
def __init__(self, *groups):
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is *groups?

Copy link
Copy Markdown
Author

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)
...

Copy link
Copy Markdown
Author

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).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants