Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: GM6 Help Shock Defence like shooting  (Read 983 times)

0 Members and 1 Guest are viewing this topic.
GM6 Help Shock Defence like shooting
« on: November 19, 2007, 12:29:33 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 61
Hi all! OK  i have a game(it's just like shock defence, if you've played it you'll know what i mean if not, google search it.) you have a arrow tower and it has a radius of 50 pixels lets say you have a path like this

                          END
|                    •     |
|   arrow tower here |
|         ___________|
|        |
|_____|

Now I want the arow tower to automatically shoot at the object tht's closest to the end in its 50 pixel radius, see what I mean? can Goodnight or some other smarty teach me?
« Last Edit: December 25, 2007, 03:37:58 am by 4Sword »
Logged
Re: GM6 Help Shock Defence like shooting
« Reply #1 on: November 19, 2007, 03:18:09 am »
  • :D
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 151
Umm, I guess something like:

Code: [Select]
var near, arrow;
near = instance_nearest(x, y, object); //object you want to shoot at

if(distance_to_object(near) <= 50){
  direction = point_direction(x, y, near.x, near.y);
  //shoot arrow
  arrow = instance_create(x,y,objArrow);//change objArrow to the name of your arrow object
  arrow.direction = self.direction;
  arrow.speed = 1; //speed of arrow
}
« Last Edit: November 20, 2007, 03:52:23 am by Knightmare »
Logged
  • Knighty Games
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.382 seconds with 41 queries.