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 / My questions (angles and stuff.)

Author
Message
nightmare
20
Years of Service
User Offline
Joined: 21st Nov 2003
Location:
Posted: 26th Nov 2003 01:09
Since I'm new to Dark Basic, I'll post my questions in this topic, after I've looked throught he tutorials and programs on the disk and have checked this forum and devolopers network.

My first question:

rem Modify character angle based on left/right keys
stage=0
IF LEFTKEY()=1 THEN a#=a#-8.0
IF RIGHTKEY()=1 THEN a#=a#+8.0
a#=wrapvalue(a#)

rem Modify character position based on up/down keys
IF UPKEY()=1 THEN x#=NEWXVALUE(x#,a#,3) : z#=NEWZVALUE(z#,a#,3) : stage=1
IF DOWNKEY()=1 THEN x#=NEWXVALUE(x#,a#,-3) : z#=NEWZVALUE(z#,a#,-3) : stage=1

I don't understand this, as in what is a#, x#, and z#, and what does stage do? I know what its supposed to do, but how it works confuses me. And I don't fully understand this wrapvalue thing, its supposed to be used if something goes beyond 360 degress, but can you explain more of it?

I hope I don't have to ask many questions in this and can find most of them out myself, but this would be better then to keep picking out new topics. Btw, how do I do that thing where you click on it and text appears?

Webmaster of www.mediashrine.com
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 26th Nov 2003 01:36 Edited at: 26th Nov 2003 01:38
put text within "code" "/code" html tags (wrapped in [....])

as far as wrapvalue, use this function by IanM



the dbp one is broken on large numbers (higher than dbp integer)

stage? that must be some variable from some code snippet you got somewhere - I don't thinks its a command - not sure tho.

-RUST-
nightmare
20
Years of Service
User Offline
Joined: 21st Nov 2003
Location:
Posted: 26th Nov 2003 01:44 Edited at: 26th Nov 2003 01:45
Stage is not a command.

I got this code from a brief program, by going to help, tutorial, programs, then the sample 10 folder in Dark Basic.

btw, now i'm really confused on wrapvalue.....

Webmaster of www.mediashrine.com
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 26th Nov 2003 01:50
sorry, wrapvalue() function takes a number and keeps it within a 360 range...here's dbp help:

WRAPVALUE
This command will return a value that does not exceed the range of 0 to 360. Where a value is specified
that exceeds this range, the command will wrap the value around to bring it back within the range. This
command is best understood by using the number of a clock as a mental picture of how a number wraps. If
the clock hand points to 11 and is then advanced 2 hours, the number has to wrap from 12 around to 1 to
keep the cycle going. The parameter should be specified using a real number.

SYNTAX
Return Float=WRAPVALUE(Angle Value)


so 361 becomes 1, 362 becomes 2 and so on...
you can replace the dbp one by inserting the function in your code and calling it just like you would wrapvalue()...

myFloatVar=NewWrapValue(floatValueToWrap)

-RUST-
nightmare
20
Years of Service
User Offline
Joined: 21st Nov 2003
Location:
Posted: 26th Nov 2003 02:34
A better question would be how can wrapvalue be used in a useful way?

I understand what it does, not how it can be used.

Webmaster of www.mediashrine.com
nightmare
20
Years of Service
User Offline
Joined: 21st Nov 2003
Location:
Posted: 26th Nov 2003 05:46
I figured out a lot, after looking exteremely hard, but I still don't understand some of it. Here is what I do understand, stage is set to 0, or for false. then its used to check if it is to play the animation of the .x file or not, and which one. you have to use wrapvalue in this too, because you need to store the coords of the next move it makes into a variable for future animation loops.

but what's z, newvalue, and the 3 and -3's for?


I'm so proud I figured that out by myself!

Webmaster of www.mediashrine.com
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 26th Nov 2003 06:07 Edited at: 26th Nov 2003 06:09
Again, from dbp help file:

NEWXVALUE
This command will return a value that represents the new X position of a point in 3D space. This command
is used in conjunction with NEWYVALUE and NEWZVALUE commands to move from one point in space to
another point in space based on a specified angle. Rather than using COS/SIN maths, these commands
simplify the task of moving coordinates within 3D space. The step value specifies how far in the specified
direction you would like to calculate. The parameters should be specified using real numbers.

SYNTAX
Return Float=NEWXVALUE(Current X Value, Angle Value, Step Value)


people here won't mind helping newbies but you have to do some leg-work on your own too. Use the tutorial, start small, read the help files for command definitions, and if you are still stuck then post up. Hope I have helped you.

-RUST-
nightmare
20
Years of Service
User Offline
Joined: 21st Nov 2003
Location:
Posted: 26th Nov 2003 06:50
I did look in the dicitionary, but that didn't help me so I asked here. Like I said previously, I have looked through this forum and many other places first. And its faster and a better way to learn too.

I thank you for your help

Webmaster of www.mediashrine.com
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 26th Nov 2003 07:02
no problem.
are you using dbpro and have the latest help files?

-RUST-
las6
22
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Finland
Posted: 26th Nov 2003 09:49
stage=0
that sets the variable stage to 0.

IF LEFTKEY()=1 THEN a#=a#-8.0
if leftkey is pressed (true) then variable a# is decreased by 8. Variable a# is used as the value for the Angle. That is used in the movement (y-axis, I presume)

IF RIGHTKEY()=1 THEN a#=a#+8.0
This time it checks for rightkey, and instead of decreasing the a# variable, it increases it by 8.

a#=wrapvalue(a#)
Now, when the app starts, a# was most likely 0 by default. If the user pressed leftkey, it would have been decreased by 8. That means a# would be -8 at the moment. Now, if you want to use the a# as an angle, you can't have negative values or values over 360. Wrapvalue solves this. after passing a# through wrapvalue means that a# = 352

IF UPKEY()=1 THEN x#=NEWXVALUE(x#,a#,3)
If the player presses upkey, the new value for variable x# is calculated. x# is most likely a variable used in positioning an object in 2 or 3 dimensional space.

NEWXVALUE requires 3 variables to return anything usefull.
first is the current position. we use x# here which is the old/current position. a# is the angle we are facing. (y-axis)
and the last one is the distance or speed (depends on how you look at it) we move.

new zvalue does the same, but for z# position.

Thing with this, is that we are basically plotting a new position on 2d space (x & z dimensions). This means the even if it looks that we are moving both values by 3 or -3, it takes account the angle. if you are looking at left (usually x dimension), only the x will get added up while the z stays the same. Fortunately for you, those commands make this all a lot easier than by doing it all with maths.

And stage is some variable that is set on when you press upkey.
Normally the ":" sign is used to separate commands (so you can have more than one in the same line) but if you use it after IF, it will count in aswell.

that's about it.

Keyboard not detected. Press F1 to continue.

Login to post a reply

Server time is: 2024-09-21 09:43:31
Your offset time is: 2024-09-21 09:43:31