I've been working on the guide for FPS's again and Ive ran into a problem; Im now introducing the use of arrays and I thought I knew everything I needed to know about them but when I was working on some sample code for the readers to learn from something went wrong:
Basically, the sample code shows how to store object data in arrays, in this case Object1(1,3) stores object 1's x, y and z sixe. In the sample, object 1 is a box with dimensions 30x60x50, but the object size commands return 29.9956989something er other, 79.99989870 something er other, and 49.986708 something er other
I've tried using the integer command but for some reason it rounds the value down instead of up, even though in my mind should it not round up?
Here's the sample code Im working with:
SYNC ON:SYNC RATE 0:AUTOCAM OFF:HIDE MOUSE
MAKE OBJECT BOX 1,30,50,80
MAKE OBJECT SPHERE 2,20
MAKE OBJECT CUBE 3,5
DIM Object1(1,3)
DIM Object2(1,3)
DIM Object3(1,3)
DO
Object1(1,1)=OBJECT SIZE X(1)
Object1(1,2)=OBJECT SIZE Y(1)
Object1(1,3)=OBJECT SIZE Z(1)
Object2(1,1)=OBJECT SIZE X(2)
Object2(1,2)=OBJECT SIZE Y(2)
Object2(1,3)=OBJECT SIZE Z(2)
Object3(1,1)=OBJECT SIZE X(3)
Object3(1,2)=OBJECT SIZE Y(3)
Object3(1,3)=OBJECT SIZE Z(3)
TEXT 0,0,"Object 1"
TEXT 0,30,STR$(Object1(1,1))
TEXT 0,45,STR$(Object1(1,2))
TEXT 0,60,STR$(Object1(1,3))
TEXT 0,100,"Object 2"
TEXT 0,130,STR$(Object2(1,1))
TEXT 0,145,STR$(Object2(1,2))
TEXT 0,160,STR$(Object2(1,3))
TEXT 0,200,"Object 3"
TEXT 0,230,STR$(Object3(1,1))
TEXT 0,245,STR$(Object3(1,2))
TEXT 0,260,STR$(Object3(1,3))
`This is a test to show one size of object 1 in decimal and below it the same size in integer form
TEXT 0,300,STR$(OBJECT SIZE X(1))
TEXT 0,315,STR$(INT(OBJECT SIZE X(1)))
SYNC
LOOP
(P.S I know theres a better way to write it that comes later in the guide)
<EDIT>
After looking up the INT command I can see why it isnt working, according to the definition it returns the largest whole number
before the decimal. I still haven't come acrosx any rounding commands however.
<EDIT2>
Come to think of it it wouldn't be too hard to come up with a function to do it, its just Id rather not have to introduce functions right now if I dont have to
FUNCTION Round(Value#)
NewVal=1+(INT(Value#))
ENDFUNCTION NewVal
Hmm..I guess if its that simple to round something then I can see why there wouldn't be a command...
Either way if someone finds one please direct me to it (looks like functions are going to be introduced sooner than thought if not)