#Include "Ninfa3d.bi"

dim Shared camera As nCAMERA
dim light01 As nLIGHT
Dim pivot As nMESH
Dim chopper As nMESH
Dim sprite As nSPRITE

'Enable vertical synch.
EnableVsync()

'Starts the Ninfa3D Engine
InitEngine(640,480,32,0)
	BackGroundColor(128,128,128)'Background Color
	AmbientLight(64,64,64)'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,1)
	PositionEntity(camera,0,128,-256)' Position

pivot = CreateMeshNull()'Creates an empty mesh is used as the pivot.

Dim As nFONT font01 = LoadFont("media\courier.xml")'Load the font, in format XML

'Creates the lights
light01 = CreateLight(LGT_POINT)
	EntityParent(light01,pivot)
	LightCastShadow(light01)'It makes the light cast shadows.
	PositionEntity(light01,0,128,256)' Position
	LightRadius(light01,256)' Radius of the light
	
sprite = LoadSprite("media/glow.bmp")
	EntityParent(sprite,light01)
	ScaleSprite(sprite,30,30)

CreateGround()'Creates the test area

Dim As UInteger Ptr writeFile = CreateWriteFile("casa.txt")

	Dim As String oldString1 = "Hola vaya casa de lokos..!!!!"
	Dim As String oldString2 = "Hola."
	WriteCHAR(writeFile,oldString1)
	WriteCHAR(writeFile,oldString2)
	'Dim As single oldSingle = 1334567890.1234567890
	'WriteFLOAT(writeFile,oldSingle)

	'Dim As integer oldInteger = 1334567890
	'WriteINT(writeFile,oldInteger)

CloseWrite(writeFile)

Dim As UInteger Ptr readFile = CreateOpenFile("casa.txt")

'Dim As zString Ptr newString1 = ReadCHAR(readFile)
'Dim As zString Ptr newString2 = ReadCHAR(readFile)

CloseRead(readFile)

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()

	Font(font01)'assign the font to use
	'Text(100,100,newString1)
	'Text(100,150,newString2)
	'End the scene
	EndScene()
	
Wend

'Ends Ninfa3D Engine
EndEngine()