A
AYoshiGuy
Guest
Hey, i am trying to make a RPG game and i can't make the main character's walking animation. I have tried tutorials, my coding skills and other stuff but i just can't do it. Just help me please.
var dx = keyboard_check(vk_right)-keyboard_check(vk_left);
var dy = keyboard_check(vk_down)-keyboard_check(vk_up);
/* Collision detection code here */
x += dx;
y += dy;
if (dx == 0 && dy == 0) {
image_index = 0;
image_speed = 0;
} else {
if (dx > 0) {
sprite_index = spr_right;
} else if (dx < 0) {
sprite_index = spr_left;
} else {
if (dy > 0) {
sprite_index = spr_down;
} else {
sprite_index = spr_up;
}
}
image_speed = 1;
}
One way is to just have a speed variable initialized in the Create Event of your player and then check if whatever button you want is being held and if so increase the movement speed. Something like this:This helped me a lot!
I have been working on my games for a couple of months and i couldn't do the animations. Most of the videos are for platformers. I fell like a person who begs because of 'just help me please'. I think i can do better in the future. I need to know everything about GameMaker. I still have a long journey to becoming a good developer. You have inspired me to study for my goal. I have a GML book and i will learn everything on it. Then for the stuff that isn't in it. Thank you.
And also, how can i make my character faster?
When walking and while holding a key?
//Create Event
movespeed = 3;
//Frostycat's example but with the movement variable added
var dx = keyboard_check(vk_right)-keyboard_check(vk_left);
var dy = keyboard_check(vk_down)-keyboard_check(vk_up);
if keyboard_check(vk_shift) movespeed = 6; else movespeed = 3;
/* Collision detection code here */
x += dx * movespeed;
y += dy * movespeed;
I totally understand. It's challenging, but if you make an attempt - someone is almost always willing to help. Stick with it, and may the force be with you.You guys helped me so much. I thought the GML (GameMaker Language) was easy but now that i see the code that you gave me, it is not as easy as i thought.
I'm gonna study and learn everything GameMaker Studio 2 has. Thanks!