globals = {
	camera = { x = 0.0, y=0.00, z=6.0 },
	fov = 20, 
	target = { x = 0., y=0.0, z=0 },
	up = { x=0, y=1, z=0 },
	light0 = {   	direction = {x=0, y=0, z=2 }, 
				color = {x=1, y=1, z=1}, 
			},
	light1 = {   	direction = {x=1, y=0, z=2 }, 
				color = {x=1, y=1, z=1}, 
			},
	ambient = { x = 0.4, y = 0.4, z = 0.4 },
     raymarch_steps = 80,
	raymarch_shadow_steps = 40,

	sky = 0,
	shadow_scale = 1,
	isPaused = 0
	
}



output = {
--	resolution = { width = 160, height=160},
--	resolution = { width = 320, height=160},
	resolution = { width =  8, height=8},
	output_type = 3,
--	palette_file = "images/pals.pal",
	palette = { 0,0,0  ,100, 100, 100, 200, 200, 200, 256,256,256 },
	c64_imageType = 0,
	c64_multicolor=1,
	aspect = 1,
	ditherStrength= {x=1, y=1, z=1 },
	dither = 2,
	index_colors = { 0,1 }
--	index_colors = { 0,1,2,3,4,5,6,9,10,11 }
--	index_colors = { 0,2,3,1 }
--	index_colors = { 0,2,3,1 }
--	c64_colors = { 0,1}
}


Material0 = {
   color = { x=0.2, y=0.2, z=0.2 },
	reflection = 0.0,
	shininess = 100,
	shininess_intensity = 0.0
}


Material2 = {
	color = { x=0.7, y=0.2, z=0.2 },
	reflection = 0.0,
	shininess = 40,
	shininess_intensity = 0.2

}


GroundMaterial = {
	color = { x=0.2, y=0.4, z=0.1 },
	reflection = 0.0,
	shininess = 400,
	shininess_intensity = 0 

}


-- Init is called on start  


 
function Init()


--  AddObject("cylinder","cyl1", "", "Material0", 0,0,0,    0.2,0.2, 3 )
--  AddObject("box","cyl1", "", "Material0", -0.5,0,0,    2.0,2,0.3 )

	font = "rom"
	--font = "charsets/gamecharset.flf"
	y = 0.1
	z = 0
	w = 0.1

	z = -0.0
	w = .9
	r = 0.3
	rs = 2.4
	dx=-0
--	AddObject("box","box1","","Material0", dx,0,0,rs,rs*1.5,r);
--	AddObject("perlin","box1","","Material0",  "box1", 0.2,1.45,0);

		
	if char~=25 then

	AddObject("char","char1", "", "Material2",  font, char+1,   
dx,y,-z,            -- position
0.5,0.5, 2.0,      -- width xyz 
w-0.8,0.31111,0.3111,0  -- stretch xyz
);          


--[[
	AddObject("char","char2", "", "Material2",  font, char+1,   
0,0,z,            -- position
0.6,0.5,0.5,      -- width xyz 
0.250,0.26,0.31  -- stretch xyz
);          
]]--
--	jj = sin(char+1)*10
	jj = 0
	SetRotation("char1",0,45+90,jj);

	--SetRotation("char2",0,45+90,jj);

	end

	UpdateGraphics()

end


distance = 10
frame = 0
noFrames = 32
char = 0


function UpdateGraphics()

  	t = ((frame)/noFrames)*3.14159+3.1515/2;--*2 
	r = 12
	r = 11
--	t = 0.5
--	t2 = 3.14
    t2 = t
	globals.camera.y = sin(t2)*r
	globals.camera.z = cos(t2)*r
	d0 = 0
--	globals.up.y = sin((t-3.14/2)/1.0+d0)
--	globals.up.x = cos((t-3.14/2)/1.0+d0)


--	t=t+3.14159/4
	t=t
    dt = 0
--	globals.light0.direction.x = sin(t+dt)
--	globals.light0.direction.z = cos(t+dt)



--[[	SetRotation("char1",0,(t*180+90),0);
	SetRotation("char2",0,(t*180+90),0);
	SetRotation("cyl1",0,(t*180+45)*2,0);
	t=t*3.14159*2;
	r=1
	SetPosition("char1",cos(t)*r,0,sin(t)*r);
	t=t+3.14159
	SetPosition("char2",cos(t)*r,0,sin(t)*r);
--	SetPosition("char1",0,0,0);
]]--

end


function Update()
	

	if frame == noFrames then 
		char=char+1
		frame = 0
		if char == 25 then 
			globals.isPaused = 1
--			CompressAndSaveHorizontalData(4,2, "data/data_small.bin","data/table_small.bin",1);
			SaveRawData("data/small_text.bin");
			--CompressAndSaveHorizontalData(4,1, "data/screen_sprite.bin","data/table_sprite.bin");



			Message("Files written")
			
		end
		ClearAllObjects()
		Init()
	end


--	if (frame ~= noFrames) then 
--		AddC64LineToData(0,0,3,21)
	SetLight(1,0,0,-1,1,1,1);
--    AddGameboyData(0,0,1,8);
	--if (frame>=1) then
    AddAmigaBitplaneToData(0,0,1,8,1);
	--end;
	UpdateGraphics()
	frame=frame+1

--	end
	


end
