zonama-sekot/zonama-fighter — pull request #9 by hkdobrev (2014-05-15 03:09:33+00:00)
Title: Invader

Hey, guys!

I've started working on #3 and I've created a `Space` class and an `Invader` class.

---

:construction_worker: :construction: **Construction zone ahead** :construction: :construction_worker:

---

#### Work in progress

This is still work in progress, but I've decided to submit it here to discuss it. I've tried to make the code very readable and I'll comments as well.

##### `Invader`

So I've started with the `Invader` class. I quickly realized it should not know about the time and its speed (relative to the time). If every invader had its own timer the game would have a ton of them.

I think the whole game should have a single timer which would be controlling both the invaders, the fighter and the bullets. This way everything will be synchronized (and I hope fast).

I was thinking about different objects moving at different speed. This could now be implemented using the `step` property in the `Invader` class. It would move the object more pixels for the same amount of time in which the other items would move less.

##### `Space`

The `Space` class is currently managing the invaders. It moves them down every time the `Timer` fires (we should come up with a name for that - e.g. moments?) It also creates a new `Invader` instance on a random column every moment as well.

Currently the newly added invaders (after the first one) are not always visible. So this is not ready to be merged right now.

---

#### Code style

What do you think of the code style? Readability, approaches with the static/non-static methods, the getters/setters? Do you like it, do you hate it?

IMHO it is more clear and it would be really easy to plug in the `Fighter` class in this infrastructure and later the bullets.

---

What do you think?