I don’t know why this isn’t series isnt as popular as it should be. This series has taught me so much about GameMaker Studio 2 and you’ve inspired me to make my own game even without coding experience!
Yes, i just started learning game maker as well, and every tutorial besides this on is so very confusing, i like how he explains what everything does in depth
You are seriously the best. It’s been a dream of mine since I was a kid to make my own rpg. Fast forward a bit I’ve got a really solid story to work with!!......and absolutely 0 coding experience haha. I have a really strong vision of how I want the game to work without any idea how to put it into action. This is a lot of help, thank you. I guess I should start making sprites and stuff haha....
It is really hard to see the codes in the screen, so I keep having to enhance the image quality, so it'd quite helpful if you zoomed in a bit. Asides from that I must say this is an amazing class pal, I been always imagining to make a game out of my story
if your player sprite appears to be behind a wall when they approach one above them, you need to go to the room, find the layers window, and move the player object to the bottom of all the objects. that will put your player above them all, and make the collision masks still work properly. (just thought i'd add this tip, bc i ran into this issue but thankfully already knew how to fix it)
if you have an error with sprites remember to change your own name! Like if your player name is Mike then don't write "sprite[RIGHT] = spr_player_right;" like in tutorial but sprite[RIGHT] = Mike_right; (and don't forget to use = not -) because gm won't know who's spr_player. hope this helps!💕
Thank you so much! I've been struggling for about 15 minutes now why my spr_player_right keeps getting an error, its because I didn't have it changed to the placeholder name I gave the player! TwT
@@einaryt6972 nvm i found it, you have to duplicate the file, for some reason its as if the gamemaker file breaks and it gets stumped on the macro sprite stuff, im not sure if you hvae to close and reopen, but "Save as" and then using the new file fixed it 4 me
If anyone is interested, I modified the code so the left/right sprites are taking priority when moving on a perfect diagonal. You might want to rename the variables depending on what you chose. // Sprite Animation if abs(xspeed) >= abs(yspeed) { if xspeed < 0 { face = LEFT; } if xspeed > 0 { face = RIGHT; } } else { if yspeed < 0 { face = UP; } if yspeed > 0 { face = DOWN; } } sprite_index = sprite[face];
I'm only having left and right facing sprites in my game so after copying the tutorial my character was moon walking sometimes I found it funny so I kept it in and made it a feature lol. Great series my game's going pretty well so far
Thank you so much for your help, it's greatly appreciated and it has motivated me to pick up GameMaker Studio 2 again. With kind regards, Happy Norwegian man.
I know this series is decently old but it’s still REALLY good. So currently I’m learning to improve my mentality by meditating and improving my visualization within my mind, so I can wrap around how I can get these visions in my head to be more solid and condensed into manageable ideas that I can create in video games. It’s a process I’ve taken for granted but now I’m starting to get the hang of it! I actually wanted to go into the 8-wind compass rose directions(N, E, W, and S.. but also the diagonals NE, NW, SE, and SW). It took me a long minute to break down what I learned so far, but I was able to change the macros to go from EAST, counter clockwise ofc, all the way to SEAST(instead of 1 being NORTH and 2 being WEST, it would be 1 as NEAST, 2 as NORTH, 3 as NWEST, and so forth all the way around). After I modified my macros, my create event, and my step event, I actually didn’t need to have the bit that resets the directions to face the right way, since the “moving diagonally backwards” bug wouldn’t happen since I already had diagonals accounted for in the correct direction! Then I added the extra sprites(had to make a new arrow for diagonals, but then I used the image rotation like he showed us), and I was done!!! It took me a bit of thinking, but I’m really proud that I didn’t need to look up a separate tutorial and I was able to modify it on my own just by thinking about it and back-tracking the steps carefully. Also using the // to write notes was very helpful in keeping track of what parts were making me face where so I didn’t have to constantly think about which line was making the character move in a specific direction as I was rewriting the code. Thank you a bunch Peydin!!! I’m gonna add assets and stuff later, but when I’m done with my game and make it uniquely mine.. I’ll make sure to add a personal Easter egg for you to find! 😁
I just have to say that you are a bloody life saviour. I was banging my head against my desk for almost two days because I was trying to do something similar in correlation with movement and sprites also stopping and resuming to be displayed properly after opening and closing the inventory and also colliding into walls. You helped me out a lot this evening and I thank you for it. Your game looks neat, I will definitely buy it when it comes out. I will go and make a sandwich now.
Thank you so so much for this! I managed to fiddle with the code so I can switch between an idle and walking animation =0!! For those wondering: Make a separate array group for your idle animation in the create tab Then go back to the step tab and replace sprite_index with this: (I added my sprite_index at the top but idk if it affects the code or not Edit: It does! Having it before the rest of the set sprite code will keep you from moving freely in the up,down space) if xspd == 0 && yspd == 0 {sprite_index = idle_array[face];} else {sprite_index = walk_array[face]} This also gets rid of the animation section since if does that in the set sprite section.
any chance you could explain this in a way that even a 5 year old could not mess it up? lol I kind of understand but i actually have no idea what you mean, how do I make a seperate group for idle animation? and what do you mean by else? is that part of the code. sorry. I am a complete beginner and no nothing about coding atm. thank you
I think the array they're talking about is the one where you set the sprite variables to the actual sprite you drew, eg: sprite_idle[RIGHT] = spr_player_right; sprite_idle[UP] = spr_player_up; sprite_idle[LEFT] = spr_player_left; sprite_idle[DOWN] = spr_player_down;
I am trying to make an Undertale Fan Game and this series has helped me a lot with the basic foundations of my game. Thankyou so much for creating this series!
If anyone is interested, this is the code I used to modify the above script into 8-Direction Movement: if y_spd < 0 { if x_spd < 0 {face = UP_LEFT;} if x_spd > 0 {face = UP_RIGHT;} }
if y_spd > 0 { if x_spd < 0 {face = DOWN_LEFT;} if x_spd > 0 {face = DOWN_RIGHT;} } if y_spd == 0 { if x_spd > 0 {face = RIGHT;} if x_spd < 0 {face = LEFT;} } if x_spd == 0 { if y_spd > 0 {face = DOWN;} if y_spd < 0 {face = UP;} }
@@MicahYaple you'd need to make a different sprite for the new macros and assign them the same way as you did the others. spr_player_down_right for the sprite and the Macro would be #macro DOWN_RIGHT 4 and the create event for the player obj would be sprite[DOWN_RIGHT] = spr_player_down_right
Thank you so much with these tutorials, I have always really wanted to create video games but had no idea how to code this is super helpful for the rpg I want to create :))
A much cleaner solution to the issue discussed at 10:37 is to simply remove the the "if xspd == 0" condition for setting the position as up or down. The code for this would be: if yspd == 0 { if xspd > 0 {face = RIGHT}; if xspd < 0 {face = LEFT}; } if yspd > 0 {face = DOWN}; if ySpd < 0 {face = UP};
My guess is that you would have the animation as a normal sprite animation. Then placing it into and if statement that plays when nothing is pressed on the keyboard
I haven't tested this code but I imagine it would work something like this: In scr_Macros: #macro IDLE 4 In obj_Player Create event: sprite[IDLE] = spr_Player_Idle; In obj_Player Step event: if x_Speed == 0 && y_Speed == 0 { face = IDLE; } You could probably just set the face variable in Step event to DOWN instead so it would just be: In obj_Player Step event: if x_Speed == 0 && y_Speed == 0 { face = DOWN; }
Ive always wanted to learn how to make games since i was little, all the lessons and stuff just didnt work, then i found geometry dash, (its like scratch coding but easier) it is a rhythm game but you can make awesome stuff there in the paid, but it had many problems like data, sound effects, and checkpoints, and i didnt think i could learn programming, but you helped me and now im learning!
Im having a small issue with the fix in 11:05 because when i type out the if statement exactly how you did it says "empty if statement". How do i fix this?
can anyone help i get this error every time i try load the scene ERROR in action number 1 of Step Event0 for object obj_player: Variable obj_player.sprite(100012, 3) not set before reading it. at gml_Object_obj_player_Step_0 (line 30) - sprite_index = sprite[face];
Every time i looked on the playstore or anyhting to find a rpg game I could never find one that appealed to me. You made my dreams come true of making a rpg game and im truly thankful
Btw, you might notice that if you click left_key and right_key at the same time they will cancel out and the player will stop moving, because 1 - 1 = 0. So to avoid this, you can make the player continue moving based on the the last pressed key instead. Make a variable called something like lastPressedLeftRight. So for example, if your lastPressed variable is 0, assign 1 to the left_key variable, and make the player move to the desired direction. Like this: //Create Event lastPressedLeftRightUpDown = 0; //Step Event // So the player doesn't stop moving if they press opposing directions at the same time. //If going right but clicks left. Or vice versa. if lastPressedLeftRightUpDown == false && left_key == 1 { xspd = -1; face = LEFT; } //If going down but clicks up. Or vice versa. if lastPressedLeftRightUpDown == 0 && down_key == 1 { yspd = 1; face = DOWN; } You can expand on this, but for me it works to keep this for left/right VS up/down.
@@espectroplasma746 the lastPressedKey variables are supposed to be booleans, tho. So when it's equal to 0 it's same as being false. And when it's equal to 1 it's the same as being true.
So quick question about the sprite masking and stuff, say I make a somewhat humanoid sprite (So from the front you see the full body, while on the side it's not as wide since it's only part of the body), I noticed masking makes it so the sprite doesn't fully hit the wall on the side but it will from up and down. Is there any way to make it so the side sprite will touch the wall without messing up the masking, or is it just going to have to stay a few pixels away from the wall? I also noticed with your sprite, you always made sure you had one pixel out to the limit on all sides, should I be trying to do that if I do make a humanoid sprite in order to not have this weird gap instead? Overall helpful tutorial, just for how I want to make sprites (I know next to nothing so I'm making really basic humanoid sprites to start) I have a bit of issues with the masking.
Yeah, unfortunately that will just be one of your jobs as a pixel artist. You'll have to make sure that the sprites from all 4 directions (or 8 or 16 or whatever) will need to fit the same collision mask. If you look at some of your favorite RPGs, no matter which way the character is facing they'll normally take up the same amount of space for this very reason. For a lot of top down RPGs where you're mostly just traversing or puzzle solving (e.g. Earthbound, Dragon Quest, OneShot, etc) it isn't that much of an issue if the left and right facing sprites are thinner. However, if your game is more action-y like a Zelda game or has stuff you need to dodge in the over world like Deltarune, you're going to want to make all of the sprites for your character to be roughly the same size. And I just set my collision mask to something I thought looked nice! Sometimes it can look a little odd if your mask is very tight to the character's body and they can press right up against a wall, especially something like my character which has a big head! But whatever looks nice to you is what works the best! As long as it doesn't negatively affect the gameplay of your game, no one will judge it for having a couple extra little pixels of space!
@@peytonburnham4316 Alright then, thanks for the heads up on that. I'll try to keep that in mind when I inevitably work on some small zelda-like projects. At least for right now it shouldn't matter all too much since this seems to be a regular rpg, so dodging stuff on the overworld shouldn't be necessary. I'm new to this all as a whole (kinda), so even the small tips like that for pixel art help a lot.
if anyone is having a variable not set before reading it error, its because your code line order is wrong, the variable settings should be before action codes!
I actually fixed the walls blocking the player’s view issue ahead of time so no worries. This is a lot better compared to other tutorials where my game ended up crashing.
Hello, I have a question, and also these tutorials are amazing! How do I code the player not moving/idle? I found a way to do it where when the player is facing down it is completely still with no leg up like it was in a sprite animation, but then when the player walks let’s say left, when they stop walking it makes the player face forward again, since it’s only set on that one sprite, I’m just not sure how to make it for each sprite without affecting the other sprites, sorry if this didn’t make sense! If anyone has any idea how to do that the help would be greatly appreciated!
the only thiing like that i know is making it idle when the game starts in the create event sprite[IDLE] = Sprite_player_idle face = IDLE; and then in macros #macro IDLE 5
i found another working way so remove the code that stops the animation at its 1 frame when not moving and put (if xspd == 0 && yspd == 0 { face = IDLE } in step) (sprite[IDLE] = spr_player_idle; in create) as well as (#macro IDLE 4 in macros) just remove the () i put around each topic
Idk who might need it but I coded it like this: if xspd == 0 and yspd == 0 and face == RIGHT {sprite_index = sprite_player_idle_right} (change accordingly for every direction)
these tutorials are great ive really learned from them this one and the last taught me so much like using and's equals brackets variables costumes keys etc
At 18:00 you can just set the collision mask on the object itself instead of doing it in the code (I was 2 years late to leave a comment but whatever lol)
hi! sorry for posting a comment on an old video but could i ask if you made your sprites manually on the sprite editor or did you use another art program for the sprites and then converted them into the sprite editor? if so, what dimensions (like canvas size) did you use for the art program? does it have to be 16px by 16px or can you make the sprites smaller?
I had the same problem until I realized that when writing "face = DOWN" I accidentally put "DOWN" into brackets which left the variable "face" undefined. No sure whether you did the same mistake, but I would suggest to you that you check your code for these kind of mistakes in general.
it says my code isn't working down here if yspd == 0 { if xspd > 0 {face = RIGHT}; if xspd < 0 {face = LEFT}; } here > if xpsd > 0 && face == LEFT {face = RIGHT}; if xpsd < 0 && face == RIGHT {face = LEFT}; if xspd == 0 i did exactly as he did but it still is going wrong can anyone help????? nvm i fixed it
If anyone else is really stupid like me and gets an error for "sprite_index = sprite[face]; on line 35 or so in their step event (When he tests it at around 8:10) Its because I put brackets around DOWN on line 11 in the create event 😭 I literally quit this tutorial a year ago because I couldn't figure out what I was doing wrong omg
Hello I really love your tutorials because its really easy to follow but could you zoom in next time everytime you write a code? It would be extremely helpful and will probably make your tutorials even better
Really helpful video, I just have one problem: I animated my own sprites rather than using yours, and when I press the down key and the left key it shows the spr_player_up sprite as they move down-left. Double checked the code and I think I have it exactly the same as yours?
Does anyone know how to make it change to an idle sprite when you're not moving?? Mine just shows the last frame of the walking animation and I'd like to set it to the default standing still one when nothings being pressed
The only thing i've found to work consistently with animation checks has been either a switch statement or else if statements. I followed your guide to the letter and it doesn't stop looping its animations. Theres no account for image speed or transition from an idle state to a movement state. How people got this to work i don't know.
So I've followed all the code correctly, but whenever I'm moving South, then move towards South West, for some reason it puts the sprite as sPlayerUp, for some reason. Can you help me? Here's my movement code in the Step event; right_key = keyboard_check(ord("D")); left_key = keyboard_check(ord("A")); up_key = keyboard_check(ord("W")); down_key = keyboard_check(ord("S")); xspd = (right_key - left_key) * move_spd; yspd = (down_key - up_key) * move_spd; mask_index = sPlayerDown; if yspd == 0 { if xspd > 0 {face = RIGHT}; if xspd < 0 {face = LEFT}; } if xspd > 0 && face == LEFT{face = RIGHT}; if xspd < 0 && face == RIGHT{face = LEFT}; if xspd == 0 { if yspd > 0 {face = DOWN}; if yspd < 0 {face = UP}; } if xspd > 0 && face == UP{face = DOWN}; if xspd < 0 && face == DOWN{face = UP}; sprite_index = sprite[face]; if place_meeting(x + xspd, y, oWall) == true { xspd = 0; } if place_meeting(x, y + yspd, oWall) == true { yspd = 0; } x += xspd; y += yspd; if xspd == 0 && yspd == 0 { image_index = 0; }
alright i know this video is old at this point but i need some help, whenever im choosing a direction to walk in my animation takes like a whole half second to play, its not super noticeable but if i keep talk walking my player will just glide
I have copied everything for the box arrow pointing part but for some reason when i press left or right arrow buttons the arrow animation appears for up and down and for up and down arrow buttons vice versa direction arrow animation appears even though i followed everything as it is. Is this some version change issue?
I do have one question, i looked through my sprites and code but i cant figure out why my sprites (player left, player right, player up, player down) are blurry, can anybody help? I also noticed that all of my sprites are inverted when i load the game. Can anybody fix that?
when my player hits the wall, it stops, and if i keep the button pressed and begin to use another button for another direction, it moves but doesnt animate. and then if i stop pressing any buttons and then press one again, it moves and animates again normally. is there a solution?
So uhh the player and collisions are set to middle Center and the player still gets stuck on the collision and idk how to fix it but other than that it’s good
If your left walking Sprite its bigger/smaller than the left you could use this code If xspd < 0 {face =[your variable] image x_scale = 1 _} If xspd > 0 {face =[your variable] image x_scale = -1 _} Hope this helps
I dunno why but I go straight through my walls when I try to collide into them. I double-checked that my code was the exact same as yours, and it was. Any help would be appreciated, I'm just starting to code
hello, i have a question. When im doing to coding for the character veiws all the code is correct but it wont go back to facing forward or back after sideways, is there anything i could have done wrong? code says its right but it still doesnt work
Just a quick question, unsure if it makes sense, but… instead of having 0, 1, 2, 3 as the macros you could have spr_player_right, spr_player_up, etc and forego the array altogether by setting face to the macros and sprite index to to face?!
I've watched this video and went through the code a bunch of times, everything works except when i go left and up the sprite keeps flipping back and forth between the correct sprite and the sprite facing the opposite direction when i move. everything in my codes looks exactly the same, i went through it line for line. I cant figure out what i did wrong.
Nevermind I figure it out after like three hours LOL! When I copy and pasted the sprite i only change the first frame in the animation. I had one arrow facing one way and two arrows in the opposite direction so it was animating that when I moved.
If the sprite gets bigger it sounds like you might be using the image_xscale or image_yscale where you don't need to be. The best advice I can give you for both that and the sprite issue is to double check your code and make sure it 100% matches the video! Good luck!
hey idk if anyone will help me but even tho i did evrything correct whenever i try to test the player movement like in 8:20 i keep getting an error for the "sprite_index" : Variable .face(100011, -2147483648) not set before reading it. at gml_Object_obj_player_Step_0 (line 34) - sprite_index = sprite[face]; i did evrything like in the video but cant get past this point, can someone help?
hey if you stil read comments the code broke after i put the sprite animations code what should i do. it says the right key stuff is brocken even though it used to work before that. can you help me? PS. and when i remove the stoping animation code it worked again what the heck is going on???
I don’t know why this isn’t series isnt as popular as it should be. This series has taught me so much about GameMaker Studio 2 and you’ve inspired me to make my own game even without coding experience!
That's so awesome!! So glad to hear that! Good luck to you!
since two years a lot has changed but still its one of the best tutorial
Yes, i just started learning game maker as well, and every tutorial besides this on is so very confusing, i like how he explains what everything does in depth
You are seriously the best. It’s been a dream of mine since I was a kid to make my own rpg. Fast forward a bit I’ve got a really solid story to work with!!......and absolutely 0 coding experience haha. I have a really strong vision of how I want the game to work without any idea how to put it into action. This is a lot of help, thank you. I guess I should start making sprites and stuff haha....
I think it's best to do the sprites as you go
Or else you will end up not doing anything
I guess we are rivels now
we both have the same dream
and we both have the same sensei
Well
Good luck!
@@NanoKaufman wish u the best of luck as well!!! :)
@Feba Sox I'm joining in too
It is really hard to see the codes in the screen, so I keep having to enhance the image quality, so it'd quite helpful if you zoomed in a bit.
Asides from that I must say this is an amazing class pal, I been always imagining to make a game out of my story
im two years later but thank you. you have helped me start my dream goal of making games. Hats off to you my man
me and you both
me and both of you
Same
if your player sprite appears to be behind a wall when they approach one above them, you need to go to the room, find the layers window, and move the player object to the bottom of all the objects. that will put your player above them all, and make the collision masks still work properly. (just thought i'd add this tip, bc i ran into this issue but thankfully already knew how to fix it)
omg ty so much i was wondering how to fix that
ah yes moving the layer all the way to the bottom makes it go to the top of the layer hierarchy
if you have an error with sprites remember to change your own name! Like if your player name is Mike then don't write "sprite[RIGHT] = spr_player_right;" like in tutorial but sprite[RIGHT] = Mike_right; (and don't forget to use = not -) because gm won't know who's spr_player. hope this helps!💕
Thank you so much! I've been struggling for about 15 minutes now why my spr_player_right keeps getting an error, its because I didn't have it changed to the placeholder name I gave the player! TwT
@@pikapika6288 MAN TEACH ME IM STRUGGLING AND I DONT UNDERSTAND WHAT SHE SAID, AND I HAVE THE SAME PROBLEM
@@einaryt6972 same
@@einaryt6972 nvm i found it, you have to duplicate the file, for some reason its as if the gamemaker file breaks and it gets stumped on the macro sprite stuff, im not sure if you hvae to close and reopen, but "Save as" and then using the new file fixed it 4 me
@@isaactheman8004 Alright hahaha, I found a solution, doing it in a different way, but I appreciate your help
I'm having nightmares about the Luigi in the window now but aside from that I'm learning loads about game making which is really helpful, thank you!
Good, to both of those things :)
*L U I G I*
@@bilemon_alteiou881 L U I G I
OH YEAH!
ooooOOOOOOOO YEAAA--
If anyone is interested, I modified the code so the left/right sprites are taking priority when moving on a perfect diagonal. You might want to rename the variables depending on what you chose.
// Sprite Animation
if abs(xspeed) >= abs(yspeed)
{
if xspeed < 0
{
face = LEFT;
}
if xspeed > 0
{
face = RIGHT;
}
}
else
{
if yspeed < 0
{
face = UP;
}
if yspeed > 0
{
face = DOWN;
}
}
sprite_index = sprite[face];
Thank you for doing this it helped a ton
thank you sir you are LIFESAVEr
I'm only having left and right facing sprites in my game so after copying the tutorial my character was moon walking sometimes
I found it funny so I kept it in and made it a feature lol. Great series my game's going pretty well so far
i got sad when I fixed my moonwalk
I'll make it a feature too lol
Thank you so much for your help, it's greatly appreciated and it has motivated me to pick up GameMaker Studio 2 again. With kind regards, Happy Norwegian man.
So glad to help! Keep on going, I hope you make some cool stuff!
@@peytonburnham4316 Hey Buddy! What if there's a match between Luigi v Parle G
I know this series is decently old but it’s still REALLY good.
So currently I’m learning to improve my mentality by meditating and improving my visualization within my mind, so I can wrap around how I can get these visions in my head to be more solid and condensed into manageable ideas that I can create in video games. It’s a process I’ve taken for granted but now I’m starting to get the hang of it!
I actually wanted to go into the 8-wind compass rose directions(N, E, W, and S.. but also the diagonals NE, NW, SE, and SW).
It took me a long minute to break down what I learned so far, but I was able to change the macros to go from EAST, counter clockwise ofc, all the way to SEAST(instead of 1 being NORTH and 2 being WEST, it would be 1 as NEAST, 2 as NORTH, 3 as NWEST, and so forth all the way around).
After I modified my macros, my create event, and my step event, I actually didn’t need to have the bit that resets the directions to face the right way, since the “moving diagonally backwards” bug wouldn’t happen since I already had diagonals accounted for in the correct direction!
Then I added the extra sprites(had to make a new arrow for diagonals, but then I used the image rotation like he showed us), and I was done!!!
It took me a bit of thinking, but I’m really proud that I didn’t need to look up a separate tutorial and I was able to modify it on my own just by thinking about it and back-tracking the steps carefully.
Also using the // to write notes was very helpful in keeping track of what parts were making me face where so I didn’t have to constantly think about which line was making the character move in a specific direction as I was rewriting the code.
Thank you a bunch Peydin!!! I’m gonna add assets and stuff later, but when I’m done with my game and make it uniquely mine.. I’ll make sure to add a personal Easter egg for you to find! 😁
Did u stick with it?
I just have to say that you are a bloody life saviour. I was banging my head against my desk for almost two days because I was trying to do something similar in correlation with movement and sprites also stopping and resuming to be displayed properly after opening and closing the inventory and also colliding into walls. You helped me out a lot this evening and I thank you for it.
Your game looks neat, I will definitely buy it when it comes out.
I will go and make a sandwich now.
Thank you so so much for this! I managed to fiddle with the code so I can switch between an idle and walking animation =0!!
For those wondering:
Make a separate array group for your idle animation in the create tab
Then go back to the step tab and replace sprite_index with this: (I added my sprite_index at the top but idk if it affects the code or not Edit: It does! Having it before the rest of the set sprite code will keep you from moving freely in the up,down space)
if xspd == 0 && yspd == 0
{sprite_index = idle_array[face];}
else
{sprite_index = walk_array[face]}
This also gets rid of the animation section since if does that in the set sprite section.
uhhh whats an array group idk im watching this video again just to figure out how to do an idle animation
any chance you could explain this in a way that even a 5 year old could not mess it up? lol I kind of understand but i actually have no idea what you mean, how do I make a seperate group for idle animation? and what do you mean by else? is that part of the code. sorry. I am a complete beginner and no nothing about coding atm. thank you
I think the array they're talking about is the one where you set the sprite variables to the actual sprite you drew, eg:
sprite_idle[RIGHT] = spr_player_right;
sprite_idle[UP] = spr_player_up;
sprite_idle[LEFT] = spr_player_left;
sprite_idle[DOWN] = spr_player_down;
I am trying to make an Undertale Fan Game and this series has helped me a lot with the basic foundations of my game. Thankyou so much for creating this series!
good after your done this maybe you can do an original
Omg im making one too!
that person dserves much more likes, comments and subs. i´ve never seen such a good and understandable tutorial!!!
I am confused when did we make it so that if you aren't pressing the button the sprite doesn't animate?
16:22
If anyone is interested, this is the code I used to modify the above script into 8-Direction Movement:
if y_spd < 0
{
if x_spd < 0 {face = UP_LEFT;}
if x_spd > 0 {face = UP_RIGHT;}
}
if y_spd > 0
{
if x_spd < 0 {face = DOWN_LEFT;}
if x_spd > 0 {face = DOWN_RIGHT;}
}
if y_spd == 0
{
if x_spd > 0 {face = RIGHT;}
if x_spd < 0 {face = LEFT;}
}
if x_spd == 0
{
if y_spd > 0 {face = DOWN;}
if y_spd < 0 {face = UP;}
}
thanks
you're the best
THANK YOU! I was pulling my hair on that one and it turned out to be an easy solution.
What do the macros look like then in the script? 🤔
@@MicahYaple you'd need to make a different sprite for the new macros and assign them the same way as you did the others. spr_player_down_right for the sprite and the Macro would be #macro DOWN_RIGHT 4
and the create event for the player obj would be sprite[DOWN_RIGHT] = spr_player_down_right
Why’s this free this is literally the only thing keeping me sane while coding it’s entertaining plus you TEACH
This series has been a genuine lifesaver haha, has helped me learn Gamemaker so much. Fantastic work man!
I'm literally about to credit this man in the game he's helped soooo much
this is so enteraining that i'm watching even tho I don't use Game Maker
Haha thanks!
Thank you so much with these tutorials, I have always really wanted to create video games but had no idea how to code this is super helpful for the rpg I want to create :))
thats nice! hope you're still working on it
I have a dream of making an undertale inspired game and with this, it helps me a lot thank you!!!
@@ravimediatube good luck to you as well!
Same here! Goodluck to you two
bro same good luck broski
:)
@@boxlord7765 would you like to help me? If you know how to code
A much cleaner solution to the issue discussed at 10:37 is to simply remove the the "if xspd == 0" condition for setting the position as up or down.
The code for this would be:
if yspd == 0 {
if xspd > 0 {face = RIGHT};
if xspd < 0 {face = LEFT};
}
if yspd > 0 {face = DOWN};
if ySpd < 0 {face = UP};
dawg thank u so much
incredible video series I'm having tons of fun with this project and this is a great base to start off of
Imma let you finish but this is the best tutorial soundtrack of all time.
the origin points being all over the place looks really funny, I might jsut add it to a random dopey game if I make another one in the future
simply phenomenal tutorial. I was wondering though, how do I add an idle animation for when my character is still?
My guess is that you would have the animation as a normal sprite animation. Then placing it into and if statement that plays when nothing is pressed on the keyboard
that helps a lot thanks!
I haven't tested this code but I imagine it would work something like this:
In scr_Macros:
#macro IDLE 4
In obj_Player Create event:
sprite[IDLE] = spr_Player_Idle;
In obj_Player Step event:
if x_Speed == 0 && y_Speed == 0 { face = IDLE; }
You could probably just set the face variable in Step event to DOWN instead so it would just be:
In obj_Player Step event:
if x_Speed == 0 && y_Speed == 0 { face = DOWN; }
if (xspeed = 0 and yspeed = 0) {sprite_index = spr_player_pause;}
17:50 this is the best piece of code I have ever seen, thank you so much
Ive always wanted to learn how to make games since i was little, all the lessons and stuff just didnt work, then i found geometry dash, (its like scratch coding but easier) it is a rhythm game but you can make awesome stuff there in the paid, but it had many problems like data, sound effects, and checkpoints, and i didnt think i could learn programming, but you helped me and now im learning!
for me my stuff wont run bc sprite_index = sprite[face]; is apparently illegal, does anyone know a fix for this?
Im having a small issue with the fix in 11:05 because when i type out the if statement exactly how you did it says "empty if statement". How do i fix this?
can anyone help i get this error every time i try load the scene
ERROR in
action number 1
of Step Event0
for object obj_player:
Variable obj_player.sprite(100012, 3) not set before reading it.
at gml_Object_obj_player_Step_0 (line 30) - sprite_index = sprite[face];
One of your face code isn’t matching up
Nice and easy to follow tutorial for Game Maker 2. Thanks.
for some reason, every time I play the game, it gives me an error but I did everything right idk what to do :p
Tysm, I always wanted to learn how to make games just for fun and now I can!
Every time i looked on the playstore or anyhting to find a rpg game I could never find one that appealed to me. You made my dreams come true of making a rpg game and im truly thankful
try Zenonia 4! its the best rpg I've found so far. it was really fun, although in the end game there's a bug and you can't progress anymore.
jeez we're only two parts in and we already got a SHIT TON of variables
I'm mainly using this to get used to game maker 2, it's very different to game maker 1 so I definitely needed this
Thank you very much
Btw, you might notice that if you click left_key and right_key at the same time they will cancel out and the player will stop moving, because 1 - 1 = 0. So to avoid this, you can make the player continue moving based on the the last pressed key instead. Make a variable called something like lastPressedLeftRight. So for example, if your lastPressed variable is 0, assign 1 to the left_key variable, and make the player move to the desired direction. Like this:
//Create Event
lastPressedLeftRightUpDown = 0;
//Step Event
// So the player doesn't stop moving if they press opposing directions at the same time.
//If going right but clicks left. Or vice versa.
if lastPressedLeftRightUpDown == false && left_key == 1 {
xspd = -1;
face = LEFT;
}
//If going down but clicks up. Or vice versa.
if lastPressedLeftRightUpDown == 0 && down_key == 1 {
yspd = 1;
face = DOWN;
}
You can expand on this, but for me it works to keep this for left/right VS up/down.
but, how i know what is the last key pressed?
@@espectroplasma746 the lastPressedKey variables are supposed to be booleans, tho. So when it's equal to 0 it's same as being false. And when it's equal to 1 it's the same as being true.
Hi!! So im having a issue of my code not working with the spr_player_right; ect any tips
So quick question about the sprite masking and stuff, say I make a somewhat humanoid sprite (So from the front you see the full body, while on the side it's not as wide since it's only part of the body), I noticed masking makes it so the sprite doesn't fully hit the wall on the side but it will from up and down. Is there any way to make it so the side sprite will touch the wall without messing up the masking, or is it just going to have to stay a few pixels away from the wall? I also noticed with your sprite, you always made sure you had one pixel out to the limit on all sides, should I be trying to do that if I do make a humanoid sprite in order to not have this weird gap instead? Overall helpful tutorial, just for how I want to make sprites (I know next to nothing so I'm making really basic humanoid sprites to start) I have a bit of issues with the masking.
Yeah, unfortunately that will just be one of your jobs as a pixel artist. You'll have to make sure that the sprites from all 4 directions (or 8 or 16 or whatever) will need to fit the same collision mask. If you look at some of your favorite RPGs, no matter which way the character is facing they'll normally take up the same amount of space for this very reason.
For a lot of top down RPGs where you're mostly just traversing or puzzle solving (e.g. Earthbound, Dragon Quest, OneShot, etc) it isn't that much of an issue if the left and right facing sprites are thinner. However, if your game is more action-y like a Zelda game or has stuff you need to dodge in the over world like Deltarune, you're going to want to make all of the sprites for your character to be roughly the same size.
And I just set my collision mask to something I thought looked nice! Sometimes it can look a little odd if your mask is very tight to the character's body and they can press right up against a wall, especially something like my character which has a big head! But whatever looks nice to you is what works the best! As long as it doesn't negatively affect the gameplay of your game, no one will judge it for having a couple extra little pixels of space!
@@peytonburnham4316 Alright then, thanks for the heads up on that. I'll try to keep that in mind when I inevitably work on some small zelda-like projects. At least for right now it shouldn't matter all too much since this seems to be a regular rpg, so dodging stuff on the overworld shouldn't be necessary. I'm new to this all as a whole (kinda), so even the small tips like that for pixel art help a lot.
Part 2 of the tutorial accomplished. Many thanks on your comment about collision detection in the first part! Turns out I mistyped something.
Great pace and very entertaining
if anyone is having a variable not set before reading it error, its because your code line order is wrong, the variable settings should be before action codes!
I actually fixed the walls blocking the player’s view issue ahead of time so no worries.
This is a lot better compared to other tutorials where my game ended up crashing.
yeah same,it wasn't hard to fix
Hello, I have a question, and also these tutorials are amazing! How do I code the player not moving/idle? I found a way to do it where when the player is facing down it is completely still with no leg up like it was in a sprite animation, but then when the player walks let’s say left, when they stop walking it makes the player face forward again, since it’s only set on that one sprite, I’m just not sure how to make it for each sprite without affecting the other sprites, sorry if this didn’t make sense! If anyone has any idea how to do that the help would be greatly appreciated!
the only thiing like that i know is making it idle when the game starts in the create event
sprite[IDLE] = Sprite_player_idle
face = IDLE;
and then in macros #macro IDLE 5
@@SSSSSondon the sprite starts out idle but when you walk it doesnt go back to being idle
i found another working way so remove the code that stops the animation at its 1 frame when not moving and put
(if xspd == 0 && yspd == 0
{
face = IDLE
}
in step)
(sprite[IDLE] = spr_player_idle;
in create)
as well as
(#macro IDLE 4
in macros)
just remove the () i put around each topic
Idk who might need it but I coded it like this:
if xspd == 0 and yspd == 0 and face == RIGHT {sprite_index = sprite_player_idle_right} (change accordingly for every direction)
@@Україна-о2щ Thanks! I was seeing if I was doing something wrong and forgot about idle sprites this code helped so much!
Thank you for your videos ! Great help
Im 3 years late but ty man you taught me more and better things than anybody and Im makingmy own game aswell now!! :^)
Can you link a .zip file to the sprites that you use in this video? Thanks
these tutorials are great ive really learned from them this one and the last taught me so much like using and's equals brackets variables costumes keys etc
love your tutoraisl. im doing everything step by step 🤩
At 18:00 you can just set the collision mask on the object itself instead of doing it in the code
(I was 2 years late to leave a comment but whatever lol)
nice bro
hi! sorry for posting a comment on an old video but could i ask if you made your sprites manually on the sprite editor or did you use another art program for the sprites and then converted them into the sprite editor? if so, what dimensions (like canvas size) did you use for the art program? does it have to be 16px by 16px or can you make the sprites smaller?
the sprite editor is built into game maker
@@Shadowsbackgrounds I know, I just prefer using my art program more
@@ashsurix_ana you can import sprites up to 64 by 64 and im pretty sure 8 by 8 aswell
in that case
on sprite_index = sprite[face]; it says theres an illegal array use, and the code wont run. does anyone know how to fix this?
I had the same problem until I realized that when writing "face = DOWN" I accidentally put "DOWN" into brackets which left the variable "face" undefined. No sure whether you did the same mistake, but I would suggest to you that you check your code for these kind of mistakes in general.
@@tobstobs950 thx
Where do I get the sprites?
IDK anyway i need 32 X 32
Hey i'm having a small problem with the if statement. can you pleas help me. it is saying "empty if statement." Thx
it says my code isn't working down here
if yspd == 0
{
if xspd > 0 {face = RIGHT};
if xspd < 0 {face = LEFT};
}
here > if xpsd > 0 && face == LEFT {face = RIGHT};
if xpsd < 0 && face == RIGHT {face = LEFT};
if xspd == 0
i did exactly as he did but it still is going wrong
can anyone help?????
nvm i fixed it
Love the background music!
Wow, this is super helpful, thanks!
Oh good! Super happy to help!
when i run my game my Sprite appears upside down on the screen? what have i done?!? please help me
dude thanks love you man i really liked these tutorials
A really great tutorial, especially for people with not much coding experience. I was just wondering where i could get the sprites. Thank you :)
If anyone else is really stupid like me and gets an error for "sprite_index = sprite[face]; on line 35 or so in their step event (When he tests it at around 8:10)
Its because I put brackets around DOWN on line 11 in the create event 😭 I literally quit this tutorial a year ago because I couldn't figure out what I was doing wrong omg
For anyone in the middle of the video wondering how he made the idle sprite, it was recorded after the rest of the video, and he explains it later.
Do you know when he does it??
Hello I really love your tutorials because its really easy to follow but could you zoom in next time everytime you write a code? It would be extremely helpful and will probably make your tutorials even better
11:03
no, they must moonwalk, diagonally, the must moonwalk DIAGONALLY
Really helpful video, I just have one problem: I animated my own sprites rather than using yours, and when I press the down key and the left key it shows the spr_player_up sprite as they move down-left. Double checked the code and I think I have it exactly the same as yours?
same except mine has up and down flipped, i literally re watched the video and double checked my code lmao
Does anyone know how to make it change to an idle sprite when you're not moving?? Mine just shows the last frame of the walking animation and I'd like to set it to the default standing still one when nothings being pressed
Ik im like 2 years late but my sprites are all like really blurry is there like any way to fix that?
did you fix it because im having the same problem
@@alexscreations2577 no, sorry I’m still stuck
@@sameoso I actually just figured it out
@@alexscreations2577 oh how do you fix it?
@@sameoso I just wrote a whole comment on instructions and I forgot to press send 😀
my character gets stuck in the wall, i scrolled through the comments and no one had explained it so could someone tell me the solution pls
Maybe its because of player collision being uneven for the sprites. Or the code is just wrong
The only thing i've found to work consistently with animation checks has been either a switch statement or else if statements. I followed your guide to the letter and it doesn't stop looping its animations. Theres no account for image speed or transition from an idle state to a movement state. How people got this to work i don't know.
Though the creator did say its "ductapey"
My sprites are appearing fuzzy/ out of focus. I've got them set 16 by 16 so I'm not sure whats wrong..
same. did you figure out how to fix it?
So I've followed all the code correctly, but whenever I'm moving South, then move towards South West, for some reason it puts the sprite as sPlayerUp, for some reason. Can you help me? Here's my movement code in the Step event;
right_key = keyboard_check(ord("D"));
left_key = keyboard_check(ord("A"));
up_key = keyboard_check(ord("W"));
down_key = keyboard_check(ord("S"));
xspd = (right_key - left_key) * move_spd;
yspd = (down_key - up_key) * move_spd;
mask_index = sPlayerDown;
if yspd == 0
{
if xspd > 0 {face = RIGHT};
if xspd < 0 {face = LEFT};
}
if xspd > 0 && face == LEFT{face = RIGHT};
if xspd < 0 && face == RIGHT{face = LEFT};
if xspd == 0
{
if yspd > 0 {face = DOWN};
if yspd < 0 {face = UP};
}
if xspd > 0 && face == UP{face = DOWN};
if xspd < 0 && face == DOWN{face = UP};
sprite_index = sprite[face];
if place_meeting(x + xspd, y, oWall) == true
{
xspd = 0;
}
if place_meeting(x, y + yspd, oWall) == true
{
yspd = 0;
}
x += xspd;
y += yspd;
if xspd == 0 && yspd == 0
{
image_index = 0;
}
alright i know this video is old at this point but i need some help, whenever im choosing a direction to walk in my animation takes like a whole half second to play, its not super noticeable but if i keep talk walking my player will just glide
I have copied everything for the box arrow pointing part but for some reason when i press left or right arrow buttons the arrow animation appears for up and down and for up and down arrow buttons vice versa direction arrow animation appears even though i followed everything as it is. Is this some version change issue?
then what about the player idle? there it only explains about player UP, DOWN, RIGHT, and LEFT I want to make the player idle please help
I do have one question, i looked through my sprites and code but i cant figure out why my sprites (player left, player right, player up, player down) are blurry, can anybody help?
I also noticed that all of my sprites are inverted when i load the game. Can anybody fix that?
i know this is an old comment but i've been having the same issue with blurry sprites. i don't know how to fix it. did you figure it out?
when my player hits the wall, it stops, and if i keep the button pressed and begin to use another button for another direction, it moves but doesnt animate. and then if i stop pressing any buttons and then press one again, it moves and animates again normally.
is there a solution?
it is saying the sprite_index = sprite[face] is illegal what do I do
same for me
So uhh the player and collisions are set to middle Center and the player still gets stuck on the collision and idk how to fix it but other than that it’s good
If your left walking Sprite its bigger/smaller than the left you could use this code
If xspd < 0 {face =[your variable] image x_scale = 1
_}
If xspd > 0 {face =[your variable] image x_scale = -1
_}
Hope this helps
Where can I download the art pack? Is there any link?
My sprites are 16x32 (Kinda like super Mario) and now all my sprites are blurry, what do I do?
Try disabling anti-analysing
Try diabling Interpolate colours between pixels and set your texture page size to 11024x1024 in the Game options
I dunno why but I go straight through my walls when I try to collide into them. I double-checked that my code was the exact same as yours, and it was. Any help would be appreciated, I'm just starting to code
same. i don't understand why because sometimes it works and sometimes it doesnt, did you find out yet ?
that Macro trick god damn that saves alot time
hello, i have a question. When im doing to coding for the character veiws all the code is correct but it wont go back to facing forward or back after sideways, is there anything i could have done wrong? code says its right but it still doesnt work
Just a quick question, unsure if it makes sense, but… instead of having 0, 1, 2, 3 as the macros you could have spr_player_right, spr_player_up, etc and forego the array altogether by setting face to the macros and sprite index to to face?!
I've watched this video and went through the code a bunch of times, everything works except when i go left and up the sprite keeps flipping back and forth between the correct sprite and the sprite facing the opposite direction when i move. everything in my codes looks exactly the same, i went through it line for line. I cant figure out what i did wrong.
Nevermind I figure it out after like three hours LOL! When I copy and pasted the sprite i only change the first frame in the animation. I had one arrow facing one way and two arrows in the opposite direction so it was animating that when I moved.
what should I do if I want an idle animation to play for each direction while I'm not moving?
When I press the down arrow key, the sprites gets bigger and It shows the animation for the up face. How do I fix
If the sprite gets bigger it sounds like you might be using the image_xscale or image_yscale where you don't need to be. The best advice I can give you for both that and the sprite issue is to double check your code and make sure it 100% matches the video! Good luck!
hey idk if anyone will help me but even tho i did evrything correct whenever i try to test the player movement like in 8:20 i keep getting an error for the "sprite_index" :
Variable .face(100011, -2147483648) not set before reading it.
at gml_Object_obj_player_Step_0 (line 34) - sprite_index = sprite[face];
i did evrything like in the video but cant get past this point, can someone help?
Amazing! *Proud UK man*
Help, I set if xspd && yspd == 0
{
image_index = 0;
}
to stop the animation, but it's still animated :(
EDIT: and when I walk right, it's not animated
For me it was because I forgot to include both '&&' symbols. Instead, I wrote "if xspd & yspd == 0".
@@kilroy7398 thanks but I dont even use gamemaker anymore I use godot now LOL
8:22
nothing special, just saving this, because I'm tired and may go to bed and continue this tomorrow lol
love this series years later!!
hey if you stil read comments the code broke after i put the sprite animations code what should i do. it says the right key stuff is brocken even though it used to work before that. can you help me? PS. and when i remove the stoping animation code it worked again what the heck is going on???
what if some of my directions have smaller and or bigger hitboxes?
How do you change the pixels on the grid to match 16x16 in the project room to place stuff easier?
player direction fix code does not work for me.
im using gamemaker 1, it works aswell if you cant afford :)