Issues with Tower Defence Game

joecrozierjoecrozier Member Posts: 6
edited February 2012 in Working with GS (Mac)
For the last few days I've been working on a simple tower defense style game for the iPhone in GameSalad.
So far things have been going quite well, however earlier today I ran into a speed bump. While programming the method in which the towers would shoot the creeps, I found myself unable to think of a way to specify which creeps the towers should be shooting.

Let me explain. Currently, I have the game set up with a creep actor, a creep-spawning actor, a tower actor, and a tower "aura" actor. The tower aura actor is effectively just a large circle which is programmed to be spawned when the tower is placed. I have it set up so that when the creep enters the aura, it's X and Y coords are constrained to global variables and in turn, the tower spawns a bullet object which accelerates towards the aforementioned coordinates. This works well and fine when using one tower, it only targets enemies inside its aura, and it targets the enemy which was last to enter its aura. Unfortunately though, when I add in a second tower, I find that the *first* tower will begin to target the creeps inside the second towers aura, rather than the first aura.

Does anyone have any better ideas on how I should approach this? Perhaps I'm going at it the complete wrong way, and I'm open to redesigning the way the game tracks and targets creeps.

Thanks in advance.

Comments

  • joecrozierjoecrozier Member Posts: 6
    Anyone?
  • MotherHooseMotherHoose Member Posts: 2,456
    IMO the aura actor is not really needed … just have the tower image on a transparent background that is the size of the aura
    use: > Physics > Collision Shape > Circle

    then a simple collide on a creep can initiate the correct range and the firing
    and not affect creeps in other towers' aura/range

    don't know how many towers Player can have on scene at one time … but:

    gameAttributes tower1RangeX and tower1RangeY … tower2RangeX and tower2RangeY … etc. would work to store the creeps' X,Y
    and of course after firing and a successful hit (before the destroy) change them to 0
    while the towers respond to appropriate Rule: when (All) tower1RangeX > 0; tower1RangeY > 0 … -fire behavior

    @};- MH
  • joecrozierjoecrozier Member Posts: 6
    Thanks!
    I followed your advice and the game is working great.

    I have it set up so there are 5 different "towerRangeX" and "towerRangeY" values, one for each tower. This of course means that currently, a max of 5 towers can be placed on the gameboard at once.

    It's obviously very easy to increase this number - I just add more tower actors and more attributes. However, I've read on the forums that increasing the amount of actors and active restrains can reduce FPS.

    Is this true? Realistically, how many towers would you estimate would be safe and would not damage FPS?
  • MotherHooseMotherHoose Member Posts: 2,456
    if you have the behaviors as in the last 2 lines of my previous post,
    the constrains you use are only active when a creep is in the range
    that should not be to demanding on FPS

    @};- MH
Sign In or Register to comment.