0,]']>S}Wup8d%qy)6o;]AsVl3 500 and (key() or left or middle or right) then intro = false reset() end end function show_game_over() cls(0) print("GAME OVER", 15, 55, 12, true, 4) print("Press any key to restart", 15, 100, 12, true, 1) local x,y,left,middle,right,scrollx,scrolly=mouse() if key() or left or middle or right then reset() end end function main() local x,y,left,middle,right,scrollx,scrolly=mouse() -- sketchy handling of the mouse button if left then if last then left = false else last = true end else last = false end -- backround colors cls(3) -- clear screen rect(0,128,240,10,4) -- zone for the score line(0, 128, 240, 128, 12) -- draw the line for i = 0,7 do local s = snakes[i] line(0, s.y, 240, s.y, 12) local idx = 2*((t // 10) % 4) if s.x > 220 then idx = idx + 40 end spr(idx, s.x, s.y, 15,1, 0,0, 2,2) if left and checkCollision(s, x, y) then s.x = -16 s.speed = speed() hit = hit + 1 mslh = 0 end s.x = s.x + s.speed if s.x > 240 then s.x = -16 s.speed = speed() miss = miss + 1 mslh = mslh + 1 if mslh >= 5 then game_over = true -- game over end end end print(string.format("hit = %d", hit), 30, 130, 7) print(string.format("miss = %d", miss), 90, 130, 9) rectb(180,130,32,5,1) rect(181,131,5*mslh,3,2) t = t+1 end function checkCollision(snake, x, y) if x < snake.x then return false end if y < snake.y then return false end if x > (snake.x + 16) then return false end if y > (snake.y + 16) then return false end return true end