Creating tower defense


Last Updated:

  1. swarmski

    swarmski New Member This Topic's Starter

    Joined:
    Jul 25, 2010
    Messages:
    2
    Likes Received:
    0
    Hi Guys,

    I have just started learning to code for Android and im loving (and hating) it so far.

    I have run through a few tutorials and basically im up to the game section (all menus etc done)

    Now the game i want to create is a tower defence style but im having a little difficulty knowing where to start. I have programmed in java a few times before, but would not really rate myself higher then beginner.

    I have a boolean array which is my path and an object, but i want to know how to move this object automatically (waves of enemies).

    I have tried to search for some examples but cannot seem to find any that help.

    I also noticed packages such as cocos2d (again no tuts available) and i have had a quick look at Rokon. With Rokon, im not sure how to provide move then one movement point (ie move sprite here, then there, then there - pathing)

    Is there any tips or tutorials you guys can recommend.

    Thanks heaps!
     

    Advertisement
  2. swarmski

    swarmski New Member This Topic's Starter

    Joined:
    Jul 25, 2010
    Messages:
    2
    Likes Received:
    0
    One idea i was thinking is to use the snake example on the Hello, World site
    Snake - Snake | Android Developers

    Id have the walls set in a path shape and instead of losing the game when detecting a collision on the wall, i would get it to pick a random way that isnt backwards and isnt the way its going, eg

    (rough idea)

    If collision = detected then
    go left
    If collision = Detected then
    go right
    if collision = detected then
    go down
    end if
    end if
    end if


    thoughts?
     
  3. Gamesterdude

    Gamesterdude New Member

    Joined:
    Aug 5, 2010
    Messages:
    2
    Likes Received:
    0
    Hey, was thinking about starting on tower defenses myself. Maybe we could bounce emails back and forth to help each other out. Most of my actual coding experience is in c++ so im still adapting to java and android. As for ur problem here that would work as a basic fix but could be manipulated by a player. I would suggest setting up the map as a grid or an array and when they build a new tower have it check to make sure there is an open path to the exit. then u could pass this path to your mobs.
     
  4. cp1

    cp1 Well-Known Member

    Joined:
    Apr 30, 2010
    Messages:
    375
    Likes Received:
    35
    I'm not sure if I understand the question -- is it about the actual drawing, or the algorithm to handle it?

    Basically you want to setup a movement event that happens every tick (every second, or whatever you decide). In that event you want:

    Iterate through every grid that has a mob in it and decide the best way to exit the board

    Iterate through all your mobs and have them move 1 step

    Then you'll need a firing event that probably happens more often? And has your towers find the closest enemy and shoot at it, subtracting from its HP.
     

Share This Page

Loading...