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 I make My Character jump

Author
Message
gopherbro 94
17
Years of Service
User Offline
Joined: 21st Dec 2008
Location:
Posted: 31st Dec 2008 04:34
I have a premade jump method from my school. ( I am modifying a pre made game for a mid term ). I had tried to use a matrix, but I gave that up. So somewhere in the process I believe I destroyed the jump command. SO Ill post the parts that I think go with the jump command.


This is the input command ( the buttons that make him jump



TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 31st Dec 2008 10:23
Hello!

I wrote a quick example:



The part that you are interested in is this:



Just study the code. You will get the hang of it.

TheComet

Peachy, and the Chaos of the Gems

Caleb1994
17
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 31st Dec 2008 20:32 Edited at: 31st Dec 2008 20:41
...
Caleb1994
17
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 31st Dec 2008 20:39 Edited at: 31st Dec 2008 20:43
whoops sorry didn't read it completly lol
gopherbro 94
17
Years of Service
User Offline
Joined: 21st Dec 2008
Location:
Posted: 2nd Jan 2009 16:36
I looked back In pages I found for the project and fixed the code to this.


REM Gravity Effects_____________________________________________________

If MyAcceleration# = 0.0
Emptyspace = 0 : Objectschecked = 0
for CheckObject = 6 to 12
If object collision(1,CheckObject)>0
1pY# = 1pY# - Gravity#
Position object 1, 1pX#,1pY#,1pZ#
if object collision(1,CheckObject) = 0
EmptySpace = EmptySpace + 1
endif
1pY# = 1pY# + Gravity#
Position object 1, 1pX#,1pY#,1pZ#
else
EmptySpace = EmptySpace + 1
endif
ObjectsChecked = ObjectsChecked + 1
next CheckObject
if EmptySpace = ObjectsChecked
MyAcceleration# = MyAcceleration# - Gravity#
endif
endif

If MyAcceleration# <> 0.0
1pY# = 1pY# + MyAcceleration#
Position object 1, 1pX#,1pY#,1pZ#
EmptySpace = 0 : ObjectsChecked = 0
for CheckObject = 6 to 12
If object collision(1,CheckObject)>0
1pY# = 1pY# - MyAcceleraion#
Position object 1, 1pX#,1pY#,1pZ#
MyAcceleraion# = 0.0
else
EmptySpace = EmptySpace + 1
endif
ObjectsChecked = ObjectsChecked + 1
next CheckObject
If EmptySpace = ObjectsChecked
MyAcceleration# = MyAcceleration# - Gravity#
endif
endif

The Input command stayed the same:


if Spacekey()=1 and MyAcceleration# = 0.0 : rem Make sure I've fully landed before I can jump again
1pY# = 1pY# - Gravity# : rem Look below me
position object 1, 1pX#,1pY#,1pZ# : rem Feel below me
for t = 6 to 12
if object collision(1,t)>0 : rem If feel a solid object below me
MyAcceleration# = MyPower : rem Prepare to jump!
play sound 6
endif
next t
1pY# = 1pY# + gravity# : rem Look up
position object 1, 1pX#,1pY#,1pZ# : rem Move back
endif

if Upkey()=1 then move object 1,MySpeed
if Downkey()=1 then move object 1,0-MySpeed
if Leftkey()=1 then 1aY = wrapvalue(1aY-(MySpeed/3))
if Rightkey()=1 then 1aY = wrapvalue(1aY+(MySpeed/3))

if Inkey$()="q"
for x = 1 to 100
if object exist(x) = 1 then delete object x
next x
backdrop off
goto EndSection
endif


Now for some reason, He jumps up in the air, but keeps going and going; never stopping. What do I do to make him stop and return to the ground?
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 3rd Jan 2009 18:28
Hello!

Firstly, please use the CODE button!!


Secondly, please INDENT your code!

Instead of:



Use the tab:



You usually add another tab after every do, repeat, while, if, for, subroutine and function.

Your code should look like this:



I am willing to help you, but it is extremely hard for me, because I don`t have ALL of the code. Could you please post ALL of the code?

Peachy, and the Chaos of the Gems

Login to post a reply

Server time is: 2026-07-05 00:01:59
Your offset time is: 2026-07-05 00:01:59