Make a Platformer in GameMaker! Part 5 (Sprite/Animation Control + Running/Sprinting)
HTML-код
- Опубликовано: 28 сен 2024
- Part 5 of 9! Download the sprites for this video at the link below!
Sprite Folder (Public Patreon Post) : www.patreon.co...
Wishlist Starcross Starcade Special! store.steampow...
Rose of Starcross Trailer: https: // • Rose of Starcross Kick...
Starcross Starcade Special Trailer: • Starcross Starcade Spe...
My tweets: / peydinburnham
Rose of Starcross Demo: peytonburnham....
Discord: / discord
My twitch: / peydinburnham
I just started using game maker with zero experience and it made me so happy to make a square move up and down then bump into a wall because of you so thank you so much. ALSO ur quality of life video is a hood classic.
LMAO thank you very much my man I appreciate it 😎
Just for fun, I edited the Maria jump sprite to be a sprPlayerFall and added
//Falling
if !onGround && ySpeed == termVelocity {sprite_index = fallSpr;};
Once the player reaches terminal velocity, the jump sprite changes to a falling sprite where her legs are both stretched forwards and her hat lifts like the air was pushing it up.
Thanks for this, it's good to know animation can be customized like that
Hi everyone, I noticed that if you want to control also the frames of the sprite (let's say you use the controller and want to see the player walk at a slower pace), you can simply adjust the image_speed parameter to abs(moveDir).
Example:
//Walk
if abs(xspd) > 0 {sprite_index = walkSpr; image_speed = abs(moveDir);}
By simply doing this you can adjust the speed with the lever on your controller and notice the change in the walking speed on the walking sprite.
Oh... and btw if you want to use the lever of the controller to walk you can simply do this:
right_key = keyboard_check(ord("D")) + gamepad_axis_value(0, gp_axislh);
right_key = clamp(right_key, 0, 1);
left_key = keyboard_check(ord("A")) - gamepad_axis_value(0, gp_axislh);
left_key = clamp(left_key, 0, 1);
I don't know if it also will happen to you but when I use the lever analog data from the movement it is never -1/0/1, it can be also float numbers so I changed the code by changing 0 with 0.01, this because the controller lever as I said is never a full integer.
Adapted code:
//Walk
if abs(xspd) > 0.01 {sprite_index = walkSpr; image_speed = abs(moveDir);}
peyton has starcross fully come out yet either way yiu got me into game design
Starcross Starcade Special is coming out this year! I'll definitely be doing an update on that soon!
It feels criminal to be this early
I found that the walking code you went with was prone to crashing, so I went with this as a comromise:
if xspd > 0 { sprite_index = walkSpr; };
if xspd < 0 { sprite_index = walkSpr; };
I'm not sure what in your code I was working wrong, but at least I got it working
I also had a similar problem with that line of code, but instead of 2 lines of code, you can efficiently write it as...
if xspd != 0 { sprite_index = walkSpr}
tips for GM if you rename your image with strip and the number like "exemple_strip4" it's will strip it in 4 (in this case) when you drag it into GM
If you're having issues with your character paper maria-ing when walking in different directions and dissapearing when idle (but only when a controller is connected), it's likely an issue for if you added joystick support. I fixed it up for me by adding rounding and it works. If you're having these issues, replace what defines your right and left keys (in the general_functions script) with this and it should work! Here:
rightKey = keyboard_check(ord("D")) + keyboard_check(vk_right) + gamepad_button_check(0, gp_padr) + round(gamepad_axis_value(0, gp_axislh));
rightKey = clamp(rightKey, 0, 1);
leftKey = keyboard_check(ord("A")) + keyboard_check(vk_left) + gamepad_button_check(0, gp_padl) + round(gamepad_axis_value(0, gp_axislh)*-1);
leftKey = clamp(leftKey, 0, 1);
was watching the subpixel problem wondering if it was just me messing up the code for several videos lol
That outta pocket bit with miyamoto was really funny, I appreciated that.
Did...did he show up at your door too? D:
@@matthewlawton9241 Yes, but it wasn't a bat... it was a hammer.
how could i do sprites for an asymmetrical character?
Instead of using the sprite scale to change direction, you would probably have to do it all in the sprite control, so when setting a sprite for walking and jumping, you would have to set one for walking left and one for walking right.
To switch between the two you can simply check movedir, if it's 1 you use one direction if it's 0 you are going to the other direction.
❤❤Can I use your character body and movements to create my own character?❤❤
if i don't have a use for the running section will that mess me up later or am i good to skip it?
12:53 "Then" I proceeded to write my second and third lines of code before it was shown in the video! WOOT
Except I did the third one a little different. I'm not sure if this affects much?
if ySpeed != 0
{
sprite_index = playerJumpSprite;
}
I completely forgot about onGround and my thought process was (from the absolute value of xSpeed) obj_Player will only be falling if ySpeed is -1 or 1.
Everything is fine, except for one thing. After I added draw_sprite_ext to the draw event, the sprite animation stopped working. How can I fix this? I did everything as in the video.
Ok, I found a solution. I added a custom image_speed to each movement where located the //sprite control.
awesome tutorial
hi. why is it that when I run to the left, the sprite does not change but is superimposed on top, it turns out that my character runs both to the left and to the right (((( I double-checked everything, found no errors,after adding the draw_sprite_ext function, this happens
did you find any solution?
Not sure if you are doing your arrays that way intentionally? But you can just do this: moveSpd = [2, 3.5];
I'm pretty sure he is doing that way to make it easier for newer people to understand.
HERCULES STYLE >_
would be cool if you showed a tutroial on how to make undertale fangames
19:33
I love you Peyton
I have a jump animation that has multiple frames, but it keeps looping after I've already jumped. How do I fix that?
Bro I’m so early to this
Could you make a cutscene tutorial at some point? That would be really helpful! 🙏🙏🙏
seconded
Hey Peyton! I followed your tutorials for making RPGs for beginners, could you tell me what the song in the videos is called? I’m obsessed
with putting _strip (number of sprites you have) so that it adjusts automatically
Example: asdas_strip3
17:11 --- could be used instead of the + and the clamp?
That's what I did and have not had any issues YET.
...Also at 17:49 I attempted to figure this one out by myself and ended up with
runType = abs(moveDirection * runKey);
I was thinking since the moveSpeed array can only be 0 or 1, it can't be negative (absolute value) and it only applies when there's a moveDirection != 0.. if moveDirection is 0 the equation is 0, so player wouldn't be running?
I did try this before pressing Play again and it seems to be working without any issues YET.
It was also working while I was in the air, which felt weird, so I added one more line of code the runType code line
if !onGround
{
runType = 0;
}
so far.... so good... YET?
I'm a super beginner and literally these are my first lines of code and understanding of code ever. I do realize if the array for moveSpeed ever goes to [2] for any reason that my code breaks entirely because I don't know how to make that equation equal 0, 1, or 2.
Locked in for this one, no mistakes and it looks wicked, thanks for the sprites too, having all the assets help make quick progress
really nice to see another great tutorial from the best coding teacher i've ever seen videos of
i actually didnt need the sprites cause i made my own in 15 mins lol
4:07 You sounded like the imessage message sent sound 💀
Hey guys, so I have a weird bug. When I walk off a ledge now, my character floats (they can walk around in midair). This happens until I jump, then gravity kicks back in. Any ideas what I did wrong?
Issue solved! I uh, accidently deleted the end of this line of code.
if yspd >= 0 && place_meeting( x, y+1, o_wall )
{
setonground(true);
} else {
onground = false;
}
i think i might love u
hey, i'm with a problem, whenever my character is idle he just ceases to exist.
Does he kind of paper mario himself back and forth when you walk? I'm having the same issue. Only happens when I have a controller connected.
Hi again! Fixed it! Apparently it has to do with joystick values not just being 0 or 1. Here's the code you should replace your right and left key stuff from the general_functions script:
rightKey = keyboard_check(ord("D")) + keyboard_check(vk_right) + gamepad_button_check(0, gp_padr) + round(gamepad_axis_value(0, gp_axislh));
rightKey = clamp(rightKey, 0, 1);
leftKey = keyboard_check(ord("A")) + keyboard_check(vk_left) + gamepad_button_check(0, gp_padl) + round(gamepad_axis_value(0, gp_axislh)*-1);
leftKey = clamp(leftKey, 0, 1);
Hey Peyton. Is there a way to disable "Interpolate colours between pixels" globally or programmatically (so Maria doesn't look all blurry)? I found the option in Game Options, but you have to change it for each platform individually.
I don’t know if you answer coding questions but In the game I’m making my player sprites design isn’t reversible so It can’t just be flipped on the x axis sadly. I couldn’t find any video really explaining how I could change my sprites to fix this issue.
Absolutely great tutorial series! It’s making me feel like an actual game developer! Can’t wait for more!
Well, this gonna be a good day !