tutorials/beginner
12_first3d.abs
45 lines of ArcBasic. Words in colour that are commands link to their help page. To run it, download ArcBasic, open the file and press F5.
; A first look at 3DGraphics3D 640, 480SetBuffer BackBuffer(); a camera to look through, and a light to see bycamera = CreateCamera()PositionEntity camera, 0, 3.5, -8TurnEntity camera, 15, 0, 0 ; look down a littlelight = CreateLight()RotateEntity light, 50, 30, 0; the ground, a cube and a ballground = CreatePlane()EntityColor ground, 80, 160, 80cube = CreateCube()PositionEntity cube, -3, 1, 0EntityColor cube, 255, 120, 60ball = CreateSphere(24)EntityColor ball, 80, 160, 255; a ready-made character from the media folder, playing its "idle" animationhero = LoadAnimMesh("../../media/kenney/mini-characters/character-knight.glb")ScaleEntity hero, 3, 3, 3PositionEntity hero, 3, 0, 0TurnEntity hero, 0, 180, 0Animate hero, 1, 1, FindAnimSeq(hero, "idle")While Not KeyHit(1) ; arrows walk the camera about If KeyDown(203) Then TurnEntity camera, 0, 2, 0 If KeyDown(205) Then TurnEntity camera, 0, -2, 0 If KeyDown(200) Then MoveEntity camera, 0, 0, 0.1 If KeyDown(208) Then MoveEntity camera, 0, 0, -0.1 TurnEntity cube, 1, 2, 0 ; spin the cube a little every frame PositionEntity ball, 0, 1 + Abs(Sin(MilliSecs() / 4)) * 2, 0 ; bounce the ball UpdateWorld ; animations (and physics, collisions) move on RenderWorld ; draw the 3D world from the camera Text 10, 10, "Arrows move the camera. Escape quits." FlipWendEnd
