; CountLines Example ; ------------------ ; Requires Extended mode. Graphics3D 640,480,0,2 SetBuffer BackBuffer() SeedRnd MilliSecs() camera=CreateCamera() PositionEntity camera,0,1,-9 ; A starfield sketch that grows one random line per frame scribble=CreateLineList() EntityColor scribble,160,120,255 LineWidth scribble,2 While Not KeyDown(1) ; Space adds a burst of ten extra segments If KeyHit(57) Then For n=1 To 10 AddLine scribble,Rnd(-3,3),Rnd(-2,2),0,Rnd(-3,3),Rnd(-2,2),0 Next EndIf ; One new segment every frame keeps the sketch growing AddLine scribble,Rnd(-3,3),Rnd(-2,2),0,Rnd(-3,3),Rnd(-2,2),0 ; CountLines drives the game logic: wipe the sketch once it reaches 200 segments If CountLines(scribble)>=200 Then ClearLines scribble ; Arrow keys move the camera If KeyDown(200) Then MoveEntity camera,0,0,0.1 If KeyDown(208) Then MoveEntity camera,0,0,-0.1 If KeyDown(203) Then TurnEntity camera,0,1,0 If KeyDown(205) Then TurnEntity camera,0,-1,0 RenderWorld Text 0,0,"Arrow keys: move camera Space: add 10 segments Esc: exit" Text 0,20,"CountLines(scribble) = "+CountLines(scribble)+" (auto-clears at 200)" Flip Wend End