Hi Philip,

Thanks so much. I can take this example and port it to a 2D scenario using vectors and the like. This is exactly what I've been looking for. Thank you.


On 1/6/2016 17:16, Philip Bennefall wrote:
Hi Gavin,

Assuming that you don't intend to let the user move in two dimensions (e.g. your map is only a 1d grid with left/right movement), you can implement jumping in a hacky way with a flag and a timer. BGT:ish pseudocode follows:

const int jump_limit_ms=200; // The amount of time the character must wait after landing before they can jump again. const int jump_time_ms=800; // How long the character should stay in the air.
timer jumptimer;
bool jumping=false;;
if(key_pressed(KEY_J) and jumping==false and jumptimer.elapsed>=jump_limit_ms)
{
play jump sound;
jumping=true;
jumptimer.restart();
}

if(jumping and jumptimer.elapsed>=jump_time_ms)
{
play landing sound;
jumping=false;
jumptimer.restart();
}

Of course, you'll want to wrap this into a more modular player class. This is just a very basic starting point from which you can build further. Remember that with this setup it is perfectly fine for the player to move in the air; you just have to check the jumping flag to see if anything special should happen if the player moves onto a particular tile while jumping.

Note that if you do want your character to be able to travel in 2 or 3 dimensions (e.g. proper movement), the procedure is more involved. You will then need to move the character on the x and y and possibly z axis depending on how high and how far they jump.

Good luck!

Kind regards,

Philip Bennefall

On 1/6/2016 4:07 PM, Gavin Grundlingh wrote:
Thanks for the code snippet, John. The problem is that wait pauses execution of the entire script, so while I'm in the air, I wouldn't be able to move, shoot, or anything else.


On 1/6/2016 17:04, john wrote:
Note that in the below, wait means execute your timer.
if(key_pressed(KEY_J))
{
height=1;//in the air
play(jump);
wait(700);
height=0;//on the ground
play(land);
}
And now whenever it matters if the player is jumped, just check the height
variable.

--------------------------------------------------
From: "Gavin Grundlingh" <[email protected]>
Sent: Wednesday, January 06, 2016 9:54
To: "Gamers Discussion list" <[email protected]>
Subject: Re: [Audyssey] Making a Character Jump In BGT

Hi John,

Yes, I want to put the character back on the ground after the 700
milliseconds, but I don't know how to make that bit of code wait until
the jump timer is finished without using a second while loop, which will
break execution of the rest of my script.


On 1/6/2016 16:13, john wrote:
Are you putting the character back on the ground?

--------------------------------------------------
From: "Gavin Grundlingh" <[email protected]>
Sent: Wednesday, January 06, 2016 4:33
To: "Gamers Discussion list" <[email protected]>
Subject: [Audyssey] Making a Character Jump In BGT

Hi all,

I'm trying to make a character jump in BGT. I managed to make it stay in the air for the specified amount of time, but I can't figure out how to
make it land after that time has elapsed. I'll paste a code fragment
below:

if (key_pressed (KEY_J))
{
if (Jumper.elapsed >= 700)
{
Jumper.restart ();
JumpSound.play ();
}
LandSound.play ();
}

I have a suspicion that I'm missing something stupidly logical to make
it work. Any feedback is appreciated.

Regards,

Gavin

---
Gamers mailing list __ [email protected]
If you want to leave the list, send E-mail to
[email protected].
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/[email protected].
If you have any questions or concerns regarding the management of the
list,
please send E-mail to [email protected].


---
Gamers mailing list __ [email protected]
If you want to leave the list, send E-mail to
[email protected].
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/[email protected].
If you have any questions or concerns regarding the management of the
list,
please send E-mail to [email protected].


---
Gamers mailing list __ [email protected]
If you want to leave the list, send E-mail to
[email protected].
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/[email protected].
If you have any questions or concerns regarding the management of the list,
please send E-mail to [email protected].


---
Gamers mailing list __ [email protected]
If you want to leave the list, send E-mail to [email protected].
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/[email protected].
If you have any questions or concerns regarding the management of the list,
please send E-mail to [email protected].



---
Gamers mailing list __ [email protected]
If you want to leave the list, send E-mail to [email protected].
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/[email protected].
If you have any questions or concerns regarding the management of the list,
please send E-mail to [email protected].
.



---
Gamers mailing list __ [email protected]
If you want to leave the list, send E-mail to [email protected].
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/[email protected].
If you have any questions or concerns regarding the management of the list,
please send E-mail to [email protected].



---
Gamers mailing list __ [email protected]
If you want to leave the list, send E-mail to [email protected].
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/[email protected].
If you have any questions or concerns regarding the management of the list,
please send E-mail to [email protected].

Reply via email to