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 / I can go up but I cant get back down again!

Author
Message
Dom
20
Years of Service
User Offline
Joined: 31st May 2004
Location:
Posted: 9th Oct 2004 20:50
Yes I am having a problem with gravity and jumping in 3D. I can get my character to go up but Im not sure how to get it back down again.
Here is my code so far


Can anyone help me?

P.S Please try to explain it as simply as possible with as little Sine and Cosine because I am terrible at maths.

I am currently working on : A Medievil style game
By the way I'm 13 years old!!
computer
20
Years of Service
User Offline
Joined: 5th Oct 2004
Location:
Posted: 9th Oct 2004 22:54
ok, don't forget that all of that code is running more than once a second. That means running from the top to the bottom with your eyes about FIVE times... it's impossible.

I say this because I noticed

if controlkey()=1 then V#=(V#+3)
If V#=>1 then Gravity=(Gravity+1)
If Gravity=>1 then Position object obj,Posx#,Posy#+3,Posz#
If V#=>3 then V#=0

which seemed to me, that in the space of time it took to run 4 lines of code (V is 3, then four lines down V is 0 because YOU MAY of taken your finger off the control button in time).

I didn't wander off and tell you about another way of coding this. Maybe you should think about it more logically. or you need more programming time, so I'm not going too fast.

Here is the code.. I added a matrix, made myself a box and commented afew lines out. It works.. DBC..

box goes up.
box goes down.



bleep bleep
Dom
20
Years of Service
User Offline
Joined: 31st May 2004
Location:
Posted: 10th Oct 2004 00:26
sorry im a bit confused about
Quote: "if controlkey()=1 then V#=V#+3
If V#=>1
Gravity=Gravity+1
else
Graivty = 0
endif
If Gravity=>1
Position object obj,Posx#,Posy#+3,Posz#
else
Gravity=0
endif
` If V#=>3 then V#=0
"


I tried putting it in my program but my model now wont move at all.

I am currently working on : A Medievil style game
By the way I'm 13 years old!!
computer
20
Years of Service
User Offline
Joined: 5th Oct 2004
Location:
Posted: 10th Oct 2004 00:52
odd. Perhaps you have other variables within your code that you did not include above.

Maybe you could leave out the else and replace that excact piece of code with

if controlkey()=1 then V#=(V#+3)
If V#=>1 then Gravity=(Gravity+1)
If Gravity=>1 then Position object obj,Posx#,Posy#+3,Posz#

like you mentioned before. It still works in that small code you offered.

bleep bleep
computer
20
Years of Service
User Offline
Joined: 5th Oct 2004
Location:
Posted: 10th Oct 2004 01:17
ok, I didn't mess with your code too much, but I decided to add in a command called Point Object. I've had abit of fun because it does simulate gravity.

If you run just this code you should see the cube move up. I hope if can fit into your program.



bleep bleep
computer
20
Years of Service
User Offline
Joined: 5th Oct 2004
Location:
Posted: 10th Oct 2004 01:26
Smart, I managed to get the code to look abit more like yours.

Now when you press control, V is above 1. Gravity is 0. The object is moving up. Other wise the model will fall due to graivty being 1.

I'm getting alittle confused myself, somehow I think gravity should be either way round now.

Take a look at the code, both now should work.



I hope one of these will fit in.

bleep bleep

Login to post a reply

Server time is: 2025-05-26 00:17:47
Your offset time is: 2025-05-26 00:17:47