• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Creating tower defense

swarmski

Lurker
Jul 25, 2010
2
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!
 
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?
 
Upvote 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.
 
Upvote 0
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.
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones