thanks for this simple but great tutorial...
- Game Maker Community
- → Viewing Profile: Posts: stevanooz
stevanooz
Member Since 12 Jun 2011Offline Last Active Feb 08 2012 04:48 AM
About Me
Community Stats
- Group New Member
- Active Posts 10
- Profile Views 1489
- Member Title GMC Member
- Age 38 years old
- Birthday August 12, 1974
-
Gender
Male
-
Location
Indonesian-EastJava-Surabaya
-
Interests
Game, Gadget, Lego
Contact Information
-
MSN
stevanooz
-
Website URL
http://www.jualpremium.com
-
Yahoo
jualpremium@yahoo.com
Latest Visitors
Posts I've Made
In Topic: PacMan Tutorial -GML Through Implementation-
02 July 2011 - 03:22 PM
thanks for this simple but great tutorial...
In Topic: multiple rooms and character question
21 June 2011 - 04:48 PM
hemm.. I hope someone answer this....
In Topic: instance count and teleporting
21 June 2011 - 04:47 PM
The example code already does it (as mentioned at the 14th line.) Each of 'lower' teleporters (I suppose it means that the y coordinates is smaller than the current one) is assigned 'dist' according to the distance. On the other hand, 'higher' ones get the value of distance + 10000. As the result, every 'lower' instance has smaller value of dist than 'higher' ones. We choose the one who has the smallest dist among all of them.
If there is any 'lower' instance that matches criteria, the closest one among them is picked up. When there is no 'lower' one, the closest one is found from 'higher' ones.
ouhh.. i c....
well.. i guess, I must try any of the suggestion here to more understand.
thank you all...
In Topic: instance count and teleporting
20 June 2011 - 08:02 AM
Instead of checking every places, you can loop through instances of the object. Supposing that it is in the collision event with a teleporter:
var current, found, dist, min_dist; // Declare variables so that we can access them within the with-loop. current = other.id; // Save the id of the teleporter we hit so that we can refer it inside the loop. found = noone; min_dist = 99999; // Give it large enough initial value. with (obj_teleporter) { // Loop through all instances of the teleporter object. // Skip instances those don't match our criteria if (id == current) continue; // It is the same teleporter we hit. if (collision_line(x, y, current.x, current.y, obj_block, false, true)) continue; // It is blocked // Now check if it is the closest one dist = distance_to_object(current); if (y >= current.y) { dist += 10000; // Make that 'higher' instances are found after lower ones. } if (dist < min_dist) { dist = min_dist; found = id; } } // Now 'found' contains the id of the closest instance, or noone if all instances are blocked.
hemm.. it's a good one...
but... how can it chek the lower first and then the highest... as I said before... it will search the lower teleport first, if can't find one... then it will start search from the highest one. assume my room is 1024x1024... so it will first search teleport lower from the current teleport, until it find one. if not and reach (0,0).. then it will start search again from 1024x1024 until it find one. It must be find it somehow, because my game is not create the teleport without any destination. at least 2 teleports in one room.
In Topic: instance count and teleporting
20 June 2011 - 03:42 AM
i guess there is no short way to find it... haha... I mean maybe there is a function to use that can check and pick one out....
but your program is simple... and I wasn't thinking that... I mean, I never thought to use another pixel to check every position...
thanks a lot man... I will try it out... i believe it will work. I hope the checking won't take too long, so it can freeze the program...
- Game Maker Community
- → Viewing Profile: Posts: stevanooz
- Privacy Policy
- GMC Rules and Forum Rules ·



Find content
