Help needed on making a TD game!

Talk about making games.

Help needed on making a TD game!

Postby 98700 » Fri Jul 18, 2008 1:48 pm

I am in the process of making a tower defense game and is was wondering if anyone could help me on how to make my turrets shoot when the badguy is in range. Thanks in advance. :D
Forum Me and Game A Gogo are administrating:
http://jacobtzgamz.freeforums.org/
98700
 
Posts: 106
Joined: Fri Jun 08, 2007 3:46 pm
Location: in your closet
Score: 1 Give a positive score

Re: Help needed on making a TD game!

Postby feral » Fri Jul 18, 2008 11:26 pm

Your best bet is to use the distance function...


distance: Returns the distance between points (x1, y1) and (x2, y2).
example

Code: Select all
range=distance(turret.x, turret.y, badguy.x, badguy.y);



are your "badguys" cloned, or individuals ?
User avatar
feral
 
Posts: 308
Joined: Sun Mar 16, 2008 6:27 am
Score: 47 Give a positive score

Re: Help needed on making a TD game!

Postby 98700 » Sun Jul 20, 2008 9:51 pm

im sure im gonna make em clones
Forum Me and Game A Gogo are administrating:
http://jacobtzgamz.freeforums.org/
98700
 
Posts: 106
Joined: Fri Jun 08, 2007 3:46 pm
Location: in your closet
Score: 1 Give a positive score

Re: Help needed on making a TD game!

Postby 98700 » Tue Jul 29, 2008 2:24 am

Ok I used the code now how do i make the turrets turn and shoot the enemy when in range?
Forum Me and Game A Gogo are administrating:
http://jacobtzgamz.freeforums.org/
98700
 
Posts: 106
Joined: Fri Jun 08, 2007 3:46 pm
Location: in your closet
Score: 1 Give a positive score

Re: Help needed on making a TD game!

Postby feral » Tue Jul 29, 2008 3:51 am

to make the turrents turn towards the enemy you will need to use the direction() function which returns the angle between one point and another.

you will also need to match that up with the right animations

try looking in the moon defender tutorial
http://game-editor.com/tutorials/moonde ... l_eng.html

to shoot when in range it is simply a matter of working out what shooting range is and setting a vaiable like "inrange" and saying something like

if (inrange<range)
{
//do turning and shooting code
}
User avatar
feral
 
Posts: 308
Joined: Sun Mar 16, 2008 6:27 am
Score: 47 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron