R
RCarnival
Guest
Hello, I've very new to GMS, I'm currently working on learning the different coding and used the same code I used from a tutorial learning how to make the character's sprite speed look good but when I used it in a new game with little to know differences the sprite speed is going way too fast... I made sure the sprite speeds were all the same 15 frames per second and have image speed set to 1... not sure what I'm messing up..
Obj_Hero
Create:
Obj_Hero
Create:
hsp = 0;
vsp = 0;
grv = 0.5;
walksp = 6;
Step:vsp = 0;
grv = 0.5;
walksp = 6;
//Movement
key_left = keyboard_check(vk_left) || keyboard_check(ord("A"));
key_right = keyboard_check(vk_right) || keyboard_check(ord("D"));
key_jump = keyboard_check_pressed(vk_space);
//Calculate Movement
var move = key_right - key_left;
hsp = move * walksp;
vsp = vsp +grv;
if (place_meeting(x,y+1,Obj_Ground)) && (key_jump){
vsp = -10
}
//Horizontal Collision
if (place_meeting(x+hsp,y,Obj_Ground)) {
while (!place_meeting (x+sign(hsp),y,Obj_Ground)) {
x = x + sign(hsp);
}
hsp = 0;
}
x = x + hsp;
//Vertical Collision
if (place_meeting(x,y+vsp,Obj_Ground)) {
while (!place_meeting(x,y+sign(vsp),Obj_Ground)) {
y=y+sign(vsp);
}
vsp = 0;
}
y = y+vsp;
//Animation
if (!place_meeting(x,y+1,Obj_Ground)) {
sprite_index = Spr_HeroAir;
if (sign(vsp) > 0) image_index = 1; else image_index = 0;
}
else
{
image_speed = 1;
if (hsp == 0) {
sprite_index = Spr_Hero;
}
else {
sprite_index = Spr_HeroWalk
}
}
if (hsp!=0) image_xscale = sign(hsp);
If you can see what I'm doing wrong it would be greatly appreciated!!key_left = keyboard_check(vk_left) || keyboard_check(ord("A"));
key_right = keyboard_check(vk_right) || keyboard_check(ord("D"));
key_jump = keyboard_check_pressed(vk_space);
//Calculate Movement
var move = key_right - key_left;
hsp = move * walksp;
vsp = vsp +grv;
if (place_meeting(x,y+1,Obj_Ground)) && (key_jump){
vsp = -10
}
//Horizontal Collision
if (place_meeting(x+hsp,y,Obj_Ground)) {
while (!place_meeting (x+sign(hsp),y,Obj_Ground)) {
x = x + sign(hsp);
}
hsp = 0;
}
x = x + hsp;
//Vertical Collision
if (place_meeting(x,y+vsp,Obj_Ground)) {
while (!place_meeting(x,y+sign(vsp),Obj_Ground)) {
y=y+sign(vsp);
}
vsp = 0;
}
y = y+vsp;
//Animation
if (!place_meeting(x,y+1,Obj_Ground)) {
sprite_index = Spr_HeroAir;
if (sign(vsp) > 0) image_index = 1; else image_index = 0;
}
else
{
image_speed = 1;
if (hsp == 0) {
sprite_index = Spr_Hero;
}
else {
sprite_index = Spr_HeroWalk
}
}
if (hsp!=0) image_xscale = sign(hsp);