#Include "Ninfa3d.bi"

dim Shared camera As nCAMERA
dim As nLIGHT light01 
Dim As nMESH dwarf,ant,ninja,zombie
Dim As nSPRITE sprite
Dim As nTEXTURE tex01,tex02

'Enable vertical synch.
EnableVsync()

'Starts the Ninfa3D Engine
InitEngine(640,480,32,0)
	BackGroundColor(128,128,128)'Background Color
	AmbientLight(32,32,32)'Ambient color

'Include the file "SampleFuntions.bi.
'It contains useful features, such as drawing the interface and create the test area.
#Include "SampleFunctions.bi"

'Create a camera
camera = CreateCameraFPS(100,0.25)
	PositionEntity(camera,0,64,256)' Position

'Creates the lights
light01 = CreateLight(LGT_POINT)
    lightradius(light01,200)
	PositionEntity(light01,0,128,128)' Position
	LightCastShadow(light01)
    
sprite = LoadSprite("media/glow.bmp")
	EntityParent(sprite,light01)
	ScaleSprite(sprite,30,30)

CreateGround()'Creates the test area

'Load mesh.
tex01 = LoadTexture("media\ant1.jpg")'Load texture
ant = LoadMesh("media\ant01.b3d")
	EntityTexture(ant,tex01,0)
	AnimateMesh(ant,1,30,1,9,1)'Animate the mesh
	PositionEntity(ant,-100,0,0)
	ScaleMesh(ant,5,5,5)
    MeshCastShadow(ant)
	
tex02 = LoadTexture("media\nskinrd.jpg")
ninja = LoadMesh("media\ninja.b3d")
	EntityTexture(ninja,tex02,0)
	AnimateMesh(ninja,1,15,1,300,1)'Animate the mesh
	PositionEntity(ninja,0,0,0)
	ScaleMesh(ninja,5,5,5)
    MeshCastShadow(ninja)

dwarf = LoadMesh("media\dwarf2.b3d")
	AnimateMesh(dwarf,1,15,1,30,1)'Animate the mesh
	PositionEntity(dwarf,150,0,0)'Move the mesh
    MeshCastShadow(dwarf)
	
zombie = LoadMesh("media\zombie.b3d")
	AnimateMesh(zombie,1,15,1,200,1)'Animate the mesh
	PositionEntity(zombie,75,0,0)'Move the mesh
	RotateEntity(zombie,0,180,0)
	ScaleMesh(zombie,2.5,2.5,2.5)
    MeshCastShadow(zombie)
	
While(EngineRun)'Returns 1 if the engine is running.

	'Begins scene
	BeginScene()

	'By pressing the "ESCAPE" closes the engine.
	If KeyHit(KEY_ESCAPE) Then CloseEngine()

	'Update the Engine.
	'Changing the value (only affects the physics) that will update the
	'Physical faster or slower.
	UpdateEngine(0)

	'Displays the interface (FPS and triangles)
	Interface()

	'End the scene
	EndScene()

Wend

'Ends Ninfa3D Engine
EndEngine()