Do you know how to program a level to automatically scroll? I know how to program it to scroll with the player...But I've been bashing my brain trying to figure out how to make it scroll automatically.
Well, think about this then-- you have the camera's x value set at the player's x value minus half the screen width, right? So, instead of making the camera's x value dependent on the player's x value, make it an integer that automatically increments by, say, 1 pixel for every game loop. Then the camera would automatically scroll to the right.
Building the map was simply a matter of reading a two dimensional array of integer values. 0 stood for nothing, 1 stood for a solid block, 2 stood for a checkpoint, 3 for coin, 4 for badguy1, etc etc... I had a loadlevel function that had a loop that went through the level array, placing new objects for every nonzero value in the array at 32 pixel intervals. There were two loops nested in each other, one for the x values of the array, and one for the y values... Hope this helps!
@noobgy One way you could go about shooting multiple bullets, is by using a linked list to store the bullet objects. Every time you fire a shot, you create a bullet object and add it to the linked list. When a shot hits, or a bullet is otherwise removed from the game, you remove that bullet from the list, and redirect the pointers (just like removing a typical node from a linkedlist).
Not sure about the efficiency of this, but its the best i can come up with in 30 seconds xD
Could you please tel me how to code that multiple scrolling layers background. I'm trying to find one tutorial about this topic but i feel defeated, a can't find anything usefull. Can you help me please
hey man!, i'm studing programation but io can't wait to learn this from the teachers, can i see the program of this?, i want to do something similar one day!
Does allegro make sure the game is clocked at 30 FPS?
For example, let's say you just kept setting an x-coordinate of an object to +1 every step of your loop, and then you simply draw him on the screen using allegro's draw/blit functions. How big of a chance will there be for the player to lag at certain times? Are there any optimisations you have to do with that x-coordinate to make sure it syncs with your 30 FPS? Or would you just do x+=1 and Allegro does all of that stuff for you?
No, Allegro doesn't, not version 4.2 anyway (the version I was using; Haven't used it since then-- they are past version 5 now). But you have multiple options to limit the frame rate-- I used pthreads (an easy to implement timer system) to limit my game to 60fps and to prevent the computer from wasting cpu time waiting for a screen refresh :D Another option is to call vsync() before each draw to the screen-- however not everyone's monitor refresh rate is the same!
Camera is implemented by storing an x and y integer. These are the camera coordinates; At all times they focus on the player by getting the player's x and y and subtracting half of the screen width and screen height. Now, when you draw tiles, the player, and enemies, you need to draw everything relative to the camera-- when drawing, simply subtract from the sprite coordinates the camera x value and the camera y value from the respective coordinate x and y values.
The parallax background is too difficult to explain on a youtube comment, sorry. To draw a stationary background, before drawing everything else, simply draw the background image to coordinate 0, 0 on the screen.
@Falciase tru tru, well nice game anyways :D. I'm working on other projects right now but I'll be making a side scroller soon so I'll let you know when I start that. And who knows, maybe we can make a game together in the future, if you're willing to of course but yea it would be pretty nice to work with you :)
How did you do collision on the x axis? I'm using a 2d array for my map and have successful y collision with whether or not gravity is affecting the sprite, but I don't know what to do if the sprite successfully collides on the side of my tiles.
Well, when your character is moving left or right, before you actually move him (xLocation - xSpeed for moving left and xLocation + xSpeed for moving right) you first need to make sure that spot is actually unoccupied by a solid object! So before you move your character, for example when moving right, do something like this:
if(noSolidObjectAtXY(xLocation + xSpeed, y)
then(xLocation = xLocation + xSpeed)
You just need to write a func. that checks if map is free at an X, Y location.
To make your character jump, all you have to do is, for example, when you are pressing the spacebar key, SUBTRACT a constant jump force variable, like 4 from your character. This force will be greater than the gravity and propel your character upwards. Now, you just need to limit how long the player can hold down the spacebar key, so as to limit them from jumping infinitely high!
Basic idea is this: at all times, gravity is pulling your character down, unless there is a solid obstacle beneath your hero's feet. If there is not a solid object beneath your character's feet, add a global gravity constant (for instance, .15) to your character's y speed. Do this every step that your character is in the air, until he hits solid ground again. This will be the constant gravity pulling on your character.
@swagbucksmaster360 if you want to have a jump function using only x and y variable just do it using a negative quadratic funcion and that will give you the motion
Amazing job, love sound effects, sprites ,and gameplay looks quite fun! I never used allegro before always used SDL :P wish i were as good as u, u can check out my SDL games on my youtube channel but nothign too complicated like yours :P
Also it's a lot of nostalgia to hear all the Zelda sounds :D
I am a professional programmer but so far games has not been on my resume, currently trying to find all the info I can about stuff like allegro, sdl, open gl, direct x, what they are, benefits and downsides, how to combine them, it's hard even for an experienced developer so once again bravo to you
You inspire me. just because of this video i went off and bought a book on allegro. awesome.do you mind if i use megaman sprites in my game too? i dont want to copy you :D
hahah dude that's fine. in fact, if you go to my website (listed on my channel) you can download this game, and all the game graphics are in there. but yeah, megaman is awesome, you should use megaman sprites :D
Just curious- I noticed that the "bullet" from the enemy disappears into thin air right when the enemy dies, regardless of it hitting you. Is this because you combined the alive status of the bullet with that of the enemy? Did you combine their bool values?
Yes, in retrospect, the way I handled bullets was terrible. I tied bullets to their owner, so when the owner no longer existed (bool alive = 0), neither did their bullet! Oh well. Won't make that mistake again :)
Yeh I was making a pong game and I noticed that my ball would stop moving as soon as game was over (bool gameover = true). So I just moved the ball code out of the "if (bool gameover=true)" conditional statement and voila ball continues to bounce.
@ison011 The background is two bitmaps that are each as large as the resolution of the game, 640x480. Each background is blitted 4 times to tile seamlessly and scrolled depending on the camera's x. Ultimately the only thing blitted is as big as the screen resolution, so no efficiency is lost.
Thanks for the complement! Check out my website to check out the new platforming game I'm working on :]
I used mappy tilemap editor, which exports an array of numbers, which I can put into the game easily. I only made 3 levels, but they only take like 5-10 minutes to make :D
About 5 header files and 1 main file. Animation was set up by looping through a frame number to a max number every couple of steps. Depending on what the player was doing [jumping, walking, climbing up ladder, etc] it displayed the corresponding bitmap.
About half a year of messing around with Allegro. Before this game I made a text adventure, a 4 player warlords (similar to breakout) game, and a 3 player buster bros. game.
This is pretty cool! Im just starting with allegro (i've been trying to make C++ games for almost 4 months and just found out about allegro so im really happy =D). I was wondering how you designed the whole map, is it an extremely large image, or all designed in the coding? I just figure out how to design something like that...
You need to make a class of blocks, which is what I did. It is not one large image-- I've seen people do that, and it's terribly inefficient. Don't do that, as it is a terrible way to code a game. Make a class of obstacles, and then you just arrange the blocks how you want them in the level.
Hmm, you could do a 2d array, however I just use a one dimensional array and tell the thing when the next row begins-- ie, every 50 blocks (for a 50 block wide level). 2d array would probably be easier, honestly, but they both work!
I have a few questions. Why does the pirate shoot jelly beans and why are the enemies megaman when your on "dinosaur" island. But overall it's very nice.
Both the jelly beans and all of the enemies being Megaman-- that was all cause I didn't have any art to put there. This was a class project, and the artists that were supposed to design the art of my game provided nothing but the main character sprites-- so I just went on the internet and grabbed a few Megaman sprites for my enemies :P The jellybean thing-- I really just made it neon colors so as to demonstrate that it was, in fact, animated, rather than a still image for the bullet.
Also-- I took great care to make this game as efficient as I knew how to at the time I made it... as a result, this game runs very nicely with any PC with a 500mhz processor, and 10mb of RAM :P maybe even a slower processor could work, but I have yet to test it on a slower computer than that :P
Objects stay in the same location, but when drawing the objects, draw them relative to a scroll_x and scroll_y variable. For anything that draws to the buffer, draw it to x-scroll_x and y-scroll_y and voila! Scrolling :D
This looks great, how did you ever make such a nice game only 2 months into C++?
SecretTechniqueGuy 1 week ago
MAN!!! actually the game seems pretty fun lol! so, have you ever used sdl? do you like allegro more than sdl?
Maxguitarrista 1 month ago
nice game thats very impressive
how long have you been learning c++?
JakobRobert00 1 month ago
@JakobRobert00
At the point that I made this game, I was probably about two months in.
Falciase 1 month ago
@Falciase wow thats amazing
JakobRobert00 1 month ago
Do you know how to program a level to automatically scroll? I know how to program it to scroll with the player...But I've been bashing my brain trying to figure out how to make it scroll automatically.
adamrothraisdead 2 months ago
@adamrothraisdead
Well, think about this then-- you have the camera's x value set at the player's x value minus half the screen width, right? So, instead of making the camera's x value dependent on the player's x value, make it an integer that automatically increments by, say, 1 pixel for every game loop. Then the camera would automatically scroll to the right.
Falciase 2 months ago
@Falciase This is where I facepalm and wonder how I didn't figure that out myself. Thanks.
adamrothraisdead 2 months ago
what libraries and file types did you use for the map handling? unless you hard coded each tile?
TotalJargon 2 months ago
@TotalJargon
Building the map was simply a matter of reading a two dimensional array of integer values. 0 stood for nothing, 1 stood for a solid block, 2 stood for a checkpoint, 3 for coin, 4 for badguy1, etc etc... I had a loadlevel function that had a loop that went through the level array, placing new objects for every nonzero value in the array at 32 pixel intervals. There were two loops nested in each other, one for the x values of the array, and one for the y values... Hope this helps!
Falciase 2 months ago
arte!, esto es arte!
Tortoiseius 4 months ago
@Tortoiseius Muchas gracias, amigo!!
Falciase 4 months ago
When I was recording this video, at 2:30 I quite literally facepalmed.
Falciase 5 months ago
the game looks quite nice....can i download this in open source ?
noobgy 7 months ago
can u teach me how to shoot multiple bullets ??
noobgy 7 months ago
@noobgy One way you could go about shooting multiple bullets, is by using a linked list to store the bullet objects. Every time you fire a shot, you create a bullet object and add it to the linked list. When a shot hits, or a bullet is otherwise removed from the game, you remove that bullet from the list, and redirect the pointers (just like removing a typical node from a linkedlist).
Not sure about the efficiency of this, but its the best i can come up with in 30 seconds xD
WoWrowrin 7 months ago
@noobgy I use a vector that dynamically adds a bullet object each time one is shot and dynamically removes it when it hits.
adamrothraisdead 2 months ago
@Gigon12 go to my website on my channel's description and click on the 'old projects' section of the website to download!
Falciase 7 months ago
are those sound effects from zelda a link to the past
AndrewH1998 7 months ago
@AndrewH1998 Yep! Read the description!
Falciase 7 months ago
Could you please tel me how to code that multiple scrolling layers background. I'm trying to find one tutorial about this topic but i feel defeated, a can't find anything usefull. Can you help me please
dvarelae858 8 months ago
hey man!, i'm studing programation but io can't wait to learn this from the teachers, can i see the program of this?, i want to do something similar one day!
roloxhellbringer 8 months ago
Does allegro make sure the game is clocked at 30 FPS?
For example, let's say you just kept setting an x-coordinate of an object to +1 every step of your loop, and then you simply draw him on the screen using allegro's draw/blit functions. How big of a chance will there be for the player to lag at certain times? Are there any optimisations you have to do with that x-coordinate to make sure it syncs with your 30 FPS? Or would you just do x+=1 and Allegro does all of that stuff for you?
heymangone 9 months ago
@heymangone
No, Allegro doesn't, not version 4.2 anyway (the version I was using; Haven't used it since then-- they are past version 5 now). But you have multiple options to limit the frame rate-- I used pthreads (an easy to implement timer system) to limit my game to 60fps and to prevent the computer from wasting cpu time waiting for a screen refresh :D Another option is to call vsync() before each draw to the screen-- however not everyone's monitor refresh rate is the same!
Falciase 9 months ago
how did you implement the background and the camera?
MrBlenderMan 9 months ago
@MrBlenderMan
Camera is implemented by storing an x and y integer. These are the camera coordinates; At all times they focus on the player by getting the player's x and y and subtracting half of the screen width and screen height. Now, when you draw tiles, the player, and enemies, you need to draw everything relative to the camera-- when drawing, simply subtract from the sprite coordinates the camera x value and the camera y value from the respective coordinate x and y values.
Falciase 9 months ago
@MrBlenderMan
The parallax background is too difficult to explain on a youtube comment, sorry. To draw a stationary background, before drawing everything else, simply draw the background image to coordinate 0, 0 on the screen.
Falciase 9 months ago
this looks fun good job!
6am3r1 10 months ago
@6am3r1
Thanks!!
Falciase 9 months ago
nice game :o
tortorios 10 months ago
thumbs up if u think red guy is on crack
71619997a 10 months ago
pretty cool game . How many years of experience do you have with c++?
CodingMadeEasy 11 months ago
@CodingMadeEasy Probably about 3 years!
Falciase 11 months ago
@Falciase tru tru, well nice game anyways :D. I'm working on other projects right now but I'll be making a side scroller soon so I'll let you know when I start that. And who knows, maybe we can make a game together in the future, if you're willing to of course but yea it would be pretty nice to work with you :)
CodingMadeEasy 11 months ago
you are the fucking shit man !!!! Congrats !!
wildchild15381 1 year ago
Allegro is awesome, it's simple and easy to use, yet very powerfull for 2d games.
Thebrujo1986 1 year ago
are u killing mega man? lol
sk8rboi7566 1 year ago
Where can I download this?
davidgreen1020 1 year ago
@davidgreen1020
go to the website listed on my channel and click on the 'old projects' link to download it! youtube won't let me put the link to the website here.
Falciase 1 year ago
How did you do collision on the x axis? I'm using a 2d array for my map and have successful y collision with whether or not gravity is affecting the sprite, but I don't know what to do if the sprite successfully collides on the side of my tiles.
TheTntuser 1 year ago
@TheTntuser
Well, when your character is moving left or right, before you actually move him (xLocation - xSpeed for moving left and xLocation + xSpeed for moving right) you first need to make sure that spot is actually unoccupied by a solid object! So before you move your character, for example when moving right, do something like this:
if(noSolidObjectAtXY(xLocation + xSpeed, y)
then(xLocation = xLocation + xSpeed)
You just need to write a func. that checks if map is free at an X, Y location.
Falciase 1 year ago
SO,so fkn cool. 15 years ago, this game would heve been a huge success:))
DoiMango 1 year ago
@Falciase
To make your character jump, all you have to do is, for example, when you are pressing the spacebar key, SUBTRACT a constant jump force variable, like 4 from your character. This force will be greater than the gravity and propel your character upwards. Now, you just need to limit how long the player can hold down the spacebar key, so as to limit them from jumping infinitely high!
Hope this helps.
Falciase 1 year ago
@Falciase Thanks for such a quick reply! This is very helpful...i'll use some sort of timer function to do this... whatever works in darkGDK
swagbucksmaster360 1 year ago
Can you give me a basic idea of how you made your character jump? I have a problem doing this in my games.
swagbucksmaster360 1 year ago
@swagbucksmaster360
Basic idea is this: at all times, gravity is pulling your character down, unless there is a solid obstacle beneath your hero's feet. If there is not a solid object beneath your character's feet, add a global gravity constant (for instance, .15) to your character's y speed. Do this every step that your character is in the air, until he hits solid ground again. This will be the constant gravity pulling on your character.
Falciase 1 year ago
@swagbucksmaster360 if you want to have a jump function using only x and y variable just do it using a negative quadratic funcion and that will give you the motion
frizba 1 year ago
Thumbs up.
sava1811 1 year ago
looks fun, nice work, good level design.
mengu1988 1 year ago
Amazing job, love sound effects, sprites ,and gameplay looks quite fun! I never used allegro before always used SDL :P wish i were as good as u, u can check out my SDL games on my youtube channel but nothign too complicated like yours :P
YouKondziu 1 year ago
This is a VERY cool game... bravo!
Also it's a lot of nostalgia to hear all the Zelda sounds :D
I am a professional programmer but so far games has not been on my resume, currently trying to find all the info I can about stuff like allegro, sdl, open gl, direct x, what they are, benefits and downsides, how to combine them, it's hard even for an experienced developer so once again bravo to you
d77sweden 1 year ago
You inspire me. just because of this video i went off and bought a book on allegro. awesome.do you mind if i use megaman sprites in my game too? i dont want to copy you :D
MrDuskling 1 year ago
@MrDuskling
hahah dude that's fine. in fact, if you go to my website (listed on my channel) you can download this game, and all the game graphics are in there. but yeah, megaman is awesome, you should use megaman sprites :D
Falciase 1 year ago
You inspire me. just because of this video i went off and bought a book on allegro. awesome.
MrDuskling 1 year ago
Just curious- I noticed that the "bullet" from the enemy disappears into thin air right when the enemy dies, regardless of it hitting you. Is this because you combined the alive status of the bullet with that of the enemy? Did you combine their bool values?
thank you and great job! keep it up!
tallthunder 1 year ago
@tallthunder
Yes, in retrospect, the way I handled bullets was terrible. I tied bullets to their owner, so when the owner no longer existed (bool alive = 0), neither did their bullet! Oh well. Won't make that mistake again :)
Falciase 1 year ago
@Falciase
Yeh I was making a pong game and I noticed that my ball would stop moving as soon as game was over (bool gameover = true). So I just moved the ball code out of the "if (bool gameover=true)" conditional statement and voila ball continues to bounce.
Great job :)
tallthunder 1 year ago
How long have you been working on programming games?
MrZekrot 1 year ago
@MrZekrot about two years now, if you don't count the stuff I made in GameMaker, hahah.
Falciase 1 year ago
@Falciase Ok :P
MrZekrot 1 year ago
@Falciase I don't count the stuff I made in Game Maker either.
atre89 1 year ago
Wow this is so awesome. :D
xAustechx 1 year ago
alot of zelda SFX :-/
thowedthanka 1 year ago
@thowedthanka
Who doesn't like Zelda SFX?? :P
Falciase 1 year ago
@thevlogginggamer
It's not just you, the guy that did the main character's graphics for me changed up Megaman's sprites from the NES games into a pirate, hahah.
Falciase 1 year ago
@Falciase AWESOME!
MrDuskling 1 year ago
Can you release the source code? Thanks
sheepkilier 1 year ago
@sheepkilier
Sorry, not anytime soon. Perhaps in a year or two, when I'm finished with my current project.
Falciase 1 year ago
The game is awesome! I just think you should spread the invincibility power ups apart.
Boskinoskin 1 year ago
could you send me background sprites please? :)
ison011 1 year ago
@ison011
Go to my website listed on my channel page and download the game and it has backgrounds in the gfx folder :)
Falciase 1 year ago
@ison011
Go to my website listed on my Youtube channel and download the game. It has background graphics in the 'gfx' folder :)
Falciase 1 year ago
really cool game. How did u set up background? is it one huge bitmap?
ison011 1 year ago
@ison011 The background is two bitmaps that are each as large as the resolution of the game, 640x480. Each background is blitted 4 times to tile seamlessly and scrolled depending on the camera's x. Ultimately the only thing blitted is as big as the screen resolution, so no efficiency is lost.
Falciase 1 year ago
good game man
Nitros8891 1 year ago
really amazing work in just 4 weeks =]
did you make a level editor ? =D or did you specify the level design from inside of the code? =]
mody1710 2 years ago
Thanks for the complement! Check out my website to check out the new platforming game I'm working on :]
I used mappy tilemap editor, which exports an array of numbers, which I can put into the game easily. I only made 3 levels, but they only take like 5-10 minutes to make :D
Falciase 2 years ago
Nice man, how many files did it take to code this, also wondering, how did you set up the animation?
Donutslayer7 2 years ago
About 5 header files and 1 main file. Animation was set up by looping through a frame number to a max number every couple of steps. Depending on what the player was doing [jumping, walking, climbing up ladder, etc] it displayed the corresponding bitmap.
Falciase 2 years ago
About how long of learning C++ did it take you to be able to make this game?
Conker303 2 years ago
About half a year of messing around with Allegro. Before this game I made a text adventure, a 4 player warlords (similar to breakout) game, and a 3 player buster bros. game.
Falciase 2 years ago
This is pretty cool! Im just starting with allegro (i've been trying to make C++ games for almost 4 months and just found out about allegro so im really happy =D). I was wondering how you designed the whole map, is it an extremely large image, or all designed in the coding? I just figure out how to design something like that...
Rman159Productions 2 years ago
You need to make a class of blocks, which is what I did. It is not one large image-- I've seen people do that, and it's terribly inefficient. Don't do that, as it is a terrible way to code a game. Make a class of obstacles, and then you just arrange the blocks how you want them in the level.
Falciase 2 years ago
but did you do it in a matrix / 2d array? or did you do it some other way?
Rman159Productions 2 years ago
It is in a single dimensional array of numbers. The numbers signify what each spot should be, such as a block, an enemy, a powerup, or empty space.
Falciase 2 years ago
@Falciase
but that would only be one row in the game wouldn't it? how do you have multiple rows of stuff if its only a single dimensional array?
Rman159Productions 2 years ago
Hmm, you could do a 2d array, however I just use a one dimensional array and tell the thing when the next row begins-- ie, every 50 blocks (for a 50 block wide level). 2d array would probably be easier, honestly, but they both work!
Falciase 2 years ago
I have a few questions. Why does the pirate shoot jelly beans and why are the enemies megaman when your on "dinosaur" island. But overall it's very nice.
Conker303 2 years ago
Both the jelly beans and all of the enemies being Megaman-- that was all cause I didn't have any art to put there. This was a class project, and the artists that were supposed to design the art of my game provided nothing but the main character sprites-- so I just went on the internet and grabbed a few Megaman sprites for my enemies :P The jellybean thing-- I really just made it neon colors so as to demonstrate that it was, in fact, animated, rather than a still image for the bullet.
Falciase 2 years ago
Also-- I took great care to make this game as efficient as I knew how to at the time I made it... as a result, this game runs very nicely with any PC with a 500mhz processor, and 10mb of RAM :P maybe even a slower processor could work, but I have yet to test it on a slower computer than that :P
Falciase 2 years ago
Nice :) how you made map scrooling and its collision?
Neomex000 2 years ago
You is moving all object or just camera(but it is impossibile in allegro i think)
Neomex000 2 years ago
Objects stay in the same location, but when drawing the objects, draw them relative to a scroll_x and scroll_y variable. For anything that draws to the buffer, draw it to x-scroll_x and y-scroll_y and voila! Scrolling :D
Falciase 2 years ago
the only thing i don't like is that when you kill an enemy his missles or weapons disapear right when you kill him
but other then that good job, looks fun :D
cafiremage2 2 years ago
Thanks! :D
Falciase 2 years ago