F
Felipe Paluco
Guest
Hello Guys, i'm actually trying to study GML/Programation Logic and in the same time developing a game. (On GMS 2)
I'm studying with videos on YouTube. On the past 2 weeks i'm developing and studying the method to create a game using the HeartBeast video's, to be more precise, the "Hack'n'Slash Course" of him.
I successfully create the horizontal colision, learned the sprite animation process using the method of state-machine. I expanded the functions that he presents on the video, creating a "crounch state" or a third attack on the combo mechanic that he apply on the course.
But i having issues to do a thing: A Jump Mechanic with vertical colision.
How i pretend to make this work:
But i tried on many forms using the way he make on the course, but i don't get success. (and putting some code of another guys of plataform to understand and adapt to my code)
If i make the player jump and collide, i can't make stop be possible to slide or attack on the air, or vice versa.
And i don't give any idea how to make that, or apply to the code and logic of HeartBeast.
move_and_collide script (the collision script)
I'm studying with videos on YouTube. On the past 2 weeks i'm developing and studying the method to create a game using the HeartBeast video's, to be more precise, the "Hack'n'Slash Course" of him.
I successfully create the horizontal colision, learned the sprite animation process using the method of state-machine. I expanded the functions that he presents on the video, creating a "crounch state" or a third attack on the combo mechanic that he apply on the course.
But i having issues to do a thing: A Jump Mechanic with vertical colision.
How i pretend to make this work:
- The player jumps, the sprite changes to the jumping sprite
- When the player reach the maximum determined altitude, the player start to fall and the sprite changes to the falling sprite (this sprite will be applied everytime the player fall's, independent of him jumping or not, e.g: falling in a hole.)
- The player cannot attack, slide (the same thing to the roll state created by HeartBeast on the course, i changed a little heh) and must importantly he cannot jump on the air. Just in contact with a solid surface.
But i tried on many forms using the way he make on the course, but i don't get success. (and putting some code of another guys of plataform to understand and adapt to my code)
If i make the player jump and collide, i can't make stop be possible to slide or attack on the air, or vice versa.
And i don't give any idea how to make that, or apply to the code and logic of HeartBeast.
move_and_collide script (the collision script)
Code:
///@arg Xspeed
///@arg Yspeed
if not place_meeting(x+argument0, y, obj_ground)
{
x += argument0;
}
if place_meeting(x, y+argument1, obj_ground)
{
y += argument1;
}
Code:
key_mapping()
switch (state) {
#region Move State
case "Move":
if right {
move_and_collide(run_speed, 0);
image_xscale = 2;
sprite_index = s_player_run;
image_speed = 0.8;
} if left {
move_and_collide(-run_speed, 0);
image_xscale = -2;
sprite_index = s_player_run;
image_speed = 0.8;
}
if not right and not left {
sprite_index = s_player_idle;
image_speed = 1.1;
}
if slide {
image_index = 0;
state = "Slide";
}
if attack {
image_index = 0;
state = "Attack_One";
}
if crounch {
sprite_index = s_player_crounch;
image_speed = 1.1;
state = "Crounching"
}
break;
#endregion
#region Slide State
case "Slide":
sprite_index = s_player_slide;
image_speed = 1.6;
if image_xscale == 2 {
move_and_collide(slide_speed, 0);
}
if image_xscale == -2 {
move_and_collide(-slide_speed, 0);
}
break;
#endregion
#region Crounching State
case "Crounching":
if crounch {
sprite_index = s_player_crounch;
image_speed = 1.1;
}
if keyboard_check_released(vk_down) {
state = "Move"
}
break;
#endregion
#region Attack One
case "Attack_One":
sprite_index = s_player_attack_one;
image_speed = 0.8;
if right then image_xscale = 2;
if left then image_xscale = -2;
if attack and animation_hit_frame_range(3.5, 5)
{
image_index = 0;
state = "Attack_Two"
}
break;
#endregion
#region Attack Two
case "Attack_Two":
sprite_index = s_player_attack_two;
image_speed = 0.8;
if right then image_xscale = 2;
if left then image_xscale = -2;
if attack and animation_hit_frame_range(2, 5)
{
image_index = 0;
state = "Attack_Three"
}
break;
#endregion
#region Attack Three
case "Attack_Three":
sprite_index = s_player_attack_three;
image_speed = 0.8;
if right then image_xscale = 2;
if left then image_xscale = -2;
break;
#endregion
}
Code:
image_speed = 0.6;
state = "Move";
run_speed = 3.5;
slide_speed = 8;
Code:
if state == "Attack_One" or state == "Attack_Two" or state == "Attack_Three" or state == "Slide" {
state = "Move";
image_index = 0;
}
Code:
///@description Verify the number of index sprite frame to a other higher than.
///@arg low
///@arg high
return image_index >= argument0 and image_index <= argument1;
Key_Mapping Script:
Code:
//Key Mapping
left = keyboard_check(vk_left)
right = keyboard_check(vk_right)
slide = keyboard_check_pressed(vk_shift)
attack = keyboard_check_pressed(ord("Z"))
crounch = keyboard_check_pressed(vk_down)
Thank's for the becoming support.
Last edited by a moderator: