help with Slot machine game

Blitz3D Forums/Blitz3D Beginners Area/help with Slot machine game

Oh-Hello(Posted 2006) [#1]
I'm creating a Slot machine type game and I have three cubes set up with a surface and texture(7,bar,cherry,etc.) on each side. Im having a problem being able to identify which side is facing the user. I tried a few things using the ENTITYROLL#,ENTITYYAW# and the ENTITYPITCH# commands but found no luck.

Any Help would be Amazing

Thanks in advandce!!


sswift(Posted 2006) [#2]
I assume you're just pitching the cubes to make them spin? If so, I'm not sure what the problem is, but if you're doing that then all you have to do is Face = Floor(EntityPitch#(Entity) / 90) and you will get a number 0..3 which tells you which face is currently facing you.

If you're getting an entitypitch greater than 360 or less than 0 then try this:

Face = Abs(Floor(EntityPitch#(Entity) / 90) MOD 4)

And if you're getting an entitypich from -180 to 180, try this:

Face = Abs(Floor((EntityPitch#(Entity)+180.0) / 90) MOD 4)


Oh-Hello(Posted 2006) [#3]
When i use any of the formulas above they all return only two #'s. Also I'm just using TURNENTITY to turn the cubes if that makes any difference.

thanks


Stevie G(Posted 2006) [#4]
The issue with entitypitch is that values will only be between -90 and 90. You can get around this by holding a global pitch variable & incrementing this variable for the rotation. Then use rotateentity mesh, pitch, 0, 0 to show the visible rotation and use sswifts formulae on the pitch variable.

Stevie


sswift(Posted 2006) [#5]
Here's a new version, perhaps it will help you debug it if it desn't work but I explain the math:

; Get EntityPitch which is -90 to 90
Pitch# = EntityPitch#(Entity)

; Change range to 0 to 180
Pitch# = Pitch# + 90.0

; Get EntityYaw which is 0 or 180? (Check this!)
Yaw# = EntityYaw#(Entity)

; Add Yaw, which is 0 or 180 to Pitch which is 0..180, to get 0..360.
Pitch# = Pitch# + Yaw#

; Divide Pitch (0..360) by 90 (360/4) and round it down to get an integer 0..3.
Face = Floor(Pitch# / 90.0)


Oh-Hello(Posted 2006) [#6]
Ok when i checked ENTITYYAW# i got either 0,180 or -180. I think that is the problem but i dont know how to change that.

PS if i wanted to just "pitch" the cube like said earlier in sswift's post how do i do that.


sswift(Posted 2006) [#7]
; Get EntityYaw which is 0 or 180? (Check this!)
Yaw# = Abs(EntityYaw#(Entity))


Oh-Hello(Posted 2006) [#8]
That was the problem needed to take the absolute value.

thanks for all the help


Yeshu777(Posted 2006) [#9]
Check your email.