background = Image.load("Astroid_Escape/Images/menu.png")
font_color = 0
current = 1
oldpad = Controls.read()

function printCentered(y,text,color)
local length = string.len(text)
local x = 240 - ((length*8)/2)
screen:print(x,y,text,color)
end

while true do
pad = Controls.read()
screen:clear()
screen:blit(0,0,background)
font_color = font_color + 1
printCentered(170, "New Game", red)
printCentered(190, "Free Play", red)

if pad:down() and oldpad:down() ~= pad:down() then
current = current + 1
end

if pad:up() and oldpad:up() ~= pad:up() then
current = current - 1
end

if pad:circle() and oldpad:circle() ~= pad:circle() then
dofile("Astroid_Escape/astroids.lua")
end

if current == 0 then
current = 2
end

if current == 1 and font_color <= 4 then
printCentered(170, "New Game", blue)
	if pad:cross() and oldpad:cross() ~= pad:cross() then
	dofile("Astroid_Escape/1_1.lua")
	end
end

if current == 1 and font_color > 4 then
printCentered(170, "New Game", white)
	if pad:cross() and oldpad:cross() ~= pad:cross() then
	dofile("Astroid_Escape/1_1.lua")
	end
end

if current == 2 and font_color <= 4 then
printCentered(190, "Free Play", blue)
	if pad:cross() and oldpad:cross() ~= pad:cross() then
	dofile("Astroid_Escape/free_play.lua")
	end
end

if current == 2 and font_color > 4 then
printCentered(190, "Free Play", white)
	if pad:cross() and oldpad:cross() ~= pad:cross() then
	dofile("Astroid_Escape/free_play.lua")
	end
end

if current >= 3 then
current = 1
end

if font_color > 8 then
font_color = 0
end

screen.waitVblankStart()
screen.flip()
oldpad = pad
end