Page 1 of 1

TowerDefense

Posted: Thu Mar 26, 2015 2:33 pm
by erbj
This project has been created before I started.

I worked with 2 other people at the project last semster (Fall Semester 2014).

So now Spring Semester 2015 I work on my own, refining it, fixing bugs and adding new features.

Upgrades until now:

- Towers inherit from turrets now.

- I set the model for the tower ad a cretain position and then place the turret (actual shooting thing) on the same place without a mesh (so it can move without the tower moving in all the directions)

Re: TowerDefense

Posted: Sat Mar 28, 2015 12:19 pm
by x3n
I like it that you use the turrets. Re-using existing code is always a good idea ;)

I don't know the code, but when I think about a tower, I think that it is responsible for two things:
  1. being placed somewhere, maybe being moved, having a cost, a level, etc
  2. shooting at enemies
These are two completely different concerns and often it makes sense to separate them in code. See http://en.wikipedia.org/wiki/Separation_of_concerns. This could mean that you use the existing turret for (b), but maybe you still need your own class to implement (a).

I think that this could also help to adress the issue with the tower's movement. You have a static tower (a) with a movable turret (b) mounted on top of it.

Of course you could implement both concerns in one class, but the design principle of 'separation of concerns' implies that it's often better if you use more than one class. This way it's easier to understand and modify the code. And maybe sometimes you want a tower which has a completely different implementation of (b), e.g. a land mine which explodes if an enemy steps on it, while the implementation of (a) is still the same. It you use SoC it's easier to do that because you only need to re-implement (b).