Tower defence, shooting the right enemy. iPhone

So I want to make a tower defence where the turret shoots at the enemy that is closest to the exit. This tower defence is multiple levels and may follow a winding path which means I can't do a simple "target enemy closest to exit". What is the best way to do this?
Also, I want to make a snap-to-grid so the turret are only created in select square areas. Thanks

Comments

  • asdfGamesasdfGames Member Posts: 15
    Well, a simple but not as intelligent solution I would do.I would make invisible "zones" underneath the path. Have 10 invisible squares or something, and as each enemy rests on top of it, a variable increases. The turret then automatically targets the enemy with the highest rating, meaning the enemy thats in the zone closet to the exit. Once again, not the most elegant solution, but it's how i would do it as a beginner.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    If you have a winding path, then the enemy that has been on the screen the longest is closest to the exit. Figure out how long it takes for an enemy to complete the path and then set each enemy's completion percentage to self.Time/self.TimeToComplete [where self.TimeToComplete is a number that you enter]. You could then have a rule that says When self.completionPercentage>game.highestPercentage --> Change Attribute game.EnemyX (and Y) to self.position.X (and Y). Have the tower fire at game.EnemyX, game.EnemyY.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • zfreedszfreeds Member Posts: 9
    edited March 2013
    Thanks tatiang. That might work. The only thing is that takes out any speed altering effects like a turret that slows enemies.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    That's true. So you might have to actually measure the distance traveled, though that seems very performance heavy (with a timer to constantly check the difference between the last position and the current position).

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • zfreedszfreeds Member Posts: 9
    Thanks
  • I know deepblueapps.com has a good tower defence template.

    http://www.deepblueapps.com/tower-defence-template/

    I think it costs some money, but it looks like what you may want.

    Cheers
Sign In or Register to comment.