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 / Help with Jumping

Author
Message
Derekioh
15
Years of Service
User Offline
Joined: 1st Feb 2009
Location:
Posted: 28th Dec 2009 22:46
ok, so i've been trying to get this jumping right for like 2 weeks and still have got nothing. When i jump, i move up, but don't come back down. Here is my jumping code:



Please help!
Hockeykid
DBPro Tool Maker
17
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 29th Dec 2009 03:04
Well I had a quick look and spotted some mistakes

JumpSpeed=1.5

Now if you want the JumpSpeed variable to hold a decimal value you need to add the has "#" mark so it should be like this


JumpSpeed#=1.5

(you'll need to change all of the JumpSpeed variables to JumpSpeed#)

Next

Your also going to want to change newy to newy# as its also trying to hold a decimal value

Next

POSITION OBJECT PlayerStatic,newx,newy, newz

as far as i'm concerned newx newy and newz all =0 so you'll want to change it to

POSITION OBJECT PlayerStatic,object position x(PlayerStatic),object position y(PlayerStatic)+newy#, object position z(PlayerStatic)

Next

You'll also want to add another check to this
("and spacekey()=0" so that it only goes into the block when space is released)

if Jumping=1 and spacekey()=0 // and ground = 1
newy = newy + JumpSpeed
JumpSpeed = JumpSpeed -0.1
POSITION OBJECT PlayerStatic,newx,newy, newz
endif


Hope that info helps

chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 29th Dec 2009 14:11
Have a look to this sort code.




learning every day
Derekioh
15
Years of Service
User Offline
Joined: 1st Feb 2009
Location:
Posted: 30th Dec 2009 18:31
@hockeykid: ok, so i tried what you said, i changed all the variables to have a '#' at the end, but now i can't jump up at all. here's my modified code.



@chafari: i didn't understand your code completely, could you explain it?

sorry for my ignorance, still trying to learn this language and programming in general.
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 30th Dec 2009 18:49
Derekioh unless you've set ground to 1 somewhere else it will be zero so this will happen



and can someone tell me what this bit is trying to do //AND

Dark Physics makes any hot drink go cold.
Derekioh
15
Years of Service
User Offline
Joined: 1st Feb 2009
Location:
Posted: 30th Dec 2009 18:58 Edited at: 30th Dec 2009 19:02
//AND it means i'm commenting it out because i've haven't fixed checking if the player is on the ground yet

this is for the new darkbasic pro that was suppose to resemble microsoft visual studios layout.

Attachments

Login to view attachments
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 30th Dec 2009 19:19
Ok, thought it might have been this || being done wrong.

used to seeing rem or ` for a comment.

Are you wanting the JumpSpeed# = JumpSpeed# - 0.1 to go negative by a lot, as after a few second this will have gone to zero and below.

Dark Physics makes any hot drink go cold.
Derekioh
15
Years of Service
User Offline
Joined: 1st Feb 2009
Location:
Posted: 30th Dec 2009 19:43 Edited at: 30th Dec 2009 19:45
what i'm trying to do is go up to 2.5 and come down faster and faster (like gravity) until it hits the ground. I don't want the Player jumping very high.
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 30th Dec 2009 19:56
try this and you'll see what going on.



Dark Physics makes any hot drink go cold.
Derekioh
15
Years of Service
User Offline
Joined: 1st Feb 2009
Location:
Posted: 30th Dec 2009 20:45
ok i did what you said and i was given this (this is when i pushed to spacebar to jump):



And this is what i had before i pusged to spacebar to jump:



so i guess jump is working but for some reason jumping and/or newy# are not changing.
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 30th Dec 2009 21:02
if you watch the code you will have seen it show 2.5 but after a few second later the object was at newy#=-800,000. and jumpspeed#=-58


Your code work ok but the the system runs it it done about 800 loop in a few seconds

I've worked out how I think you might want it to work.



Dark Physics makes any hot drink go cold.
Derekioh
15
Years of Service
User Offline
Joined: 1st Feb 2009
Location:
Posted: 30th Dec 2009 22:21 Edited at: 30th Dec 2009 22:22
its works in that demo, but for some freaking reason, it doesn,t work in my project. so here's my idea, if you could plzzzzz look at my code in my project and tell me if it's something else wrong, that would be greatly appreasated (sorry about the spelling). read the README file for the line of code for jumping. thx so much.

Attachments

Login to view attachments
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 31st Dec 2009 15:02
Ok, have doing as you hoped.
right this should be like so
might not need the sync at the end.


and this bit needs to this.



should get you going again , might want to find out why you can't shoot the bady when you moved around a bit.

Looking good, keep going you done a fair bit.

Dark Physics makes any hot drink go cold.
Derekioh
15
Years of Service
User Offline
Joined: 1st Feb 2009
Location:
Posted: 31st Dec 2009 19:03
oh my gosh! It works! thx so much!
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 31st Dec 2009 19:26
The second bit was restting it, so that why it did not seem to work.

Like you said the little demo worked so that was the clue, must be something else breaking it.

Dark Physics makes any hot drink go cold.

Login to post a reply

Server time is: 2024-11-24 20:55:28
Your offset time is: 2024-11-24 20:55:28