    k = 60
globals = {
-- 	camera = { x = 0, y=2.2, z=8 },
 	camera = { x = -0, y=-0, z=k },
     fov = 30,
	target = { x = -0, y=0, z=-10 },
	light0 = {   	direction = {x=0, y=0.0, z=1 }, 
				color = {x=1, y=1, z=1}, 
			},
	ambient = { x = 0, y = 0, z = 0 },
     raymarch_steps = 30,
	raymarch_shadow_steps = 4,
 	up = { x = 0, y=1, z=0 },
	sky = 0,
	shadow_scale = 1,
	isPaused = 0
	
}

output = {
	resolution = { width = 160, height=200},
	-- Allow for dithering (2)	
	dither = 0,
	-- set dither strength 30
	ditherStrength= {x=30, y=2, z=2},
	
	-- Enable c64 output
	output_type = 1, -- c64 image type
     aspect = 1,
     -- Set character set
	c64_imageType = 0, -- 0 = character set (4 colors, compressable), 1 = multicolor image 
	c64_multicolor = 1,
	-- Define the 4 colors (black, purple, white, blue)
--	index_colors = { 0,4,1,6 }
--	c64_colors = { 0,5,14,6 }
	index_colors = { 0,1,2,6 }
}


MaterialBlue = {
   color = { x=0, y=0, z=100 },
	reflection = 0.0,
	shininess = 50,
	shininess_intensity = 0 
}

MaterialRed = {
   color = { x=100, y=0, z=0 },
	reflection = 0.0,
	shininess = 50,
	shininess_intensity = 0 
}

MaterialWhite = {
   color = { x=100, y=100, z=100 },
	reflection = 0.0,
	shininess = 50,
	shininess_intensity = 0 
}

MaterialGreen = {
   color = { x=0, y=1, z=0 },
	reflection = 0.0,
	shininess = 50,
	shininess_intensity = 0 
}



MaterialBlack = {
   color = { x=0, y=0.0, z=0 },
	reflection = 0.5,
	shininess = 50,
	shininess_intensity = 0 
}




-- Init is called on start  
 

N = 6
distance = 10
frame = 0
--noFrames = 24
noFrames = 4
char = 0
curSave = 1

hasSaved = 0

text = "PRX"

charname = "char"
time = 0
function Init()

	N=512
--	sx=0.5
--	sy=0.3
	z=0
	sx=0.5
	sy=0.3
	
	sx=0.5
	sy=0.3

	for j=0,N-1 do
		tp=4*(j)/(N-1)*3.14159*2.0 -0.3 + (time/N)*3.14159 + 3.2
		for i=0,0 do 
			r = (11 - j*0.015)*1.85 + 1
			x = cos(tp)*r
			y = sin(tp)*r*1.4
			s = 1 + (7-i)*(7-i)/50
			mat = "MaterialBlue"
			kk = i+j
			if (kk%2==0) then 
				mat = "MaterialWhite" 
			end
--			mat = "MaterialBlue"
--				mat = "MaterialBlue" 
--[[			if (kk%3==1) then 
				mat = "MaterialRed" 
			end
]]--
			name = "l1"..tostring(j).."_"..tostring(i)
--			AddObject("box",name,"",mat,x,y,z, sx,sy*s,0.0,0);
			AddObject("box",name,"",mat,x,y,z, sx*s,sy*s,0.0,0);
			AddInt(-x*6.0+150);
			AddInt(y*4.0+128);
			t=360*tp/3.1459/2
			tf=(32-32*tp/3.1459/2+8)%32
			AddInt(tf);
			SetRotation(name,0,0,-t);
		end	
	end

--	AddObject("box","bl1","","MaterialBlack",10,8,-1,2,10,0,0);
--	SetRotation("bl1",0,0,60)

--	AddObject("box","bl2","","MaterialBlack",-12,8,-1,2,10,0);
--	SetRotation("bl2",0,0,-70)

	UpdateScene()

end



function UpdateScene()

  	t = ((frame)/noFrames) 

--	globals.camera.x = t*2
--	globals.target.x = t*2
	

	j=t*360

end

pos = 0x0400

function Update()
	
	frame=frame+1

	if (frame==1) then
		SaveRawData("data/rawxy.bin");
		Message("Saved");
	end

	UpdateScene()
	time=time-0.8
	ClearAllObjects();
	Init();
	
	


end
