How to Code D-Pad Controls for the Sega Genesis & Mega Drive - Beginners Dev Tutorials

  Рет қаралды 3,921

Pigsy's Retro Game Dev Tutorials

Pigsy's Retro Game Dev Tutorials

Күн бұрын

Пікірлер: 55
@PigsysRetroGameDevTutorials
@PigsysRetroGameDevTutorials Жыл бұрын
UPDATE: Please note that SGDK has been updated since this video was created. If you are using a version of SGDK newer than 1.7, then please write "SPR_init();" instead of "SPR_init(0, 0, 0);" and it should compile fine :)
@PigsysRetroGameDevTutorials
@PigsysRetroGameDevTutorials 2 жыл бұрын
Sorry, maybe a little late for "this weekend" for most people (had some stuff come up on Sat and Sun), but it's a big one, so worth spending the next week absorbing the content. If statements, d pad controls, sprite movement, creating functions - lots to digest in this lesson! Hope everyone has had/is having a nice weekend. I'll try and get next week's tutorial up on Saturday morning GMT. Speaking of UK time, it's late here, so time for bed for me. Have fun!
@gameresearch9535
@gameresearch9535 2 жыл бұрын
This is some code I once used many years ago in Game Maker 8.1, no longer use that as I'm working with the Unreal Engine 5. It's very simple code, nothing too unique. Though it worked well for 2D platformer side scrollers. This moves the character, and the direction of the sprites, also animates the sprites movement. ///Movement and direction. //Gravity if (place_free(x,y+1)) { gravity = 0.2; } else { gravity = 0; } //Player image direction - when the player turns. { if keyboard_check_pressed(vk_right) { image_xscale = 1; } if keyboard_check_pressed(vk_left) { image_xscale = -1; } } //Left and Right movement speed. hspeed = (keyboard_check(vk_right)-keyboard_check(vk_left))*3; //If no key pressed or the key was released, idle position and don't move the character. if keyboard_check_released(vk_right) || keyboard_check_released(vk_left) && !place_free(x,y+1) { sprite_index = spr_ellen_ripley_idle; image_speed = 0.5; hspeed = 0; } if keyboard_check_released(vk_down) || keyboard_check_released(vk_up) && !place_free(x,y+1) { hspeed = 0 sprite_index = spr_ellen_ripley_idle; image_speed = 0.5; } //Character run / movement animation. if keyboard_check(vk_right) && !place_free(x,y+1) { sprite_index = spr_ellen_ripley_run image_speed = 0.2 } if keyboard_check(vk_left) && !place_free(x,y+1) { sprite_index = spr_ellen_ripley_run image_speed = 0.2 }
@gameresearch9535
@gameresearch9535 2 жыл бұрын
Here's another for the collisions in Game Maker 8.1, again don't use it anymore since I'm using the Unreal Engine 5. This code goes easily into the player's character every time, just a copy and paste basically. This code helps with character collisions with objects like the floors, walls and ceilings. ///Collisions if (!place_free(x+hspeed,y)) { if (hspeed0){move_contact_solid(0,abs(hspeed));} hspeed=0; } if (!place_free(x,y+vspeed)) { if (vspeed0){move_contact_solid(270,abs(vspeed));} vspeed=0; } if (!place_free(x+hspeed,y+vspeed)) { hspeed=0; }
@gameresearch9535
@gameresearch9535 2 жыл бұрын
I used to have some really simple code for Alien 3 Sega Genesis version elevators, it was like one line of code. Medusa heads also used a similar code in Castlevania: Symphony of the Night as they travel across the screen, you setup some code to say that the player is "facing the other direction, then spawn a medusa head behind him or maybe it was in front of him", and then you use the code that makes them fly across the screen as they do, when they spawn in. Very simple. I have the spittle bones code from way back in 2016 and before that, somewhere in a Game Maker 8.1 project. Remember Alchemy Lab with those spider-like skeletons that rotate around a platform constantly and they spit acid below, or rather they just drop it. Basically it's the same thing as the Metroid and Super Metroid enemies that are little metroids that keep going around and around in the same pattern, on the same path. If you look up any videos on metroid path code, you will see some enemy a.i. on that, it's quite simple. And I have the medusa head code from way back in 2016 also somewhere, maybe later I can find them.
@rustymixer2886
@rustymixer2886 2 жыл бұрын
Thank you sharing your knowledge
@gameresearch9535
@gameresearch9535 2 жыл бұрын
Found the spittle bones code, though this is an old version, I can't find the latest version anywhere that had many of the stages. And so this might be old code or not what I used and not as efficient, though I'm sure it should work. I just tested it on Game Maker 8.1, works. Though if you add a second set of this code, makes it go faster. x1=lengthdir_x(1,dir) y1=lengthdir_y(1,dir) x2=lengthdir_x(1,dir-270) y2=lengthdir_y(1,dir-270) if !place_free(x+x1,y+y1) { if place_free(x+x1-x2,y+y1-y2) { x=x-x2 y=y-y2 } else { dir=dir-90 } } x1=lengthdir_x(1,dir) y1=lengthdir_y(1,dir) x2=lengthdir_x(1,dir-270) y2=lengthdir_y(1,dir-270) x=x+x1 y=y+y1 if place_free(x+x2,y+y2) { if place_free(x+(x2*2),y+(y2*2)) { dir=dir+90 } else { x=x+x2 y=y+y2 } } As for the sprites, set a variable for "bob = 0". And then set bob = 1. If bob = 1 {set the sprite direction, the first sprite with an animation set, the imagine_index to 0, and the imagine speed being the animation speed of the sprite} if bob = 2 {set a second sprite with its animations, and so on} If you have a set of sprites for it to go right, when there is one upside down animation "imagine index", there can be another sprite with another set of animations, which contains for some odd reason.. the "second frame of the upside down imagine", and another that contains the "third frame of the upside down imagine" and so on, and that's for the sprites with right direction or left, each right direction has one upside down frame, one sideways frame, and so on, you tell it "if bob = 1, or if bob = 2" and so on to keep changing to another sprite name like a flipbook in Unreal Engine, each flipbook having that upside down frame within the animation, or one sideways frame within the animation. It's weird but that's how the sprite will animate while turning direction. //Just code by itself. And set the image_index = dir/90 Meaning the direction of the sprite changes 90 degrees each time the object "the enemy" moves a long a platform. Though again it won't animate as it changes unless the steps above are done or there's an easier way with that program, it will instead rotate the sprite to match the direction it's going, without the animation for a left or right spittle bones.
@ThatOldTV
@ThatOldTV 2 жыл бұрын
Thanks!
@PigsysRetroGameDevTutorials
@PigsysRetroGameDevTutorials 2 жыл бұрын
Cheers!
@GimblyGFR
@GimblyGFR 2 жыл бұрын
Thanks for uploading another episode on this series. It was, as usual, very instructive. I've been able to start working on a demo thanks to these tutorials. I really appreciate your work, man.
@PigsysRetroGameDevTutorials
@PigsysRetroGameDevTutorials 2 жыл бұрын
All the best with your demo!
@posthumanistpotato
@posthumanistpotato 2 жыл бұрын
Keep on posting the tutorials! I hope your patreon is growing :D Very excited to try this out.
@PigsysRetroGameDevTutorials
@PigsysRetroGameDevTutorials 2 жыл бұрын
It's growing slowly but surely :) Thanks for the support
@amerikaOnFire
@amerikaOnFire 2 жыл бұрын
Man, seriously, thank you for these. Your explanations are very clear and concise and I LOVE that you show things that could go wrong based on where/when/how you input your code. Knowing some of the quirks or common pitfalls will most likely save any number of us countless hours.
@PigsysRetroGameDevTutorials
@PigsysRetroGameDevTutorials 2 жыл бұрын
I want to get everyone comfortable with making mistakes, as it is actually a great way to learn.
@ogsegasteve9430
@ogsegasteve9430 2 жыл бұрын
Pigsy...Baby...get on Twitter so we can tag you and draw more attention to the amazing work you do whilst giving you credit! "Le #MegaGen est mort. Vive le MegaGen!"
@PigsysRetroGameDevTutorials
@PigsysRetroGameDevTutorials 2 жыл бұрын
Any promotion you can give on there would be much appreciated :) I fear a twitter account would suck away too much of my time, and I don't have much of that to spare these days!
@juanjesusligero391
@juanjesusligero391 2 жыл бұрын
@@PigsysRetroGameDevTutorials You could just post tweets with links to your videos every time you release a new one (that's like 2 extra seconds per video XD) and not use it in any other way. Just put on your twitter bio a link to this KZbin channel, and everything should work just fine! :)
@PigsysRetroGameDevTutorials
@PigsysRetroGameDevTutorials 2 жыл бұрын
@@juanjesusligero391 Maybe something like that won't take up too much time. We'll see.
@solidsnake5712
@solidsnake5712 Жыл бұрын
Nice tutorial, I used some booleans variables to check whether the player is moving and if he is facing right to control walk animation and flip direction.
@PigsysRetroGameDevTutorials
@PigsysRetroGameDevTutorials Жыл бұрын
Nice one, that's the way to do it!
@Genesis814
@Genesis814 2 жыл бұрын
Great, Pigsy. Thank you for your contributions to the community.
@ThatOldTV
@ThatOldTV 2 жыл бұрын
I'm so happy! I couldn't wait for this episode!
@ThatOldTV
@ThatOldTV 2 жыл бұрын
Is that Sword of Vermillion I hear in the background?
@PigsysRetroGameDevTutorials
@PigsysRetroGameDevTutorials 2 жыл бұрын
@@ThatOldTV Yes! Incredible soundtrack. I actually played the game fairly recently on my MD mini - while it's a little janky in parts, the gameloop if still very addictive and fun.
@ThatOldTV
@ThatOldTV 2 жыл бұрын
@@PigsysRetroGameDevTutorials I purchased and played Sword of Vermillion the day it came out on shelves. I only played through it that one time 30 years ago but... the musical score was so good, it's still with me to this day. In your next episode, mapping buttons, will you show us how to jump? I got the mechanic to kind of work but I prefer your code as you explain it. I've found many tutorials but more often then not, I have to use google translate. Also, I was able to make my sprite fire her weapon but... It's in a 96 x 96 box; like you did with Alucard swinging his sword. Will we have a future tutorial to show us firing a weapon across the screen and picking up powerups.
@PigsysRetroGameDevTutorials
@PigsysRetroGameDevTutorials 2 жыл бұрын
@@ThatOldTV I will cover a lot of that in the first little tutorial project once this basic series is over - the Shinobi surfing re-creation (some things are better learnt in the context of a game rather than peicemeal)
@ThatOldTV
@ThatOldTV 2 жыл бұрын
@@PigsysRetroGameDevTutorials I sent an email asking a question about the morphball. If the question is too much. I get it. You don't need to answer it. Time is at a premium. Maybe you can do a Q&A's and answers tutorial at the end of all your videos.
@retrocompatibilidade8960
@retrocompatibilidade8960 2 жыл бұрын
Great job my friend 👏👏👏👏👏👏👏😉👍.
@PigsysRetroGameDevTutorials
@PigsysRetroGameDevTutorials 2 жыл бұрын
Thanks
@stuhl232
@stuhl232 Жыл бұрын
I am thoroughly enjoying this series! Thank you and well done! Is there a lesson #13 coming soon? Even something with a lot of code snippets to experiment with or a video on where to find other resources would be great!
@PigsysRetroGameDevTutorials
@PigsysRetroGameDevTutorials Жыл бұрын
I've been working on SotN stuff recently, but the tutorials will continue soon :)
@nikolaus8115
@nikolaus8115 Жыл бұрын
Thanks again for the tutorial
@SeanOfEarth
@SeanOfEarth 2 ай бұрын
Thanks
@PigsysRetroGameDevTutorials
@PigsysRetroGameDevTutorials 2 ай бұрын
Thanks!
@GreyMatterShades
@GreyMatterShades 2 жыл бұрын
Thanks a bunch for these tutorials! I haven't actually started a project yet, but these videos are making it feel very possible. I'm just curious, could you handle the idle animation trigger more easily/cleanly with an 'else' statement at the end of all the 'if' and 'else if' statements, or would that just apply to the second 'if' statement?
@PigsysRetroGameDevTutorials
@PigsysRetroGameDevTutorials 2 жыл бұрын
It would just apply to the second if/else chain ("else" will be featured in my next lesson though)
@GreyMatterShades
@GreyMatterShades 2 жыл бұрын
@@PigsysRetroGameDevTutorials Thanks for the answer. Watched and enjoyed the next lesson as well. The part about "else" statements helped clear up my confusion.
@PigsysRetroGameDevTutorials
@PigsysRetroGameDevTutorials 2 жыл бұрын
@@GreyMatterShades Glad to hear it!
@Poprock6108
@Poprock6108 6 ай бұрын
tengo un sprite de 32x32 con tres para la animación,una vez que empieza andar da como un salto ,nose a que es debido
@brunch1572
@brunch1572 2 жыл бұрын
Really great video, Pigsy. Question for you. I would actually prefer to use the Fusion emulator and was wondering how you got it to work with VSCode/Genesis Code. I changed the "Set Gens Emulator Command Path" to be the path to my Fusion instead of the path to Gens, and it does indeed open Fusion, but does not load the rom, only showing the static startup screen and not displaying the game name across the header. Thanks.
@di4352
@di4352 2 жыл бұрын
Fusion may not be a working alternative? Maybe it's because the Gens emulator has already been setup by the VSCode/Genesis Code plugin to be a working emu? Could Fusion require more setup? It could be as simple as that. Maybe Fusion is not a working alternative to Gens in this case.
@brunch1572
@brunch1572 2 жыл бұрын
@@di4352 He uses it successfully in the video. That's why I'm asking how he did it. I do suspect there is more setup, maybe one step I am missing or something.
@PigsysRetroGameDevTutorials
@PigsysRetroGameDevTutorials 2 жыл бұрын
I explain it more in my next tutorial, but Fusion isn't integrated into Visual Studio Code, I just keep it open and open the roms manually
@jonathanharding5103
@jonathanharding5103 2 жыл бұрын
Is there a reason for using if statements instead of cases?
@PigsysRetroGameDevTutorials
@PigsysRetroGameDevTutorials 2 жыл бұрын
For simple menus cases might be more clear, but for anything more complex I prefer if statements. Feel free to use whatever works for you though
@WilliamSomeguy
@WilliamSomeguy Жыл бұрын
A bit too late but... switch case statements are meant to check for equalities (ie.: is x = 1? is x = 2? is x = 3?...). But in this case you're applying & (bitwise and) operation to value, not just checking the equality (against 0) so you really need to use ifs. NOTE: Switch cases go along great with enums
@TheNomcognom
@TheNomcognom 7 ай бұрын
@PigsysRetroGameDevTutorials is not enough if (!value) {...} to test that no button is pressed?
@NoSpamForYou
@NoSpamForYou 5 ай бұрын
How does 'value' change when dpad is released? I assume it has to loop since it is a variable and not a register.Does Could you just test against Joy_readJoypad at the end of the handleInput function to see if anything is pressed instead of testing every direction at once using &&? I know the buttons have to be accounted for too before going into idle animation so maybe it needs refined more or not feasible. Just a thought wondering if we can get away from several comparisons and save some cycles? Or is polling Joypad slower than doing all those compares?
How to Code Level Collision for 2D Games (Sega Genesis & Mega Drive) - Beginners Game Dev Tutorials
1:12:38
How to Create Palette Cycle Animations for Sega Genesis & Mega Drive - Beginner Game Dev Tutorials
14:42
Brawl Stars Edit😈📕
00:15
Kan Andrey
Рет қаралды 50 МЛН
OYUNCAK MİKROFON İLE TRAFİK LAMBASINI DEĞİŞTİRDİ 😱
00:17
Melih Taşçı
Рет қаралды 11 МЛН
Xeno Crisis review - Segadrunk
6:00
SNES drunk
Рет қаралды 91 М.
How to Create Music for the Sega Genesis & Mega Drive - Beginner Game Dev Tutorials
8:53
Pigsy's Retro Game Dev Tutorials
Рет қаралды 2,8 М.
Swift Programming Tutorial for Beginners (Full Tutorial)
3:22:45
CodeWithChris
Рет қаралды 7 МЛН
How to Create Coloured Transparencies for Sega Genesis & Mega Drive - Beginner Game Dev Tutorials
12:25
NixOS Setup Guide - Configuration / Home-Manager / Flakes
3:01:39
Matthias Benaets
Рет қаралды 187 М.
Summer / Autumn Update 2024 - Castlevania: SotN for Sega Mega Drive & Genesis - Dev Diary 27
12:25
Harder Drive: Hard drives we didn't want or need
36:47
suckerpinch
Рет қаралды 1,7 МЛН
How to Create Complex Level Maps With Aseprite v1.3 - Beginner Game Dev Tutorials
29:38
Pigsy's Retro Game Dev Tutorials
Рет қаралды 2,6 М.
Intro to Tool Dev in Unity - An Improvised Live Course [part 1/4]
3:39:31
Brawl Stars Edit😈📕
00:15
Kan Andrey
Рет қаралды 50 МЛН