V
Vincent
Guest
So my game is a platformer, and I'm a noob in coding. My idea was to create a collision that made you jump instantly and lose a bit of health. I've made the code myself and it works more or less, but each time i jump (it worke before the new code) i get launched to the sky and lose health constantly, and I don't know why. I'm looking for a code that works and doesn't affect the rest of the actions
Player's Create event:
Player's Step event 1
Player's Step event 2
Thanks!!
Player's Create event:
Code:
gravedad = 1
vel_horizontal = 0
vel_vertical = 0
vel_salto = 16
vel_movimiento = 6
global.hp = 12
global.dano = true
Code:
///Movimiento y gravedad
//Variables
derecha = keyboard_check (ord("D"))
izquierda = -keyboard_check (ord("A"))
salto = keyboard_check_pressed (ord("W"))
//Movimiento
movimiento = derecha + izquierda
vel_horizontal = movimiento * vel_movimiento
//Gravedad
if (vel_vertical < 10)
{
vel_vertical += gravedad
}
Code:
if (global.dano = true)
and (place_meeting (x+1, y, obj_arana))
and (sprite_index = spr_fred_caminar_der) or (sprite_index = spr_fred_saltar_der)
{
alarm[0] = room_speed
{
global.dano = false
global.hp -= 1
y -= 128
sprite_index = spr_fred_dano_der
image_speed = 0.2
}
global.dano = true
}
if (global.dano = true)
and (place_meeting (x+1, y, obj_arana))
and (sprite_index = spr_fred_caminar_izq) or (sprite_index = spr_fred_saltar_izq)
{
alarm[0] = room_speed
{
global.dano = false
global.hp -= 1
y -= 128
sprite_index = spr_fred_dano_izq
image_speed = 0.2
}
global.dano = true
}