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.

DarkBASIC Professional Discussion / Advice for creating 2D platformer...

Author
Message
DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 17th Aug 2010 06:13
Hi all,

I'm currently designing a small 2D platform game and just wanted to ask the forum if they have any suggestions, tips and/or advice on making one.

I've made a platform game in 3D so I know the basic stuff like moving and jumping. I'm more worried about the "physics".

To be precise, I'm basically making a 2D platform game similar to Maple Story-like games, especially in terms of the physics. Like if you're underneath stairs and you jump up, you'll land on them and if you hold down and jump, you will fall down to the level below.

Like I was thinking of making a flat terrain with steps to a house. I imagined that the ground, each individual step and the house are all separate sprites.

I know I should start first, but thought I'd ask first in case there are things I should keep in mind or something.

Thanks
DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 17th Aug 2010 14:16
Ah here's a problem I came up with. How do I make gravity for sprites. I tried looking at some of the gravity codes in the CodeBase but none fits.

I can make one for 3D but can't for 2D. I'm currently using a sprite jump code from CodeBase which "shouldn't" be a problem.

With 3D, I use SC_GroupCollision to check whether the player is currently on the ground or not. If the player is not on the ground and he isn't jumping, then pull him down to earth.

But how do I do that for Sprite? I can check against 1 ground object via SpritePixelCollision but for some reason, when I change the parameter to an "n" via a FOR NEXT loop, it stops working =/
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 17th Aug 2010 15:36
Well I designed a function for sprite level collision where the level is an entire image and it returns where the collision hit the sprite.
So for example if you stood on the ground it would return BotLBotR
since the bottom left and right of the sprite is colliding with the level. Heres the link to my collision function thread.
http://forum.thegamecreators.com/?m=forum_view&t=174271&b=1

For jumping make X and Y velocity variables, then increase the sprites x and y position by the velocity variables. SO for jumping, just set the y velocity to like 10 or something and your good to go. For gravity, just decrease the y velocity when your not touching the ground.

My computer can render anything no matter the complexity of it in real time.
The memory is enormous. My computer is unique to everyone else’s. What computer do I have?

DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 18th Aug 2010 07:16
Kewl thanks for the link. So basically, I just make the entire level a single image?

Not sure if that would work in my case since there are sprites in the "background" like my Maple Story explanation.

For example, take a look at the image below:



See how on the bottom ground there is a slightly higher ground? In the game, if you were walking on the bottom-most ground and jumped, you will end up on the higher ground. Hope that's a good explanation of what I mean.

But I'll try it out your function nonetheless.

For the jump code, this is the one I'm using now:



That jump works fine, but when I combine it with my gravity code, the gravity doesn't work. The gravity simply says that if the player is not touching the ground nor is jumping, then INC its ypos by X. It works fine if it's just checking for 1 sprite. But as mentioned, I can't check for multiple grounds if I change the parameter to an "n" via a FOR NEXT loop, for the SpritePixelCollision.
But looking at your code, do I just make the ground a single image then check using your function that if the player is not touching the ground, move him downwards?
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 18th Aug 2010 15:58
Yes, It works as the level you collide with being 1 image. You have to have the background of the level transparent. So if you want a background sprite like the tree and clouds in that pic, just position it behind the level image.
A tip for using that function is when checking for collision, use Find Sub String$(PixelCollision(Sprite,LevelSprite),Side$) where side$ can be TopL, TopR, BotL, BotR, LefT, LefB, RigT or RigB.

My computer can render anything no matter the complexity of it in real time.
The memory is enormous. My computer is unique to everyone else’s. What computer do I have?

DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 19th Aug 2010 09:56
Ok cool. I'm also going to make a function where if you held down and jumped, you would go down to the next lower terrain (in the example above, it would be jumping straight down from the higher ground to the bottom-most ground).

I'll work on all of this hopefully this weekend (got assignments to do).

Thanks and I shall report back when I'm done ^^
DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 21st Aug 2010 14:57
Hi again. I must be misunderstanding something.

Can you show me how to work your function? I keep getting errors saying that Temp3 and "0" or "BotLBotR" is not compatible.

I thought I understood the code but guess I don't =/. I tried this just to see:



But it says Temp2 and BotL are incompatible or something. I also don't know what Find Sub String exactly does so I tried this to see:



This one says Find Sub String does not match 'source, string'.

Sorry if this is obvious but I can't get it to work. Currently I'm just trying to make a gravity code and a jump code using your function. So to avoid any more misunderstanding, can you show me how to use it?
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 23rd Aug 2010 17:50
You almost got it.


you forgot to put the speech marks around BotL.

My computer surpasses all the technologies of the day. What computer do I have?

DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 24th Aug 2010 07:09
Ok well that works. Except the two pixels aren't touching and yet the text shows up.

My test level image is a 1024x768 PNG with alphas. In fact, right now, it's just a flat ground and the player (who is a separate PNG image) is floating in the air. But the code says that they've collided.
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 24th Aug 2010 20:34
Here, I redid the GetPixels function. Replace just it with this and tell me if it works.


My computer surpasses all the technologies of the day. What computer do I have?

DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 26th Aug 2010 05:00
I just replaced the old GetPixels with your updated one and it still says the two sprites have collided even though the player is floating in the air.

This is the code thus far:

Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 26th Aug 2010 15:49 Edited at: 26th Aug 2010 15:50
Make sure the ground image takes up the entire screen and the alpha is where the ground isn't. I attached an example ground image where you would position it at 0,0 and have your display mode the size of the picture.

My computer surpasses all the technologies of the day. What computer do I have?

DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 27th Aug 2010 06:25
Yeah that's what I did. My resolution is 1024, 768, 32 and so is the image.

In fact, I attached the ground image on my last post and as you can see it is as big as the screen. And in the code you can see that it's placed at 0,0.
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 27th Aug 2010 16:34
It does work. However find substring returns the string position so you should have a >0 at the end of it.

It should work now.

My computer surpasses all the technologies of the day. What computer do I have?

DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 28th Aug 2010 06:49
Ah yip. I just added the "> 0" and it works.

Thanks ^^ This should make coding the game easier. Though until I cross the threshold of implementing a jump and giving him the ability to jump up stairs and falling down to lower levels, I can't rest just yet hehehehe =D

Thanks again
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 28th Aug 2010 17:30
No problem. Glad I could help.

My computer surpasses all the technologies of the day. What computer do I have?

DevilLiger
22
Years of Service
User Offline
Joined: 21st Nov 2003
Location: Fresno,CA,USA
Posted: 3rd Oct 2010 12:53 Edited at: 3rd Oct 2010 12:53
in the past newspapter article they did a bruce lee one. you can check that out first.

Login to post a reply

Server time is: 2026-07-24 00:18:14
Your offset time is: 2026-07-24 00:18:14