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 Professional Discussion / Keep Object Above Matrix?

Author
Message
Phantom887
16
Years of Service
User Offline
Joined: 13th Sep 2009
Location:
Posted: 16th Jul 2011 06:23
I've been writing a little testing 3D program to get myself familiar with the DBP language, and I'm stuck trying to get this little cube that you can move around to stay above the matrix when I move it.

This is the code I have for the matrix:


And for the cube:


And later in the main do loop for the cube's movement:


It will rotate fine. The trouble comes trying to move it. It moves forward the first time you press the up key, (although it's a little jerky in its motion for some reason) but when you release the up key, and then press it again, the cube won't move. What am I doing wrong? Any help would be appreciated.
Hodgey
16
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 16th Jul 2011 06:50
Hi, try this


The first problem was that you were using integers when you could use floats. That was the reason for the "jumpyness".

Secondly, I don't like the move object command so I substitued my own mathematical functions to get it to move. It uses "projectile motion" without the gravity bit. I've attached a project that explains this in 2d but the concept applies for 3d.

Hope that makes sense and helps

Phantom887
16
Years of Service
User Offline
Joined: 13th Sep 2009
Location:
Posted: 16th Jul 2011 22:29
Thanks for the ideas. For some reason the floats helped with the second issue as well. Why don't you like the move object command, by the way?
Hodgey
16
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 16th Jul 2011 23:57
Quote: "Why don't you like the move object command, by the way? "

I like to program my own movement functions (it's the way I've learnt to program), I find it gives a bit more freedom, plus I also like to show off my mathematics.

Login to post a reply

Server time is: 2026-07-10 17:18:51
Your offset time is: 2026-07-10 17:18:51