Oh Matty that looks fantastic! Shambler... Thanks! BOTH of you have helped... let me tweak that into the code and I will post it if it works (or even if it doesn't!) : )
{{ CODE NOW INCLUDED }}
Graphics3D 800,600,32,1
SetBuffer BackBuffer()
Cls
SeedRnd MilliSecs()
; ######## SETUP PLACE HOLDERS FOR EULER ANGLES
Dim pit(10) ; PITCH
Dim rol(10) ; ROLL
Dim ya(10) ; YAW
Dim TurnRate#(4)
Global stillspinning
Global turns
; ######## LOAD THE ACCORDING EULER ANGLES FOR EACH NUMBER 0 - 9
pit(0)=72
pit(1)=71
pit(2)=38
pit(3)=0
pit(4)=-40
pit(5)=-70
pit(6)=-69
pit(7)=-39
pit(8)=0
pit(9)=39
rol(0)=180
rol(1)=0
rol(2)=0
rol(3)=0
rol(4)=0
rol(5)=0
rol(6)=180
rol(7)=180
rol(8)=180
rol(9)=-180
ya(0)=-180
ya(1)=0
ya(2)=0
ya(3)=0
ya(4)=0
ya(5)=0
ya(6)=-180
ya(7)=-180
ya(8)=-180
ya(9)=180
; ######## Create a camera so we can see it
camera=CreateCamera()
PositionEntity camera,21,0,-60
; ######## add some lightage
sun = CreateLight()
PositionEntity sun,835,1456,502
RotateEntity sun,80,0,-900
; ######## Load and position the meshes for the wheels already covered in Ult. Unwrap
Global mesh=LoadMesh( "wheel1.b3d" )
Global mesh2=CopyEntity(mesh)
Global mesh3=CopyEntity (mesh)
Global mesh4=CopyEntity (mesh)
PositionEntity mesh,0,0,0
PositionEntity mesh2,11,0,0
PositionEntity mesh3,22,0,0
PositionEntity mesh4,33,0,0
Dim WheelMesh(4)
WheelMesh(1)=mesh
WheelMesh(2)=mesh2 ;this is using your already defined mesh/mesh2/mesh3/mesh4 entities but storing their handles in an array instead, easier to manipulate
WheelMesh(3)=mesh3
WheelMesh(4)=mesh4
; ######## Randomly position the wheel
wheel1=Rnd(0,9)
wheel2=Rnd(0,9)
wheel3=Rnd(0,9)
wheel4=Rnd(0,9)
RotateEntity mesh,pit(wheel1),rol(wheel1),ya(wheel1)
RotateEntity mesh2,pit(wheel2),rol(wheel2),ya(wheel2)
RotateEntity mesh3,pit(wheel3),rol(wheel3),ya(wheel3)
RotateEntity mesh4,pit(wheel4),rol(wheel4),ya(wheel4)
; ######## degrees per frame to turn higher number mean faster initial spin.
TurnRate#(1)=10.0+Rnd(-3.0,3.0) ;do the same for indexes 2-4
TurnRate#(2)=10.0+Rnd(-3.0,3.0)
TurnRate#(3)=10.0+Rnd(-3.0,3.0)
TurnRate#(4)=10.0+Rnd(-3.0,3.0)
Decay#=0.995 ;adjust to any value between 0.0 and 1.0 to change the rate at which they slow down, and therefore changing the amount of time taken for the wheels to come to rest.
; ################################################## START OF GAME LOOP
; While Not KeyHit(1)
Repeat
HaveWheelsStopped=True
For i=1 To 4
TurnEntity WheelMesh(i),TurnRate#(i),0,0
; only need to alter the pitch why bother altering the yaw and roll
; unless you are doing something totally different To what I am thinking you are...
;
; <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
;
; I AM... I am altering the pitch to make the faces (NUMBERS) selected by the random number
; generator true... that way wheel1,wheel2,wheel3,wheel4 are also values that actually
; represent the values I hope to achieve at final spin time...
TurnRate#(i)=TurnRate#(i)*Decay
If TurnRate#(i)<0.1 Then TurnRate#(i)=0
If TurnRate#(i)<>0 Then HaveWheelsStopped=False
Next
If KeyDown(57)=True Then ; ######## WHACK THE SPACEBAR
wheel1=Rnd(0,9)
wheel2=Rnd(0,9)
wheel3=Rnd(0,9)
wheel4=Rnd(0,9)
RotateEntity mesh,pit(wheel1),rol(wheel1),ya(wheel1)
RotateEntity mesh2,pit(wheel2),rol(wheel2),ya(wheel2)
RotateEntity mesh3,pit(wheel3),rol(wheel3),ya(wheel3)
RotateEntity mesh4,pit(wheel4),rol(wheel4),ya(wheel4)
EndIf
UpdateWorld()
RenderWorld()
;Text 0,0,"TrisRendered "+TrisRendered()
Text 0,10,"RUMBLE: "+wheel1+ " " +wheel2+" "+wheel3+" "+wheel4
Text 0,30,"Wheel1: "+EntityRoll(mesh)
Text 0,42,"Wheel2: "+EntityRoll(mesh2)
Text 0,54,"Wheel3: "+EntityRoll(mesh3)
Text 0,66,"Wheel4: "+EntityRoll(mesh4)
Flip
Until KeyDown(1)
; Wend
End
; ########
I am trying to do something slightly different. When the wheel spins I need to know (at the very least) what numbers end up showing... Thats why I had the euler angles (of a sort) plotted for every number on the face of the wheel. I could generate a random number and it would be the number displayed on the wheel.
If you slapped the spacebar it would (of course) keep generating NEW random numbers and the wheel would give the appearace of spinning.
Thats kind of what I was shooting for. BIG PLUS is the gradual slowdown... that helps for a lot of things. But the computer has NO WAY of knowing wht number is showing. Hard to program a check for a win! : )
-RZ
If you go to:
http://www.silverimports.com/web3ds/ you can see a fil called slots.zip or slotz.zip.. The wheel and texture is in there as well as my source code. Post me a note when you have downloaded it because I will only keep it there for a short time. : ]