Arlan64
Member
Hello world!
I've a problem with my player when he plunges in the water...
I want to make the player slow down when he dives into the water, while keeping jumping into the water.
The problem is this: when I set the vertical speed lower in the water than on the surface, the player gets stuck in that speed and even if I try to jump into the water, the player does not allow it.
That's why I appeal to you! The best help will be welcome
I will give you the codes, so you can find your way around (check in Step Event the long line "---", this is the place of the problem (I think...?)):
Blooby >> Create:
Blooby >> Step:
I've a problem with my player when he plunges in the water...
I want to make the player slow down when he dives into the water, while keeping jumping into the water.
The problem is this: when I set the vertical speed lower in the water than on the surface, the player gets stuck in that speed and even if I try to jump into the water, the player does not allow it.
That's why I appeal to you! The best help will be welcome
I will give you the codes, so you can find your way around (check in Step Event the long line "---", this is the place of the problem (I think...?)):
Blooby >> Create:
Code:
///Initialisation des variables
//Saisir la gravité initiale
grav_normal = 0.50;
grav_water = 0.45;
grav = grav_normal;
//Saisir la vitesse horizontale initiale
hsp = 0;
//Saisir la vitesse verticale initiale
vsp = 0;
//Saisir le nombre de sauts initial au sol
jumps = 0;
//Saisir le nombre de sauts maximum initiaux
jumpsmax = 1;
jumpsmax_water = 999999;
//Saisir le nombre de sauts dans les airs
jumps_outside = 0;
//Saisir la vitesse du saut initial (la hauteur plutôt)
jumpspeed_normal = 10;
//Saisir la vitesse du saut avec le HighJump PowerUp (la hauteur plutôt)
jumpspeed_powerup = 13.8;
//Saisir la vitesse de nage verticale initiale
jumpspeed_water = 7.2;
//Saisir la vitesse de saut qui est égale à la vitesse de saut normale
jumpspeed = jumpspeed_normal
//Saisir la vitesse de déplacement initiale
movespeed_normal = 6;
//Saisir la vitesse de déplacement avec le HighSpeed PowerUp
movespeed_powerup = 10;
//Saisir la vitesse de nage horizontale initiale
movespeed_water = 4
//Saisir la vitesse de déplacement qui est égale à la vitesse de déplacement normale
movespeed = movespeed_normal
//Saisir la dose de ralentissement/freinage quand le joueur plonge
stop_water = 0;
//Saisir la collision initiale avec les ennemis
touch_ennemies = 0;
Code:
///Les déplacements de Blooby
//Les commandes
key_right = keyboard_check(vk_right);
key_left = -keyboard_check(vk_left);
key_jump = keyboard_check(vk_up);
key_jump_held = keyboard_check(vk_up);
key_jump_pressed = keyboard_check_pressed(vk_up);
key_down = -keyboard_check_pressed(vk_down);
key_down_held = -keyboard_check(vk_down);
//Réactions aux déplacements basiques
move = key_left + key_right;
hsp = move * movespeed;
{if (vsp < 10)
{
vsp += grav;
}
}
//Pentes
{if (key_right)
{if place_meeting(x + 6,y,obj_slope_UpRight)
y = y - 6
}
}
{with (key_left)
{if place_meeting(x - 6,y,obj_slope_UpLeft)
y = y - 6
}
}
//Prise d'appui au sol pour sauter
{if place_meeting(x,y+1,obj_floor)
{
vsp = key_jump * -jumpspeed;
}
}
//Dash en l'air
{if place_empty(x,y+1)
{
vsp += key_down * -jumpspeed;
}
}
//Sauts dans l'eau
{if (place_meeting(x,y,obj_water) && key_jump_pressed) || (place_meeting(x,y+1,obj_floor) && place_meeting(x,y,obj_water) && (key_jump || key_jump_held || key_jump_pressed))
{
vsp = key_jump_pressed * -jumpspeed_water;
}
}
//Pas de sauts en dehors de l'eau
{if place_empty(x,y)
{
jumps = jumps_outside;
grav_water = grav_normal;
stop_water = 0;
}
}
//Hauteurs de sauts à chaque 4 pixels
{if (vsp < 0) && (!key_jump_held)
{
vsp = max(vsp,-jumpspeed/4)
}
}
//Ralentissements dans l'eau --------------------------------------------------------------------------------
{if place_meeting(x,y,obj_water)
{
hsp = move * movespeed_water
//vsp = grav_water * jumpspeed_water
}
}
/*{if vsp = grav_water * jumpspeed_water
{
vsp = key_jump_pressed * -jumpspeed_water;
}
}
{if stop_water = 1
{
//vsp = grav_normal * grav_water
}
}*/
///Collisions avec le sol/mur
//Collision horizontale
{if place_meeting(x+hsp,y,obj_floor)
{
while !place_meeting(x+sign(hsp),y,obj_floor)
{
x += sign(hsp);
}
hsp = 0;
}
}
x += hsp;
//Collision verticale
{if place_meeting(x,y+vsp,obj_floor)
{
while(!place_meeting(x,y+sign(vsp),obj_floor))
{
y += sign(vsp);
}
vsp = 0;
}
}
y += vsp;