-- Variables
red = Color.new(255,0,0)
white = Color.new(255,255,255)
green = Color.new(0,255,0)
state = 1
background = Image.load("images/background.png")
triangle = Image.load("images/triangle.png")
circle = Image.load("images/circle.png")
cross = Image.load("images/cross.png")
square = Image.load("images/square.png")
right = Image.load("images/right.png")
r = math.random(1,5)
score = 0
level = 0
--table for image
Buttons = {}
Buttons[1] = { x = 300, y = 120 }
Buttons[2] = { x = 260, y = 120 }
-- Menu Function
function menu()
screen:print(150,0, "Press X to Start", red)
screen:print(152,10, "Press O to Quit", red)
end
-- Game Function
function game()
while true do
screen:clear()
Image:blit(0,0,background )
speed = 4
screen:print(0,0, "Score :" .. score, green)
screen:print(0,10, "Level :" .. level, green)
Image:blit(Buttons[1].x,Buttons[1].y, triangle )
Image:blit(Buttons[2].x,Buttons[2].y,circle)
Buttons[1].x = Buttons[1].x - speed
Buttons[2].x = Buttons[2].x - speed
if Buttons[1].x == 0 then Buttons[1].x = 472
end
if Buttons[2].x == 0 then Buttons[2].x = 472
end
screen.waitVblankStart()
screen.flip()
end
end
while true do
pad = Controls.read()
screen:clear()
if state == 1
then menu()
end
if state == 2
then game()
end
--Menu
if state == 1 and pad:cross()
then state = state + 1 elseif state == 1 and pad:circle()
then break
end
screen.waitVblankStart()
screen.flip()
end