GameMaker The problem now has been solved entirely

E

EvilShuckle

Guest
Hey guys, im having... a think a tricky problem. The floor the player can stand on is made up by several invisible squares. Each of these square pieces checks whether the player is within range (and some other criteria) and if all criteria are met, it will spawn a tomb on top of the square which the player has to destroy quickly.
The idea itself works. If the player is within range, there is no other tomb being spawned that very moment and there are no more than 4 tombs, then a tomb is spawned. Problem is: at the very beginning of the game, only one of the squares checks it. On a square in range, a tomb is spawned. Which then stops spawning tombs because there already is one on top of it. But if the player walks out of its range, then no tombs are spawned anywhere.

What I want is: Each ground piece checks seperately and constantly whether the player is in range and if so, and the other criteria are met, it spawns a tomb
this is the code (a create event that sets an alarm, and underneath is the alarm)
Code:
if point_in_circle(player.x, player.y, x, y, 200) && instance_number(Tombspawn) < 5 && 
!instance_exists(tombcheck) && (myTomb == noone || !instance_exists(myTomb)) { 
instance_create_layer(x, y, "spawners", tombcheck); myTomb = instance_create_layer(x, y, 
"spawners", Tombspawn); alarm[0] = 3*room_speed; }
It is a messy way of programming, I know. I am new and I sort of solved it through creativity, not so much skilled programming

tl/dr: During the entire game currently only one tomb spawns. It should be spawning constantly everywhere
 

CloseRange

Member
Not a bad way to program.
Try changing
alarm[0] = 3*room_speed;
to this
Code:
with(obj_wall) alarm[0] = 3*room_speed;
where obj_wall is just the name of the object that has this code.
You reset the alarm for the wall that created the tomb but didn't reset it for all the rest.
 
E

EvilShuckle

Guest
Not a bad way to program.
Try changing
alarm[0] = 3*room_speed;
to this
Code:
with(obj_wall) alarm[0] = 3*room_speed;
where obj_wall is just the name of the object that has this code.
You reset the alarm for the wall that created the tomb but didn't reset it for all the rest.
Ill be damned... it works :eek: It actually works! Ive been breaking my head over this for days. Man I love you xD Thank you so much.
 

TsukaYuriko

☄️
Forum Staff
Moderator
Glad you found your solution (and apparently your significant other), but this thread's title is now obsolete. ;P

I changed it to avoid confusion - it might be a good idea not to name topics like this in the future. :)
 
Top