Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / 2d platformer-I need help

Author
Message
Azn QT97
13
Years of Service
User Offline
Joined: 24th Mar 2011
Location:
Posted: 24th Mar 2011 19:31
I'm stuck, I decided to make a video game for my senoir project but I suck at programming. My group wants to make a simple platformer with one level. Can somone give me a simple code in which I can edit a 2d platformer, using data to change the map, as well as a simple character that i can change later. Can you use the rem to explain in detail what things do so I can better understand and not have to ask for help like this again its embarrasing. D:

Im such a nerd :3
<(^_^)> kirby <3
DeadTomGC
13
Years of Service
User Offline
Joined: 11th Aug 2010
Location: LU
Posted: 25th Mar 2011 05:26
Here is the link to the platformer demo I made. It can generate a variable number (200 by default) of blocks in random y locations between 100 and 300. It scrolls and has full collision with these blocks. Almost all the code is in the header. So, you will be able to add it to your own main rather easily, or you could modify the given main.

http://forum.thegamecreators.com/?m=forum_view&t=182892&b=22&msg=2179754#m2179754

You need to know about arrays (not optional) and some short hand methods( the use is optional, but it is in the code).
ie,
i+=1;==>i=i+1;
i++;==>i=i+1;

Let me know if you have any questions.

Also, here is the codebase entry:http://www.thegamecreators.com/?m=codebase_view&i=11a532fa1b1f75a010c980b8fababe41

Oh, and why is this "embarrassing"? I've given this code to 4 other people already. This is what the forums are for, I think...

Hmm, maybe I shouldn't help you so much with this project...
Oh, whatever!

Azn QT97
13
Years of Service
User Offline
Joined: 24th Mar 2011
Location:
Posted: 25th Mar 2011 19:03
I have a week to finish this project, is this possible? Also thank you so much for the help, and anything else you can add is tremendously helpful. Again thank you.

Im such a nerd :3
<(^_^)> kirby <3
Azn QT97
13
Years of Service
User Offline
Joined: 24th Mar 2011
Location:
Posted: 25th Mar 2011 19:10
The above post is very helpful, and gives me a place to start, but I am still very new to coding, any beginner tutorials will be tremendously helpful. I need to be able to have some sort of produc within the next week or so, regarding a 2d platformer, even if I cant create a final product I still need something to present. Again thanks to deadtom your a boss. And thanks to anybody who is willing to help me.

Im such a nerd :3
<(^_^)> kirby <3
Azn QT97
13
Years of Service
User Offline
Joined: 24th Mar 2011
Location:
Posted: 25th Mar 2011 19:47
good sir, I have just realised that your code is C++ does that work if I am coding in DBpro?

Im such a nerd :3
<(^_^)> kirby <3
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 25th Mar 2011 23:25
Unfortunately it isn't compatable with DBPro, in order to run his code you will have to install the DarkGDK which includes installing visual c++ and the directx sdk. TGC has a video on how to install the DarkGDK from scratch.

A clever person solves a problem, a wise person avoids it - Albert Einstein
DeadTomGC
13
Years of Service
User Offline
Joined: 11th Aug 2010
Location: LU
Posted: 25th Mar 2011 23:55
Ya, I was going to ask you about that, but now I know.
I know some basic and could probably learn what I don't know and need to very easily. Then, I could translate this code into basic.
However, Realizing that you have deadlines It may be better for somebody who is more fluent in both languages to work on this.

I will work on it, but Anyone who can help translate the code on the second post, please assist!

Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 26th Mar 2011 03:30 Edited at: 26th Mar 2011 03:31
Ok, took a couple of hours but I managed to write up a small demonstration of a platformer style game. Don't laugh, its the first time I've programmed a platformer. I've attached it so all you need to do is download it, unzip it and run the exe.

Oh yeah, don't worry about the numbers on the top left of the screen, they were for debugging.

A clever person solves a problem, a wise person avoids it - Albert Einstein

Attachments

Login to view attachments
Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 26th Mar 2011 08:06
Hodgey, I'm not laughing, very nice, actually, for first time. I like the last platform. There is only one way you can get on top of it. I've been wanting to create a platform game and this will help to get me started along with a couple of books I have.


