-----------------------------------------------------------------------------
-- Cargame Version 0.2 by Nick Kochurov (dalejrrocks)
-- E-mail: dalejrrocks@rambler.ru or nascar_sk8ing_technology@yahoo.com
-----------------------------------------------------------------------------
--load pictures
green=Color.new(0,255,0)
white = Color.new(255,255,255)
screen:clear()
car=Image.load("images/cars/car.png")
car1=Image.load("images/cars/car (1).png")
car2=Image.load("images/cars/car (2).png")
car3=Image.load("images/cars/car (3).png")
car4=Image.load("images/cars/car (4).png")
car5=Image.load("images/cars/car (5).png")
car6=Image.load("images/cars/car (6).png")
car7=Image.load("images/cars/car (7).png")
car8=Image.load("images/cars/car (8).png")
car9=Image.load("images/cars/car (9).png")
car10=Image.load("images/cars/car (10).png")
car11=Image.load("images/cars/car (11).png")
screen:print(220,135,"Loading",white)
screen:print(275,135,".",green)
screen:flip()
screen:waitVblankStart()
screen:clear()
car12=Image.load("images/cars/car (12).png")
car13=Image.load("images/cars/car (13).png")
car14=Image.load("images/cars/car (14).png")
car15=Image.load("images/cars/car (15).png")
car16=Image.load("images/cars/car (16).png")
car17=Image.load("images/cars/car (17).png")
car18=Image.load("images/cars/car (18).png")
car19=Image.load("images/cars/car (19).png")
car20=Image.load("images/cars/car (20).png")
car21=Image.load("images/cars/car (21).png")
car22=Image.load("images/cars/car (22).png")
car23=Image.load("images/cars/car (23).png")
car24=Image.load("images/cars/car (24).png")
car25=Image.load("images/cars/car (25).png")
chooseone=Image.load("images/choice/chooseone.png")
choosetwo=Image.load("images/choice/choosetwo.png")
screen:print(220,135,"Loading",white)
screen:print(275,135,"..",green)
screen:flip()
screen:waitVblankStart()
screen:clear()
car26=Image.load("images/cars/car (26).png")
car27=Image.load("images/cars/car (27).png")
car28=Image.load("images/cars/car (28).png")
car29=Image.load("images/cars/car (29).png")
car30=Image.load("images/cars/car (30).png")
car31=Image.load("images/cars/car (31).png")
car32=Image.load("images/cars/car (32).png")
car33=Image.load("images/cars/car (33).png")
screen:print(220,135,"Loading",white)
screen:print(275,135,"...",green)
screen:flip()
screen:waitVblankStart()
screen:clear()
screen:print(220,135,"Loading",white)
screen:print(275,135,"....",green)
screen:flip()
screen:waitVblankStart()
confirm1p=Image.load("images/choice/confirm1.png")
confirm2p=Image.load("images/choice/confirm2.png")
bluebox=Image.load("images/choice/bluebox.png")
car40=Image.load("images/cars/car (40).png")
car41=Image.load("images/cars/car (41).png")
car42=Image.load("images/cars/car (42).png")
car43=Image.load("images/cars/car (43).png")
car34=Image.load("images/cars/car (34).png")
car35=Image.load("images/cars/car (35).png")
car36=Image.load("images/cars/car (36).png")
car37=Image.load("images/cars/car (37).png")
car38=Image.load("images/cars/car (38).png")
car39=Image.load("images/cars/car (39).png")
screen:clear()
screen:print(220,135,"Loading",white)
screen:print(280,135,"done!",green)
screen:flip()
screen:waitVblankStart()
--variables
boxx=79
boxy=109
boxx2=79
boxy2=109
lastpicu=carup
lastpic2u=carup
p1chosen = false
p2chosen = false
confirmed1 = false
confirmed2 = false
confirmed1no = false
confirmed2no = false
--allow player 1 to pick a car
function choosep1()
screen:blit(0,0,chooseone)
screen:blit(80,110,car2)
screen:blit(110,110,car3)
screen:blit(140,110,car4)
screen:blit(170,110,car5)
screen:blit(200,110,car6)
screen:blit(230,110,car7)
screen:blit(260,110,car8)
screen:blit(290,110,car9)
screen:blit(320,110,car10)
screen:blit(350,110,car11)
screen:blit(380,110,car)
screen:blit(80,150,car14)
screen:blit(110,150,car15)
screen:blit(140,150,car16)
screen:blit(170,150,car17)
screen:blit(200,150,car18)
screen:blit(230,150,car19)
screen:blit(260,150,car20)
screen:blit(290,150,car21)
screen:blit(320,150,car22)
screen:blit(350,150,car23)
screen:blit(380,150,car24)
screen:blit(80,190,car27)
screen:blit(110,190,car28)
screen:blit(140,190,car29)
screen:blit(170,190,car30)
screen:blit(200,190,car31)
screen:blit(230,190,car32)
screen:blit(260,190,car33)
screen:blit(290,190,car34)
screen:blit(320,190,car35)
screen:blit(350,190,car36)
screen:blit(380,190,car37)
screen:blit(80,230,car1)
screen:blit(110,230,car12)
screen:blit(140,230,car13)
screen:blit(170,230,car25)
screen:blit(200,230,car26)
screen:blit(230,230,car38)
screen:blit(260,230,car39)
screen:blit(290,230,car40)
screen:blit(320,230,car41)
screen:blit(350,230,car42)
screen:blit(380,230,car43)
screen:blit(boxx,boxy,bluebox)
if Controls.read():right() and boxx < 379 then
boxx=boxx+30
end
if Controls.read():left() and boxx > 79 then
boxx=boxx-30
end
if Controls.read():down() and boxy < 229 then
boxy=boxy+40
end
if Controls.read():up() and boxy > 109 then
boxy=boxy-40
end
end
--get player 1`s choice and set car pictures
function choice1()
--1st Row
if boxy==109 then
if Controls.read():cross() then
if boxx == 79 then
lastpicu=car2
p1chosen = true
end
if boxx == 109 then
lastpicu=car3
p1chosen = true
end
if boxx == 139 then
lastpicu=car4
p1chosen = true
end
if boxx == 169 then
lastpicu=car5
p1chosen = true
end
if boxx == 199 then
lastpicu=car6
p1chosen = true
end
if boxx == 229 then
lastpicu=car7
p1chosen = true
end
if boxx == 259 then
lastpicu=car8
p1chosen = true
end
if boxx == 289 then
lastpicu=car9
p1chosen = true
end
if boxx == 319 then
lastpicu=car10
p1chosen = true
end
if boxx == 349 then
lastpicu=car11
p1chosen = true
end
if boxx == 379 then
lastpicu=car
p1chosen = true
end
end
end
--2nd Row
if boxy == 149 then
if Controls.read():cross() then
if boxx == 79 then
lastpicu=car14
p1chosen = true
end
if boxx == 109 then
lastpicu=car15
p1chosen = true
end

if boxx == 139 then
lastpicu=car16
p1chosen = true
end
if boxx == 169 then
lastpicu=car17
p1chosen = true
end
if boxx == 199 then
lastpicu=car18
p1chosen = true
end
if boxx == 229 then
lastpicu=car19
p1chosen = true
end
if boxx == 259 then
lastpicu=car20
p1chosen = true
end
if boxx == 289 then
lastpicu=car21
p1chosen = true
end
if boxx == 319 then
lastpicu=car22
p1chosen = true
end
if boxx == 349 then
lastpicu=car23
p1chosen = true
end
if boxx == 379 then
lastpicu=car24
p1chosen = true
end
end
end
--3rd Row
if boxy == 189 then
if Controls.read():cross() then
if boxx == 79 then
lastpicu=car27
p1chosen = true
end
if boxx == 109 then
lastpicu=car28
p1chosen = true
end

if boxx == 139 then
lastpicu=car29
p1chosen = true
end
if boxx == 169 then
lastpicu=car30
p1chosen = true
end
if boxx == 199 then
lastpicu=car31
p1chosen = true
end
if boxx == 229 then
lastpicu=car32
p1chosen = true
end
if boxx == 259 then
lastpicu=car33
p1chosen = true
end
if boxx == 289 then
lastpicu=car34
p1chosen = true
end
if boxx == 319 then
lastpicu=car35
p1chosen = true
end
if boxx == 349 then
lastpicu=car36
p1chosen = true
end
if boxx == 379 then
lastpicu=car37
p1chosen = true
end
end
end
--4th Row
if boxy == 229 then
if Controls.read():cross() then
if boxx == 79 then
lastpicu=car1
p1chosen = true
end
if boxx == 109 then
lastpicu=car12
p1chosen = true
end

if boxx == 139 then
lastpicu=car13
p1chosen = true
end
if boxx == 169 then
lastpicu=car25
p1chosen = true
end
if boxx == 199 then
lastpicu=car26
p1chosen = true
end
if boxx == 229 then
lastpicu=car38
p1chosen = true
end
if boxx == 259 then
lastpicu=car39
p1chosen = true
end
if boxx == 289 then
lastpicu=car40
p1chosen = true
end
if boxx == 319 then
lastpicu=car41
p1chosen = true
end
if boxx == 349 then
lastpicu=car42
p1chosen = true
end
if boxx == 379 then
lastpicu=car43
p1chosen = true
end
end
end
end
--confirm player 1`s choice or allow player 1 to pick another car
function confirm1()
screen:blit(0,0,confirm1p)
screen:blit(225,115,lastpicu)
screen:blit(224,114,bluebox)
if Controls.read():circle() then
confirmed1 = true
end
if Controls.read():triangle() then
p1chosen = false
end
end
--allow player 2 to pick a car
function choosep2()
screen:blit(0,0,choosetwo)
screen:blit(80,110,car2)
screen:blit(110,110,car3)
screen:blit(140,110,car4)
screen:blit(170,110,car5)
screen:blit(200,110,car6)
screen:blit(230,110,car7)
screen:blit(260,110,car8)
screen:blit(290,110,car9)
screen:blit(320,110,car10)
screen:blit(350,110,car11)
screen:blit(380,110,car)
screen:blit(80,150,car14)
screen:blit(110,150,car15)
screen:blit(140,150,car16)
screen:blit(170,150,car17)
screen:blit(200,150,car18)
screen:blit(230,150,car19)
screen:blit(260,150,car20)
screen:blit(290,150,car21)
screen:blit(320,150,car22)
screen:blit(350,150,car23)
screen:blit(380,150,car24)
screen:blit(80,190,car27)
screen:blit(110,190,car28)
screen:blit(140,190,car29)
screen:blit(170,190,car30)
screen:blit(200,190,car31)
screen:blit(230,190,car32)
screen:blit(260,190,car33)
screen:blit(290,190,car34)
screen:blit(320,190,car35)
screen:blit(350,190,car36)
screen:blit(380,190,car37)
screen:blit(80,230,car1)
screen:blit(110,230,car12)
screen:blit(140,230,car13)
screen:blit(170,230,car25)
screen:blit(200,230,car26)
screen:blit(230,230,car38)
screen:blit(260,230,car39)
screen:blit(290,230,car40)
screen:blit(320,230,car41)
screen:blit(350,230,car42)
screen:blit(380,230,car43)
screen:blit(boxx2,boxy2,bluebox)
if Controls.read():right() and boxx2 < 379 then
boxx2=boxx2+30
end
if Controls.read():left() and boxx2 > 79 then
boxx2=boxx2-30
end
if Controls.read():down() and boxy2 < 229 then
boxy2=boxy2+40
end
if Controls.read():up() and boxy2 > 109 then
boxy2=boxy2-40
end
end
--get player 2`s choice and set car pictures
function choice2()
if boxy2==109 then
if Controls.read():cross() then
if boxx2 == 79 then
lastpic2u=car2
p2chosen = true
end
if boxx2 == 109 then
lastpic2u=car3
p2chosen = true
end
if boxx2 == 139 then
lastpic2u=car4
p2chosen = true
end
if boxx2 == 169 then
lastpic2u=car5
p2chosen = true
end
if boxx2 == 199 then
lastpic2u=car6
p2chosen = true
end
if boxx2 == 229 then
lastpic2u=car7
p2chosen = true
end
if boxx2 == 259 then
lastpic2u=car8
p2chosen = true
end
if boxx2 == 289 then
lastpic2u=car9
p2chosen = true
end
if boxx2 == 319 then
lastpic2u=car10
p2chosen = true
end
if boxx2 == 349 then
lastpic2u=car11
p2chosen = true
end
if boxx2 == 379 then
lastpic2u=car
p2chosen = true
end
end
end
--2nd Row
if boxy2 == 149 then
if Controls.read():cross() then
if boxx2 == 79 then
lastpic2u=car14
p2chosen = true
end
if boxx2 == 109 then
lastpic2u=car15
p2chosen = true
end

if boxx2 == 139 then
lastpic2u=car16
p2chosen = true
end
if boxx2 == 169 then
lastpic2u=car17
p2chosen = true
end
if boxx2 == 199 then
lastpic2u=car18
p2chosen = true
end
if boxx2 == 229 then
lastpic2u=car19
p2chosen = true
end
if boxx2 == 259 then
lastpic2u=car20
p2chosen = true
end
if boxx2 == 289 then
lastpic2u=car21
p2chosen = true
end
if boxx2 == 319 then
lastpic2u=car22
p2chosen = true
end
if boxx2 == 349 then
lastpic2u=car23
p2chosen = true
end
if boxx2 == 379 then
lastpic2u=car24
p2chosen = true
end
end
end
--3rd Row
if boxy2 == 189 then
if Controls.read():cross() then
if boxx2 == 79 then
lastpic2u=car27
p2chosen = true
end
if boxx2 == 109 then
lastpic2u=car28
p2chosen = true
end

if boxx2 == 139 then
lastpic2u=car29
p2chosen = true
end
if boxx2 == 169 then
lastpic2u=car30
p2chosen = true
end
if boxx2 == 199 then
lastpic2u=car31
p2chosen = true
end
if boxx2 == 229 then
lastpic2u=car32
p2chosen = true
end
if boxx2 == 259 then
lastpic2u=car33
p2chosen = true
end
if boxx2 == 289 then
lastpic2u=car34
p2chosen = true
end
if boxx2 == 319 then
lastpic2u=car35
p2chosen = true
end
if boxx2 == 349 then
lastpic2u=car36
p2chosen = true
end
if boxx2 == 379 then
lastpic2u=car37
p2chosen = true
end
end
end
--4th Row
if boxy2 == 229 then
if Controls.read():cross() then
if boxx2 == 79 then
lastpic2u=car1
p2chosen = true
end
if boxx2 == 109 then
lastpic2u=car12
p2chosen = true
end

if boxx2 == 139 then
lastpic2u=car13
p2chosen = true
end
if boxx2 == 169 then
lastpic2u=car25
p2chosen = true
end
if boxx2 == 199 then
lastpic2u=car26
p2chosen = true
end
if boxx2 == 229 then
lastpic2u=car38
p2chosen = true
end
if boxx2 == 259 then
lastpic2u=car39
p2chosen = true
end
if boxx2 == 289 then
lastpic2u=car40
p2chosen = true
end
if boxx2 == 319 then
lastpic2u=car41
p2chosen = true
end
if boxx2 == 349 then
lastpic2u=car42
p2chosen = true
end
if boxx2 == 379 then
lastpic2u=car43
p2chosen = true
end
end
end
end
--end
--confirm player 2`s choice or allow player 1 to pick another car
function confirm2()
screen:blit(0,0,confirm2p)
screen:blit(225,115,lastpic2u)
screen:blit(224,114,bluebox)
if Controls.read():circle() then
confirmed2 = true
end
if Controls.read():triangle() then
p2chosen = false
end
end
--main loop
while true do
--player 1 picks a car
if p1chosen == false then
choosep1()
choice1()
end
--confirm player 1`s choice
if p1chosen == true and confirmed1 == false then
confirm1()
end
--player 2 picks a car
if p1chosen == true and confirmed1 == true then
choosep2()
choice2()
end
--confirm player 2`s choice
if p2chosen == true and confirmed2 == false then
confirm2()
end
--start the race!
if p2chosen == true and confirmed2 == true then
dofile("index1.lua")
end
--exit to Lowser/Lua Os
if Controls.read():start() then
break
end
screen:flip()
screen:waitVblankStart()
end --end of code:675