Game freezes when main character dies.
#21
Posted 28 March 2012 - 07:31 PM
#22
Posted 28 March 2012 - 07:39 PM
if global.ammo > 100
{
global.ammo = 100;
}
if global.hp > 200
{
global.hp = 200;
}
if global.hp <= 0
{
sound_play(uhoh);
global.hp = 100;
Obj_player.x = Obj_player.xstart;
Obj_player.y = Obj_player.ystart;
if room = yourroom
{
instance_create(200,300,obj_enemy);
//..create more enemies here at their spawn locations in the first room.
}
room_restart();
}And how many rooms do you have?
Edited by fluidic ice, 28 March 2012 - 07:40 PM.
#23
Posted 28 March 2012 - 07:45 PM
I up to 2 rooms right now but there are a LOT more coming.
And sorry if im being stupid or something, i just started using GM
#24
Posted 28 March 2012 - 07:55 PM
if room = room1
{
instance_create(200,300,obj_enemy);
//..create more enemies here at their spawn locations in the first room.
}
if room = room2
{
instance_create(200,300,obj_enemy);
//..create more enemies here at their spawn locations in the first room.
}
...This way is fairly un-optimized and some coding genius might be able to find a different way to achieve the same effect.
#25
Posted 28 March 2012 - 08:23 PM
#26
Posted 28 March 2012 - 08:42 PM
#27
Posted 29 March 2012 - 03:28 PM
#28
Posted 29 March 2012 - 03:47 PM
#29
Posted 30 March 2012 - 11:21 AM
#30
Posted 31 March 2012 - 09:35 PM
#31
Posted 31 March 2012 - 09:41 PM
What are you bumping for? What do you want to happen when you die in room2? What's wrong with room_restart();?
#32
Posted 31 March 2012 - 10:06 PM
When i die in room2 i want to start at the beginning of room2, with the code i have now i respawn at the end of a cleared room1.
#33
Posted 31 March 2012 - 11:01 PM
#34
Posted 01 April 2012 - 12:31 PM
if global.hp<1 room_restart()but that caused the game to freeze and play the deathsound over and over when the character died.
#35
Posted 01 April 2012 - 06:51 PM
Like it says in the thread (i assume you read the thread because thats what you generally do before posting) i used the code:
if global.hp<1 room_restart()but that caused the game to freeze and play the deathsound over and over when the character died.
I flicked through it. Frankly, I don't want to continue where the others left off, you sounded like you were getting a little confused.(and people were talking about ds_lists, of all things)
The reason the game freezes, and plays deathsound over&over is because global.hp is.. a global variable.
You restart the room.. but global.hp is still <1. So your code restarts it again. And again. And again..
So just set
global.hp=100 (or whatever your 'top health' is)
first, then room_restart()
if global.hp<1
{
global.hp=100
room_restart();
}And for what it's worth, you're meant to have solved this problem already. Fluidic Ice gave you the answer..
Edited by Desert Dog, 01 April 2012 - 06:55 PM.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











