-----------------------------------------------------------------------------
-- Cargame Version 0.2 by Nick Kochurov (dalejrrocks)
-- E-mail: dalejrrocks@rambler.ru or nascar_sk8ing_technology@yahoo.com
-----------------------------------------------------------------------------
menu=Image.load("images/choice/menu background.png")
mouse=Image.load("images/choice/cursor.png")
selector=Image.load("images/choice/selector.png")
selx=172
sely=90
done = false
x=0
y=0
green=Color.new(0,255,0)
function mousecontrol()
screen:blit(x,y,mouse,0,0,mouse:width(),mouse:height())

if y>79 and y<114  and x> 173 and x< 309 then
screen:blit(172,88,selector)
screen:blit(x,y,mouse,0,0,mouse:width(),mouse:height())
end

if y>132 and y<150  and x> 183 and x< 264 then
screen:blit(172,127,selector)
screen:blit(x,y,mouse,0,0,mouse:width(),mouse:height())
end

if y>168 and y<186  and x> 183 and x< 220 then
screen:blit(172,163,selector)
screen:blit(x,y,mouse,0,0,mouse:width(),mouse:height())
end
if pad:cross() and y>79 and y<114  and x> 173 and x< 309 then
scr0llout()
dofile("index2.lua")
end
if pad:cross() and y>132 and y<150  and x> 183 and x< 264 then
scr0llout()
dofile("options.lua")
end



  dx = pad:analogX()
  if math.abs(dx) > 32 then
    x = x + dx / 32
  end

  dy = pad:analogY()
  if math.abs(dy) > 32 then
    y = y + dy / 32
  end

  if x<0 then
    x=0
  end

  if y<0 then
    y=0
  end

  if x>480-mouse:width() then
    x=480-mouse:width()
  end

  if y>272-mouse:height() then
    y=272-mouse:height()
  end
end
function scr0llin()
for i=0,480 do
i=i+10
screen:clear()
screen:blit(480-i,0,menu)
screen:flip()
done=true
end
end
function scr0llout()
for i=0,480 do
i=i+10
screen:clear()
screen:blit(i,0,menu)
screen:flip()
end
end
while true do
pad=Controls.read()
if done == false then
scr0llin()
end
if pad:cross() and y>168 and y<186  and x> 183 and x< 220 then
scr0llout()
break
end
screen:blit(0,0,menu)
pad = Controls.read()
mousecontrol()
screen:flip()
screen:waitVblankStart()
end