; CreateDecal Example ; ------------------- ; Requires Extended mode. Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,0,-6 light=CreateLight() RotateEntity light,45,45,0 ; A wall to shoot paint splats at wall=CreateCube() ScaleEntity wall,4,2.5,0.2 PositionEntity wall,0,0,3 EntityColor wall,110,120,135 ; Paint an orange splat texture in memory splat=CreateTexture(64,64,3) SetBuffer TextureBuffer(splat) ClsColor 0,0,0 Cls Color 255,80,20 Oval 6,6,52,52,True SetBuffer BackBuffer() Color 255,255,255 ; The aiming reticle sweeps across the wall on its own sight=CreateSphere() ScaleEntity sight,0.1,0.1,0.1 EntityColor sight,255,255,0 While Not KeyDown(1) ; Sweep the reticle over the wall face angle#=angle+2 aim_x#=3*Sin(angle) aim_y#=1.5*Sin(angle*1.7) PositionEntity sight,aim_x,aim_y,2.6 ; Space fires: CreateDecal makes a projector entity that stamps the wall If KeyHit(57) Then decal=CreateDecal(splat) PositionEntity decal,aim_x,aim_y,2.8 shots=shots+1 EndIf ; 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: fire paint splat Esc: exit" Text 0,20,"CreateDecal(splat) called "+shots+" times - each decal is an ordinary entity" Flip Wend End