home *** CD-ROM | disk | FTP | other *** search
- ;demo06-02.bb - Moving and rotating a sphere
- ; ------------------
- Graphics3D 640,480
- SetBuffer BackBuffer()
-
- ;Key constants
- Const A_KEY = 30
- Const Z_KEY = 44
- Const LEFT_KEY = 203
- Const RIGHT_KEY = 205
- Const UP_KEY = 200
- Const DOWN_KEY = 208
- Const ESC_KEY = 1
- Const N_KEY = 49
- Const M_KEY = 50
- Const COMMA = 51
- Const PERIOD = 52
- Const X_KEY = 45
- Const C_KEY = 46
-
- ; Create camera
- camera=CreateCamera()
- ; Create a light
- light=CreateLight()
-
- ;Create sphere
- sphere=CreateSphere(16)
- PositionEntity sphere,0,0,5
-
- ;Load the texture
- tex=LoadTexture( "brick.jpg" )
- ScaleTexture tex, .5,.5
- EntityTexture sphere,tex
-
- ; This following code moves our sphere:
- While Not KeyDown(ESC_KEY)
-
- If KeyDown(A_KEY) TranslateEntity sphere,0,-.3,0
- If KeyDown(Z_KEY) TranslateEntity sphere,0,.3,0
- If KeyDown(LEFT_KEY) TranslateEntity sphere, -0.3,0,0
- If KeyDown(RIGHT_KEY) TranslateEntity sphere, 0.3,0,0
- If KeyDown(UP_KEY) TranslateEntity sphere,0,0,0.3
- If KeyDown(DOWN_KEY) TranslateEntity sphere,0,0,-0.3
- ; Change rotation values depending on the key pressed
- If KeyDown(N_KEY)= True Then pitch#=pitch#-1
- If KeyDown(M_KEY)=True Then pitch#=pitch#+1
- If KeyDown(COMMA)=True Then yaw#=yaw#-1
- If KeyDown(PERIOD)=True Then yaw#=yaw#+1
- If KeyDown(X_KEY)=True Then roll#=roll#-1
- If KeyDown(C_KEY)=True Then roll#=roll#+1
-
- ;Rotate
- RotateEntity sphere,pitch#,yaw#,roll#
-
-
- RenderWorld
- Flip
- Wend
- End