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 Discussion / How do you make your character jump in a first person shooter type game?????

Author
Message
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 10th Oct 2008 19:49
I have a basic matrix and a i can move around and shoot and run but i can't jump and i feel that it is a very important aspect of the game and dbc dosnt have any tutorials on it and there arnt any on the website either sum 1 helpppp!!!!
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 10th Oct 2008 23:54
Basically, if you press space (or whatever the jump button is) it will add 10 or so to the players vertical velocity. Then, you position the player at its position plus the vertical velocity in the y direction. If the player is not on the ground, then you will subtract from the player's vertical velocity a set amount until he hits the ground, where flags are set to show he isn't in the air anymore and his velocity is set to 0

Thats pretty much it

Ever notice how in Microsoft word, the word "microsoft" is auto corrected to be "Microsoft" but "macintosh" just gets the dumb red underline?
Digger412
17
Years of Service
User Offline
Joined: 12th Jun 2007
Location:
Posted: 18th Oct 2008 19:57
I'd think to use an algorithm of some sort, when the spacebar or w/e is pressed then it takes your forward velocity and adds to your vertical velocity, to make the player jump in a parabola based on your forward momentum, a longer jump if your going faster, a higher jump if your going slower..
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 12th Nov 2008 04:00
ok well i tried putting gravity in my game and then just when u press the spacebar it adds to the y value but it just blinks back down to normal height. it doesnt go down slowly like gravity
Irojo
17
Years of Service
User Offline
Joined: 21st May 2008
Location: Eating toast.
Posted: 12th Nov 2008 17:28
The key is a chain reaction.

if spacekey() then dec y,10

instead:

if spacekey() then jump=1

if jump=1 and y<10 then dec y,1 else fall=1:jump=0

if fall=1 and y>0 then inc y,1 else fall=0
--

Get it?

If not, I'll post a program with the basics.


I download memory.
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 12th Nov 2008 19:12
ok i see well what i was doing is using variables and doing sumthing like this

if CamY#>Get Ground height(1,X#,Y#)+30
Position camera X#,Y#-Gravity#,Z#
Gravity#-Gravity+Accel#
endif

If spacekey()
position camera X#,Y#+Jump#,Z#
endif

I wasn't sure if this was the way to do it but your way sounds less complicated so i'll try that thanks
Not_Maindric
17
Years of Service
User Offline
Joined: 10th Jul 2007
Location: Omaha, NE
Posted: 12th Nov 2008 22:45
Quote: "Gravity#-Gravity+Accel#"


I think it should be Gravity=Gravity(#)+Accel#
Not sure if there are both Gravity# and Gravity, but you had a - instead of a =...

Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 15th Nov 2008 00:09
ya sorry typo haha

I probly should have copy and pasted it but i wrote it in
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 15th Nov 2008 00:21
@Caleb
Irojo is on the right lines, but you don't need a flag for falling; gravity should have a constant effect and a jump pushes through it.
Also you need to check your character is on solid ground before you let him jump or he'll just shoot out of the top of the screen.
I like Digger's idea of using momentum for a more realistic jump (it would also add to the gameplay as players would have to judge whether they needed a run up) but get a simple jump working first.

A small program that works is better than a large one that doesn't.

DBC Challenge Rank: Rookie
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 15th Nov 2008 01:42
Not too complicated for the distance jump. Once 'jump' is activated, lock the current speed (velocity == direction and speed). Up and down is governed by gravity and will always be the same (unless you have different jump strengths)

Enjoy your day.
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 16th Nov 2008 03:29
ok thanx guys i'll see what i can do

Login to post a reply

Server time is: 2025-06-07 17:08:02
Your offset time is: 2025-06-07 17:08:02