• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker When Player doesn't go to death room

S

Sroft

Guest
I have my player when their hp reaches 0 they should be transported to a room, I'm sure it's an easy fix, I'm just lost at the moment. Every time PlayerHp <= 0 the game just freezes, please help.
Player create-
//move vari
hsp = 0;
vsp = 0;
grv = 0.3;
walksp = 4;
hascontrol = true;
PlayerHP = 100;
//weapons
enum WEAPONS_MODE
{
HANDS,
PLASMA
}
weapons = WEAPONS_MODE.HANDS
//Guns
firing = 0;
ShootCont = true

Player step
if ( PlayerHP <= 0)
{
room_goto(DeadRoom)
}

also if there is a way to do hp better than what I am doing currently, I would appreciate advice on how to make it better (right now they player takes damage when the player collides with an enemy)

Enemy collision event with Player
with (other)
{
PlayerHP -= 1;
}
thank you
 

samspade

Member
Probably you need to check this in the debugger as there's nothing here that would prevent your code from working. So my guess is that it does work and the problem lies in something in DeadRoom.

As to the collisions, that code will also work, but it will work every step and with every enemy. Probably not what you're looking for. You need to create either some type of i_frames for the player so that can't take damage faster than you want or some type of hit list for the enemy so that they can't re-damage the same object next step.
 
Top