; CreateSprite Example ; -------------------- Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,1,-5 light=CreateLight() RotateEntity light,45,45,0 ground=CreatePlane() EntityTexture ground,LoadTexture("media/MossyGround.BMP") SeedRnd MilliSecs() ; A campfire built from ember sprites. CreateSprite makes a flat ; two-triangle quad that always faces the camera - cheap enough ; to use by the dozen for particle effects like this. Dim ember(15) Dim rise#(15) For i=0 To 15 ember(i)=CreateSprite() ScaleSprite ember(i),0.15,0.15 EntityColor ember(i),255,Rand(80,180),30 ; Additive blending makes the embers glow EntityBlend ember(i),3 rise(i)=Rnd(0.01,0.04) PositionEntity ember(i),Rnd(-0.5,0.5),Rnd(0,2.5),Rnd(-0.5,0.5) Next While Not KeyDown(1) ; Drift each ember upwards and recycle it at the top For i=0 To 15 MoveEntity ember(i),Rnd(-0.01,0.01),rise(i),0 If EntityY(ember(i))>2.5 Then PositionEntity ember(i),Rnd(-0.5,0.5),0,Rnd(-0.5,0.5) Next ; 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,"Arrows: move camera Esc: exit" Text 0,20,"CreateSprite made 16 ember particles - orbit them: they always face you" Flip Wend End