S
SlashmasterUniv
Guest
Greetings. I have been working on a platformer in Gamemaker: Studio. It has controls a bit different from most platformers. being inspired by many games, platformers or not. These games' (Shovel Knight, Smash Bros., Bayonetta) mechanics being fit into one platformer may cause more problems in the future. For now, let's focus on the task at hand.
I am using a modified version of Shaun Spaulding's platformer tutorial code. I am using an animated 32 x 32 sprite. It's collision mask is Precise, 0 Alpha Tolerance, Left = 0, Top = 0, Right = 33, Bottom = 32 and has "Precise collision checking" and "Seperate Collision Masks" ticked. My wall and ground is a solid 32 x 32 block.
If I fall from too high, my character's feet may get stuck in the ground. This inevitably happens when the player is holding left or right when hitting the ground. The player can also only move while in the air, another problem. When the player encounters a wall, they may either get stuck inside or teleport to the ground. The former of which can be negated by jumping.
I have not created any enemies yet, as I am trying to go step by step. This is my priority problem at the moment.
Here is my script:
Create: Initialize Variables:
Step: Execute a piece of code:
Here is my sprite:
Picture -
In-game strip -
Enhanced strip -
I am giving as much information as I can as to get the best answer. To alleviate some confusion of the long strips, I am not sure if one can loop an idle animation for so many frames before adding a waiting animation.
Any help (or attempts) will be greatly appreciated. Thank you so much.
Warm regards, Slash.
I am using a modified version of Shaun Spaulding's platformer tutorial code. I am using an animated 32 x 32 sprite. It's collision mask is Precise, 0 Alpha Tolerance, Left = 0, Top = 0, Right = 33, Bottom = 32 and has "Precise collision checking" and "Seperate Collision Masks" ticked. My wall and ground is a solid 32 x 32 block.
If I fall from too high, my character's feet may get stuck in the ground. This inevitably happens when the player is holding left or right when hitting the ground. The player can also only move while in the air, another problem. When the player encounters a wall, they may either get stuck inside or teleport to the ground. The former of which can be negated by jumping.
I have not created any enemies yet, as I am trying to go step by step. This is my priority problem at the moment.
Here is my script:
Create: Initialize Variables:
Code:
///Initialize Variables
grav = 0.2;
hsp = 0;
vsp = 0;
jumpspeed = 7;
movespeed = 4;
atk = 1;
def = 1;
psy = 1;
Code:
//Get the player's input
key_right = keyboard_check(vk_right);
key_left = -keyboard_check(vk_left);
key_jump = keyboard_check_pressed(vk_up);
key_jump_held = keyboard_check(vk_up);
key_down = keyboard_check(vk_down);
//React to inputs
move = key_left + key_right;
hsp = move * movespeed;
if (vsp < 10) vsp += grav;
if (place_meeting(x,y+2,obj_wall))
{
vsp = key_jump * -jumpspeed
}
//Jumps
if (vsp < 0) && (!key_jump_held) vsp = max(vsp,0)
//Diagonal Collision
if(place_meeting(x+hsp, y+sign(vsp+1), obj_wall))
{
while(!place_meeting(x+sign(hsp+1), y + sign(vsp+1), obj_wall))
{
x+= sign(hsp+1);
y+= sign(vsp+1);
} hsp = 0;
}
//Horizontal Collision
if (place_meeting(x+hsp,y,obj_wall))
{
while(!place_meeting(x+sign(hsp+1),y,obj_wall))
{
x += sign(hsp+1);
}
hsp = 0;
}
x += hsp;
//Vertical Collision
if (place_meeting(x+vsp,y,obj_wall))
{
while(!place_meeting(x,y+sign(vsp+1),obj_wall))
{
y += sign(vsp);
} vsp = 0;
} y += vsp;
///There may be spaces when not wanted, due to the copy and paste from GM:S to Facebook to here.
Picture -
In-game strip -
Enhanced strip -
I am giving as much information as I can as to get the best answer. To alleviate some confusion of the long strips, I am not sure if one can loop an idle animation for so many frames before adding a waiting animation.
Any help (or attempts) will be greatly appreciated. Thank you so much.
Warm regards, Slash.