home *** CD-ROM | disk | FTP | other *** search
- ;demo01-01.bb - Jumping Cone, your first program!
- ;---------------------------------------
-
- ;Set up the graphics
- Graphics3D 640, 480
- SetBuffer BackBuffer()
-
- ;Define constants
- Const ESC_KEY = 1
- Const UP_KEY = 200
- Const DOWN_KEY = 208
-
- ;Define variables
- camdistance = 10
- type_player = 1
- type_ground = 2
-
- ;track the position and jump of the cone
- velocity# = 0
-
- ;Create the camera, which is what the user sees
- camera=CreateCamera()
- RotateEntity camera, 45, 0, 0
-
- ;Create the light, so the user can see!
- light=CreateLight()
-
- ;Create a plane and texture, the actual objects on the screen
- ;Create texture
- grid_text = CreateTexture(32, 32, 8)
- ScaleTexture(grid_text, 10, 10)
-
- ;Draw the texture, and reset the drawing back to the main screen
- SetBuffer TextureBuffer(grid_text)
-
- ;Create two rectangles
- Color 0,0,64
- Rect 0,0,32,32
- Color 0,0,255
- Rect 0,0,32,32
-
- SetBuffer BackBuffer()
-
- ;Create the plane
- grid_plane = CreatePlane()
-
-
- CreateMirror()
-
- HandleEntities(grid_plane, grid_text)
-
- ;Create a cone
- cone = CreateCone(64)
- EntityType cone, type_player
- PositionEntity cone, 0, 1, 5
- ScaleEntity cone, 0.4, 0.4, 0.4
- EntityRadius cone, 0.5
-
- ;Create texture for the cone
- texture = CreateTexture(16,16):SetBuffer TextureBuffer(texture)
- ClsColor 256, 6, 56
- Cls
- ;assign a color for the texture
- Color 12, 126, 256
- Rect 0, 0, 8, 8, 1
- Rect 8, 8, 8, 8, 1
- ScaleTexture texture, .2, .2
- ;put the texture on the cone
- EntityTexture cone, texture
-
- ;MAIN LOOP
- While Not KeyDown(ESC_KEY)
-
-
-
- ;Handle User Input
- If KeyDown(UP_KEY)
- velocity = velocity - .001
- EndIf
- If KeyDown(DOWN_KEY)
- velocity = velocity + 0.001
- EndIf
- ;Move the cone and camera around to see everything
- MoveEntity cone, 0, velocity, 0
- TranslateEntity cone, 0, -0.03, 0
- PositionEntity camera, EntityX(cone), 0, EntityZ(cone)
- MoveEntity camera, 0, 0, -5
-
- ;Test for collisions so things can't go through walls
- Collisions type_player, type_ground, 2, 2
- Collisions type_ground, type_player, 2, 2
-
- UpdateWorld
- RenderWorld
- Flip
-
- Wend ;END MAIN LOOPS
-
- End ;End of the program
-
-
- ;FUNCTIONS
-
- ;Function HandleEntities() - this function assigns the texture to the grid plane and deals with Entities
- Function HandleEntities(grid_plane, grid_text)
- ;Make texture and plane appear on screen
-
- EntityTexture grid_plane, grid_text
- EntityBlend grid_plane, 1
- EntityAlpha grid_plane, .6
- EntityFX grid_plane, 1
- EntityType grid_plane, type_ground
-
- End Function