-----------------------------------------------------------------------------
-- Cargame Version 0.2 by Nick Kochurov (dalejrrocks)
-- E-mail: dalejrrocks@rambler.ru or nascar_sk8ing_technology@yahoo.com
-----------------------------------------------------------------------------

explode={}
for g=1,14 do
  explode[g]=Image.load("images/explode/grenade"..g..".png")
end
bang={}
for h=1,8 do
  bang[h]=Image.load("images/explode/bang"..h..".png")
end


exp=0
exp2=0
h=1
g=1
three = 0
three2 = 0
sx=0
sy=0
sx2=225
sy2=200
sx3=215
sy3=110
sx4=220
sy4=115
sx5=210
sy5=115
blue=Color.new(0,0,255)
purple=Color.new(255,0,255)
red=Color.new(255,0,0)
yellow=Color.new(255,255,0)

proportional = Font.createMonoSpaced()
proportional:setPixelSizes(0, 48)
h1d = false
countdowncomplete = false
green=Color.new(0,255,0)
p1w=Image.load("images/win/wina.png")
countdown = Timer.new()
countdown:reset()
function letsexplode()
if countdowncomplete == false then
screen:clear()
screen:blit(0,0,p1w)
screen:blit(225,200,blowitup)
countdown:start()
if countdown:time() > 0 and countdown:time() < 1000 then
screen:fontPrint(proportional, 225, 150, "3...", purple)
end
if countdown:time() > 1000 and countdown:time() < 2000 then
screen:fontPrint(proportional, 225, 150, "2..", blue)
end
if countdown:time() > 2000 and countdown:time() < 3000 then
screen:fontPrint(proportional, 225, 150, "1.", yellow)
end
if countdown:time() > 3000 and countdown:time() < 4000 then
screen:fontPrint(proportional, 140, 150, "You Lose!", red)
end
if countdown:time() > 4000 then
countdown:stop()
countdown:reset()
countdowncomplete = true
end
screen:flip()
screen:waitVblankStart()
end

if countdowncomplete == true then
screen:clear()
if sx < 5 then
sx = sx + 1
end
if sx == 5 then
sx = 0
end
if sy < 5 then
sy = sy + 1
end
if sy == 5 then
sy = 0
end

if sx2 < 233 then
sx2 = sx2 + 1
end
if sx2 == 233 then
sx2 = 225
end
if sy2 < 208 then
sy2 = sy2 + 1
end
if sy2 == 208 then
sy2 = 200
end

if sx3 < 225 then
sx3 = sx3 + 1
end
if sx3 == 225 then
sx3 = 215
end
if sy3 < 120 then
sy3 = sy3 + 1
end
if sy3 == 120 then
sy3 = 110
end
  
if sx4 < 230 then
sx4 = sx4 + 1
end
if sx4 == 230 then
sx4 = 220
end
if sy4 < 125 then
sy4 = sy4 + 1
end
if sy4 == 125 then
sy4 = 115
end

if sx5 < 220 then
sx5 = sx5 + 1
end
if sx5 == 220 then
sx5 = 210
end
if sy5 < 125 then
sy5 = sy5 + 1
end
if sy5 == 125 then
sy5 = 115
end

if exp < 65 then
exp=exp+1
end
if exp == 25 and three < 2 then
exp=0
end
if exp2 < 40 then
exp2=exp2+1
end
if exp2 == 35 and three2 < 2 then
exp2=0
end
screen:blit(sx,sy,p1w)
screen:blit(sx2,sy2,blowitup)
screen:blit(sx3,sy3,explode[g])
if h1d == true then

screen:blit(220,115,explode[g])
screen:blit(210,115,explode[g])
end
screen:blit(sx3-5,170,bang[h])
if exp2 == 0 then
h=1
end
if exp2 == 5 then
h=2
end
if exp2 == 10 then
h=3
end
if exp2 == 15 then
h=4
end
if exp2 == 20 then
h=5
end
if exp2 == 25 then
h=6
end
if exp2 == 30 then
three2 = three2 + 1
h=7
end
if exp2 == 35 then
h=8
end
if exp == 0 then
g=1
end
if exp == 5 then
g=2
end
if exp == 10 then
g=3
end
if exp == 15 then
g=4
end
if exp == 20 then
g=5
three = three + 1
end
if exp == 25 then
g=6
end
if exp == 30 then
g=7
h1d = true
g=1
end
if exp == 35 then
g=8
end
if exp == 40 then
g=9
end
if exp == 45 then
g=10
end
if exp == 50 then
g=11
end
if exp == 55 then
g=12
end
if exp == 60 then
g=13
end
if exp == 65 then
g=14
end
screen:flip()
screen:waitVblankStart()
end
end

while true do
while g ~= 14 do
letsexplode()
end
if Controls.read():start() then
break
end
screen:blit(0,0,p1w)
screen:blit(225,200,blowitup)
screen:blit(215,110,explode[g])
end