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 / How do I make a cube rotate both left AND right?

Author
Message
Tazcat22
15
Years of Service
User Offline
Joined: 23rd Apr 2009
Location:
Posted: 28th Nov 2009 16:47
I'm not some guy asking you to make my game, I'm trying to start small with a cube collecting simple jewels. Unfortunately, I cannot figure out how to rotate the cube right, not just left. I have tried setting negative coordinates for an opposite affect, but it crashed.

here is my code so far.



if anyone could tell me how the rotate Y thing works out for multiple directions, please inform me!

The Universe Is Arbitrary, Why Do We Fall But Baloons Float? Why Are Kids Short, While Adaults Are Tall? Why Am I Writing This? Why Are You Reading This? Why?
Muriako
15
Years of Service
User Offline
Joined: 11th Aug 2009
Location:
Posted: 28th Nov 2009 18:17
Well, doing it the way you are, you should be able to just change the plus to a minus in your left turning line and it would turn like you want it to.

You should probably turn on your sync rate and cap it by the way, otherwise it will run ungodly fast on many computers, as it did mine.
Digger412
17
Years of Service
User Offline
Joined: 12th Jun 2007
Location:
Posted: 28th Nov 2009 18:24 Edited at: 28th Nov 2009 18:25
Well, you're in DarkBASIC Pro. You don't have to use the yRotate command. You can just use this instead:



As for the crashing part, I don't know if it would be because you didn't have wrapvalue(value), to ensure that you're rotating didn't exceed 360 degrees or go below 0.
Tazcat22
15
Years of Service
User Offline
Joined: 23rd Apr 2009
Location:
Posted: 28th Nov 2009 18:45
Thanks, it works great. It seems like they used some old tutorials in the help file, because I got one or two that weren't recognized, such as pitching left or right.

The Universe Is Arbitrary, Why Do We Fall But Balloons Float? Why Are Kids Short, While Adults Are Tall? Why Am I Writing This? Why Are You Reading This? Why?
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 28th Nov 2009 18:59 Edited at: 28th Nov 2009 19:01
Your method written correctly (by the book):



Rotating in different directions is simply a case of adding or subtracting the amount of rotation you require. As Digger412 said, if the object's angle value goes below 0 or above 359 then you get an error - hence the use of WrapValue().

Your Wait Key and End are redundant as your main Do..Loop code will never be exited (though many people, like me, do leave the End in through habit).

Speed is also an issue - like Muriako says - but you also have the option to decrease the amount of rotation too.

Angles and 3D distances are floats - not integers like you have used. As such, you can also use something like:

Yrotate Object 1, WrapValue(Object Angle Y(1)+0.01)

If you want to follow the rules exactly, then you should also use floats even when you are using whole number values - eg: 1.0 and 2.0 instead of 1 and 2. It does work fine with integers, the command just expects a float.

TDK

Tazcat22
15
Years of Service
User Offline
Joined: 23rd Apr 2009
Location:
Posted: 28th Nov 2009 19:02
IMPOSSIBLE! I just tried that as soon as I started and it gave me errors. but now I try it and it works...

Thanks for the help guys, it's running smoothly.

The Universe Is Arbitrary, Why Do We Fall But Balloons Float? Why Are Kids Short, While Adults Are Tall? Why Am I Writing This? Why Are You Reading This? Why?

Login to post a reply

Server time is: 2024-11-24 22:30:20
Your offset time is: 2024-11-24 22:30:20