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.

Dark GDK / 2D Platformer - Gravity & Jump

Author
Message
shadow sight
17
Years of Service
User Offline
Joined: 26th Oct 2006
Location: Derby England
Posted: 8th Feb 2010 17:40 Edited at: 8th Feb 2010 19:32
Hey guys, I downloaded the Dark GDK again yesterday and I've set out to make a small Platformer.

What I want is to be able to Jump (Either with Physics or just "jump"ing)

I've tried Box2D and S3GE both to no prevail and so I tried to create the "jump" functionality for myself.

What I have so far is:


This compiles fine but doesn't work.

If there's a fix for this or a different/easier way of doing things, please let me know.

Thanks
Lee

Founder of Fireball Games
shadow sight
17
Years of Service
User Offline
Joined: 26th Oct 2006
Location: Derby England
Posted: 9th Feb 2010 00:02
bump

I've been working on this ALL day today and the best I've managed is:





This works to about 90% of what I want, except; The transition when jumping isn't smooth, obviously it just moves the sprite and when I've jumped it leaves me at the top of the jump. It doesn't take me back down.

Founder of Fireball Games
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 9th Feb 2010 08:49
maybe


shadow sight
17
Years of Service
User Offline
Joined: 26th Oct 2006
Location: Derby England
Posted: 12th Feb 2010 18:20
I worked it out, I tried the methods that you posted but it didn't give me the desired outcome. So I sat down with the old pen and paper and came up with this.


Controls:


Physics:


Lee Walker Founder of Fireball Games
oika
14
Years of Service
User Offline
Joined: 16th Feb 2010
Location: Milky Way Galaxy
Posted: 16th Feb 2010 10:37
Try this:
//very simple jumping procedure
//variable jump = 0
if (Space () && jump == JUMPIT) //global JUMPIT = 1234 or other value
jump = 18; //change this for your needs

//check for jumping or falling
if (jump != JUMPIT)
{
player.y -= jump / 3; //change this for your needs
jump --;
}
else
//check for collision with ground or what you have
// you can change if to switch to check collision with different types of obstackles and sprites
//here you can add code for detecting collision with the objects above the player
//player.w is player width and player.h is player height
if (!Collision (player.x + (player.w / 2), player.y + player.h) == BLOCK) /*||
(!Collision (player.x + (player.w / 2), player.y) == BLOCK)*/
jump = 0;

//if jump < 0, player is falling, check for collision with ground or what you have
if (jump < 0) //player is falling
{
// you can change if to switch to check collision with different types of obstackles and sprites
if (Collision (player.x + player.w / 2, player.y + player.h ) == BLOCK )

{
jump = JUMPIT;

while (Collision (player.x + player.w / 2, player.y + player.h) == BLOCK)
player.y -= 1;
}
}

Login to post a reply

Server time is: 2024-10-01 23:38:08
Your offset time is: 2024-10-01 23:38:08