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.

Newcomers DBPro Corner / Jump/Crouch System for this code

Author
Message
culmor30
17
Years of Service
User Offline
Joined: 16th Jun 2007
Location: In my head.
Posted: 20th Feb 2008 04:55 Edited at: 20th Feb 2008 04:57
Hey all,

I was wondering if you guys could help me out with jumping and crouching as I've never done it before. I'm on a tight project deadline and need this asap if possible. Here's my code:



Sorry if you don't have DP. As you can see though, there is a clock time thing and a jumping subroutine. If anyone could help me out with jumping and crouching I'd be forever grateful, as would my group.

Jumping: I really just need to:

-check if the player is at the lowest point possible (spawn point)
-If space is down, start a jump
-If jump is in progress, do not jump again
-Jump should go up, gradually stop, then return to the spawn Y level.
-Allow jumps again.

Later on I'll need to see if the player is touching the ground object but for now just this is fine.

Crouching: Instant camera-Y lowering is fine, but I can probably do that myself. I just need help with this:

-If player is crouching and jumps, jump height should be lower than normal jump.

I know it's kinda a lot to ask, but I really need this or my group will fall behind and maybe fail completely. Any and all help is appreciated.

Thanks in advance
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 20th Feb 2008 22:12
Quote: "Sorry if you don't have DP."


As well as Dark Physics, you also need Sparky's Collision V2.0 (which I don't use) so I couldn't run this either.

TDK_Man

culmor30
17
Years of Service
User Offline
Joined: 16th Jun 2007
Location: In my head.
Posted: 20th Feb 2008 23:13 Edited at: 20th Feb 2008 23:45
Oh, heh, yeah, forgot about that. Well, I was hoping for the basic structure of the code or something if anyone had any idea, maybe some sample code. I've been trying since yesterday, just can't get it to work.

EDIT: Here's what I tried:

In the loop:


jumping subroutine:


Yes, jumpstep was defined before the loop. So really, it would just raise you, lower you, back to where you started. I'm probably just doing something wrong but I don't know. Help appreciated, thanks much.
culmor30
17
Years of Service
User Offline
Joined: 16th Jun 2007
Location: In my head.
Posted: 21st Feb 2008 03:00 Edited at: 21st Feb 2008 03:27
Sorry for double post, just wanted to emphasize progress.



There's the new stuff. I attached a compiled version in case you can't compile sparky's or dp.

The player starts out low for some reason, then you can jump twice back up to normal height. If you jump a third time, you fly up to the ceiling, and after a few seconds you slowly fall back down.

I just want to go up quick, maybe 5 units, then down to the normal Y value of 10.

Can anyone help me out there?

EDIT: If anyone can, I need help URGENTLY D: my AIM is culmor30 if you wanna IM me.

Attachments

Login to view attachments
Swizzl
16
Years of Service
User Offline
Joined: 22nd Feb 2008
Location:
Posted: 22nd Feb 2008 08:06
I'm pretty new at programming (actually started 4 days ago), but I think I caught why you continue to rise and not fall.

You set jumping to 1 at the end of the jump code, but as long as the space is held, the next if sets jumping as 0, and your dec speed only works if jumping equals 1. Since it runs the prog top to bottom (unless specified)rather than at the same time. your jumping is set to 1 then 0 before it reaches your falling routine.
As for your key repeating I've looked all over and found 2 separate
codes for the solution. I couldn't get them to work with my code. They may work in your's. This is one link http://darkbasicpro.thegamecreators.com/?m=codebase_view_code&i=fdbe8d64626493833e10d082f7704731
I don't remember the other one. After thinking, I wrote a code similar to one I found but tweaked. and it works fine. Here is a sample of it. Should be easy enough to adjust.

False was set as a boolean at the beginning. You can ignore the JUMP= 1 part, it's used in concordance with my double jump. Making a 3rd person. Anyways hope that helped a little, like I said I'm new and you may know all this already or maybe I misunderstood.

-K-W
Swizzl
16
Years of Service
User Offline
Joined: 22nd Feb 2008
Location:
Posted: 22nd Feb 2008 23:26
Whoops, forget about my *not falling part of the comment. Misread, sorry. 3 Am. guess I was tired lol.

-K-W
pirate
18
Years of Service
User Offline
Joined: 18th Apr 2006
Location: u.s.a
Posted: 25th Feb 2008 07:03
this code is from the codebase and is good jumping and gravity code using sparky's 2.

hope this helps.

thanks, pirate

Login to post a reply

Server time is: 2024-09-27 10:36:13
Your offset time is: 2024-09-27 10:36:13