Terry
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 27th Mar 2011 03:01 Edited at: 27th Mar 2011 04:20
Thanks Flatlander, you can laugh if you want, I laughed .

Quote: "I like the last platform. There is only one way you can get on top of it."

I actually didn't arrange for that to happen. When I gave the platforms their x and y values all I was interested in was to not have any of them touching (that would look a bit weird) and got it right first go. Glad you like it. I hope it does help you to design a platformer and I'll be eager to see and play it.

@ Azn QT97 - I hope this helps you to design your platformer and feel free to use the sprites, no acknowledgement needed.

Edit Okay, I couldn't help myself. I've added more platforms and made the character run a bit faster. Enjoy.

A clever person solves a problem, a wise person avoids it - Albert Einstein

Attachments

Login to view attachments
Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 28th Mar 2011 04:14
Quote: "Okay, I couldn't help myself."


That's funny. It's just like me when I start something even if it is a test, sample or example. I start adding to it. When I first learned DBPro, I created a simple break out game. It was just for learning but then I created a full game out of it with three levels, power-ups, the ability to save high scores and a help menu. You may end up making a platform game yourself.


Terry
Azn QT97
13
Years of Service
User Offline
Joined: 24th Mar 2011
Location:
Posted: 31st Mar 2011 20:31
@hodgey

Ok, so I used your code, and modified it and I am using it as a learning tool in which I can edit my own code, however when i try to set a background it wont let me.

Im am using this code

load image "myimage.bmp",4

paste image 4,0,0

but instead of becoming a background, it simpley merges with the platforms and makes a bunch of uneeded platforms. How can I get around this? Also I want to add some coins or something that you can grab. How can I do this as well?

Im such a nerd :3
<(^_^)> kirby <3
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 1st Apr 2011 06:54
Check that the image number your using, in this case 4, isn't being used elseware. Since my demo uses 4 images, I have already taken up the image numbers 1,2,3,4 so try load image "myimage.bmp", 5.

As for pick ups and coins etc, all you would need to do is to position them where you want them, check for collision against the coins and perform the necessary events that occur.

A clever person solves a problem, a wise person avoids it - Albert Einstein
Azn QT97
13
Years of Service
User Offline
Joined: 24th Mar 2011
Location:
Posted: 7th Apr 2011 20:34
Ok, so I am close to finishing, but I need to spawn an item that can be collected to create an endgame scenerio, as well as level change. I tried using goto to change the level, but that doesnt work, and the closest I got to level change was simply using gotos to change the images to make the level look different. How can I order these gotos or gosubs to just change the levels images etc. Also how can I add a sprite that just moves and when you touch it, it "dies"?

Im such a nerd :3
<(^_^)> kirby <3
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 8th Apr 2011 11:08
Quote: " I tried using goto to change the level, but that doesnt work"


I'm not surprised, goto is notorious for increasing the complexity of your code as it jumps around the place. It is a good idea for you to learn what it does, and then only use it when necessary, which, in DBPro, is practically never. It makes bug finding much harder. If you're interested here's a link where goto is being discussed:
http://forum.thegamecreators.com/?m=forum_view&t=178016&b=2

Ok, when making a multi-leveled platformer it is a good idea to keep the contents of each level in its own subroutine or function and then imply that function when necessary. I'll write a small example of the structure which I use when creating projects that require different levels, menus etc. It will basically be psuedocode.



Hope that makes sense. To see it in action, here is an unfinished project of mine, it's not a platformer but it uses the structure described above.

To change the level images, implement it in a gosub or function.

Quote: "Also how can I add a sprite that just moves and when you touch it, it "dies"?"


Unfortunately, all I can say is have a go ( you could fly it out of the screen) and when you get stuck post some code and I'll try to help achieve the desired dying effect.

In my example, the uploaded one, take note as to how I reset the level and this should give you an idea on how to implement changing levels. Remember, its the concept you're looking at.



A clever person solves a problem, a wise person avoids it - Albert Einstein

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-04-25 11:53:07
Your offset time is: 2024-04-25 11:53:07