Powered by Invision Power Board

 
    Reply to this topicStart new topicStart Poll

> [Solved]Measuring distance in Game Maker?
United States
Tek
Posted: Apr 20 2007, 01:08 AM
Quote Post


no
[*]

Group Icon
Group: Members
Posts: 4393
Member No.: 1734
Joined: 17-December 05

Status: (0d) [--]


Okay, here's the deal:
dradstr is the player character
lobulletright and lobulletleft are the projectiles
The code is:
CODE
{
if dradstr.y > self.y - 5 and dradstr.y < self.y + 5
   {
   if dradstr.x > self.x
   instance_create(self.x,self.y,lobulletright)
   if dradstr.x < self.x
   instance_create(self.x,self.y,lobulletleft)
   }
}

Now this is fine, but it would be nicer if the enemy only fired when you were at most 150 pixels away. Is there a way I can make the game find the distance between these two objects?

This post has been edited by Tek-Tek on Apr 20 2007, 01:08 PM


--------------------
PMEmail PosterUsers Website
Top
Finland
Hohoo
  Posted: Apr 20 2007, 07:59 AM
Quote Post


BAN AUTOTUNE
[*][*][*]

Group Icon
Group: Members
Posts: 1562
Member No.: 3062
Joined: 14-December 06

Status: (0d) [--]


Place this first:

If distance_to_object(dradstr) is smaller than 150

...but only if you have a turret object.


--------------------

user posted image

Reference

Mickeysoft Internet Explorer

MKE


cat /usr/share/icons/*/* > /dev/dsp
user posted image
NOW IS EXCITING COMING
Johto > Hoenn > Sevii > Sinnoh > Kanto
PMUsers Website
Top
United States
Grant
Posted: Apr 20 2007, 09:50 AM
Quote Post


John Freeman said
[*][*][*][*][*]
[*][*][*]

Group Icon
Group: Members
Posts: 8260
Member No.: 2900
Joined: 31-October 06

Status: (0d) [--]


QUOTE (hohoo @ Apr 20 2007, 08:59 AM)
Place this first:

If distance_to_object(dradstr) is smaller than 150

...but only if you have a turret object.

Are you talking about an older version of GM?

The function is point_distance(x1,y1,x2,y2) in GM6.


--------------------
user posted image

QUOTE (oh youtube trolls)
u guys r retarded hippocrates

QUOTE (Piemanthe3rd)
Pie is not random. I wish people would realize this.
PMEmail PosterUsers WebsiteAOLMSN
Top
United States
Tek
Posted: Apr 20 2007, 01:07 PM
Quote Post


no
[*]

Group Icon
Group: Members
Posts: 4393
Member No.: 1734
Joined: 17-December 05

Status: (0d) [--]


Yes, that worked. Thank you nod.gif


--------------------
PMEmail PosterUsers Website
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

  Topic Options Topic Options Reply to this topicStart new topicStart Poll

 




[ Script Execution time: 0.1159 ]   [ 14 queries used ]   [ GZIP Enabled ]   [ Server Load: 12.88 ]