Hi
I have until now used different types for players,enemies,objects etc.. no problem..
But now i tried to use one Type class for different "objects".
Example.
The only difference in the sample below is that one object is a cube and the other one is a ball.
But why does the ball rotate ???
When i do a "For cube.entity = Each entity" dont it just check the cube.entity "class" ??
[CODE]
Graphics3D 1024,768,32,2
SetBuffer BackBuffer()
Type Entity
Field Name$
Field Model
Field RX#,RY#,RZ#
End Type
camera = CreateCamera()
light = CreateLight()
setup()
PositionEntity camera,0,0,-20
;Main Loop
While Not KeyHit(1)
update_all()
UpdateWorld
RenderWorld
Flip
Wend
End
Function setup()
Cube.Entity=New Entity
Cube\name = "Cube"
Cube\model = CreateCube()
Cube\RX#=Rand(-3,3)
Cube\RY#=Rand(-3,3)
Cube\RZ#=Rand(-3,3)
PositionEntity Cube\model,-10,0,0
Ball.Entity=New Entity
Ball\name = "Ball"
Ball\model = CreateSphere()
Ball\RX#=Rand(-3,3)
Ball\RY#=Rand(-3,3)
Ball\RZ#=Rand(-3,3)
PositionEntity ball\model,10,0,0
End Function
Function update_all()
For cube.entity = Each entity
TurnEntity Cube\model,Cube\rX#,Cube\ry#,Cube\rz#
Next
End Function
I have until now used different types for players,enemies,objects etc.. no problem..
But now i tried to use one Type class for different "objects".
Example.
The only difference in the sample below is that one object is a cube and the other one is a ball.
But why does the ball rotate ???
When i do a "For cube.entity = Each entity" dont it just check the cube.entity "class" ??
[CODE]
Graphics3D 1024,768,32,2
SetBuffer BackBuffer()
Type Entity
Field Name$
Field Model
Field RX#,RY#,RZ#
End Type
camera = CreateCamera()
light = CreateLight()
setup()
PositionEntity camera,0,0,-20
;Main Loop
While Not KeyHit(1)
update_all()
UpdateWorld
RenderWorld
Flip
Wend
End
Function setup()
Cube.Entity=New Entity
Cube\name = "Cube"
Cube\model = CreateCube()
Cube\RX#=Rand(-3,3)
Cube\RY#=Rand(-3,3)
Cube\RZ#=Rand(-3,3)
PositionEntity Cube\model,-10,0,0
Ball.Entity=New Entity
Ball\name = "Ball"
Ball\model = CreateSphere()
Ball\RX#=Rand(-3,3)
Ball\RY#=Rand(-3,3)
Ball\RZ#=Rand(-3,3)
PositionEntity ball\model,10,0,0
End Function
Function update_all()
For cube.entity = Each entity
TurnEntity Cube\model,Cube\rX#,Cube\ry#,Cube\rz#
Next
End Function