1. Check out our companion app, Forums for Android! Download from Google Play

Creating tower defense

Discussion in 'Application Development' started by swarmski, Jul 25, 2010.

  1. swarmski

    swarmski New Member
    Thread Starter
    5

    Jul 25, 2010
    2
    0
    5
    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
    Thread Starter
    5

    Jul 25, 2010
    2
    0
    5
    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
    5

    Aug 5, 2010
    2
    0
    5
    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
    53

    Apr 30, 2010
    375
    35
    53
    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...