I have a controller object that spawns enemies and puts them in an array, enemy[<number made here, starting at 0>].
I'm trying to figure out how to get a list of them in order by distance to the player (enemy[#].x,enemy[#].y,obj_player.x,obj_player.y) with the least distant first in the list.
I think this requires the use of lists or maps, but I don't entirely understand how to use them.
What would be the best way of going about doing this?
- Game Maker Community
- → Viewing Profile: Topics: name
name
Member Since 02 Feb 2007Offline Last Active May 13 2013 08:06 PM
Community Stats
- Group GMC Member
- Active Posts 1427
- Profile Views 3210
- Member Title GMC Member
- Age 18 years old
- Birthday June 6, 1994
-
Gender
Male
-
Location
Im right here...
-
Interests
Game Maker?
4
none
Latest Visitors
Topics I've Started
ordering a list of objects by distance to a pont?
21 November 2011 - 12:19 AM
Hampocalypse
14 November 2011 - 01:08 AM

----------
The unthinkable has happened. Pigs have learned to fly, and they're using this new-found power to wreck havoc on the unsuspecting world.
Well, kind of. They aren't smart enough to cause any real harm. ...but they are falling in your general direction.
Use your giant slingshot to turn them into bacon before they do the same to you!
----------
This game was coded in about 47 hours for bacongamejam's BaconGameJam 01 competition
My entry is here.
All of the graphics were made by myself, and all of the sounds were free-use.
Made in
----------
Use the mouse to control the slingshot, and shoot the pigs before they get to far.
There are buttons in the top-right to control sound and the aim-assist feature.
----------

----------
http://sandbox.yoyogames.com/games/189211-hampocalypse
Let me know what you think.
drawing electricity
01 September 2011 - 10:48 PM
What I'm trying to do is draw a line of electricity at y=75, across the width of the room.
How I think the best way to do this would be:
For every pixel of the room width (going from left to right), take a random number and proceed with around 1/20 chance
Make a point and set its x to the value of the room width pixel
Set a var to round(random(5)))
random but 1/2 chance of case 1
If case one make the var negative
(Otherwise it will stay positive)
Put the vars in a 2d array
Then draw a line between all of the consecutuve points (x value left to right) in the array.
Is there a better way to do this, and will my way even work?
Also sorry for the weird formatting, I'm on my phone.
How I think the best way to do this would be:
For every pixel of the room width (going from left to right), take a random number and proceed with around 1/20 chance
Make a point and set its x to the value of the room width pixel
Set a var to round(random(5)))
random but 1/2 chance of case 1
If case one make the var negative
(Otherwise it will stay positive)
Put the vars in a 2d array
Then draw a line between all of the consecutuve points (x value left to right) in the array.
Is there a better way to do this, and will my way even work?
Also sorry for the weird formatting, I'm on my phone.
line collision checking
31 May 2011 - 04:52 AM
Lets say that I have two points. Point A and point B.
There is line going between point A and point B.
There is a another line, going from point C to point D to infinity after point D.
How would I find the point where line segment AB and ray CD intersect?
I would think something like:
Is there anything wrong that I would need to fix before I try to start coding?
If you care, I'm making a game with a laser and reflecting mirrors.
AB is the surface of the mirror, and CD is the laser with C being the player.
There is line going between point A and point B.
There is a another line, going from point C to point D to infinity after point D.
How would I find the point where line segment AB and ray CD intersect?
I would think something like:
find slope of AB and CD
find length of AB
use slope of AB and length of AB to put all points on AB in an array
use slope of CD, starting at C to calculate first pixel location(point) on CD
check point against array of points on AB
if a match, return the point as the intersection point and exit
if not, go to next point on CD and recheck(and stop and exit at ~2000 or something like that.)
Is there anything wrong that I would need to fix before I try to start coding?
If you care, I'm making a game with a laser and reflecting mirrors.
AB is the surface of the mirror, and CD is the laser with C being the player.
getting data from a midi file
28 May 2011 - 02:35 AM
Is there any way to extract the note data from a midi file?
As in, import the midi and get out the pitch value and location of the notes in a track.
I doubt there's a way just with gm, but are there any .dll's that could help me with this?
If not, how would I go about making one?
As in, import the midi and get out the pitch value and location of the notes in a track.
I doubt there's a way just with gm, but are there any .dll's that could help me with this?
If not, how would I go about making one?
- Game Maker Community
- → Viewing Profile: Topics: name
- Privacy Policy
- GMC Rules and Forum Rules ·



Find content
