0,]']±>Sï}WÿÍu§ðp8·d%qy)6o;]ÉA¦ösï÷ôôô”°ÂVl†3 0.3 then spr(Player.frames[1], Player.x, Player.y, 0) elseif Player.vel < -0.3 then spr(Player.frames[3], Player.x, Player.y, 0) else spr(Player.frames[2], Player.x, Player.y, 0) end spr(Jetpack.frame(), Player.x, Player.y + 8, 0) end -- Pipes data local Pipes = {frame = 260, active = {}} function new_pipe(x) local p = {} p.x = x p.y = math.random(16, HEIGHT - 32) p.score = true table.insert(Pipes.active, p) end -- Helper function function AABB(box1_x, box1_y, box1_width, box1_height, box2_x, box2_y, box2_width, box2_height) return box1_x < box2_x + box2_width and box1_x + box1_width > box2_x and box1_y < box2_y + box2_height and box1_y + box1_height > box2_y end -- Create background 30, 17 function new_background() -- Create back for x = 1, 30 * 8, 1 do for y = 1, 17, 1 do if math.random() > 0.8 then mset(x - 1, y - 1, math.random(32, 39)) else mset(x - 1, y - 1, 255) end end end for x = 1, 30 * 8, 1 do local bilding_size = 17 - math.random(10, 15) for y = 1, 17, 1 do if y < bilding_size + 1 then mset(x - 1, y - 1 + 17, 255) else mset(x - 1, y - 1 + 17, math.random(0, 15)) end end end for x = 1, 30 * 8, 1 do local bilding_size = 17 - math.random(6, 12) for y = 1, 17, 1 do if y < bilding_size + 1 then mset(x - 1, y - 1 + 34, 255) else mset(x - 1, y - 1 + 34, math.random(16, 31)) end end end for x = 1, 30 * 8, 1 do local bilding_size = 17 - math.random(6, 12) for y = 1, 17, 1 do if y == 17 then mset(x - 1, y - 1 + 51, math.random(40, 47)) else mset(x - 1, y - 1 + 51, 255) end end end end new_background() -- Update and draw function TIC() if game then return end -- Update time t = t + 1 -- Check keys if btn(4) then Player.vel = -Player.ace - 0.3 Jetpack.timer = Jetpack.timer + 1 else Jetpack.timer = 0 end -- Update Pipes if t % 120 == 0 then new_pipe(WIDTH + 16) end local for_remove = nil for i, p in pairs(Pipes.active) do p.x = p.x - 1 if p.x < -16 then for_remove = i end end if for_remove then table.remove(Pipes.active, for_remove) end -- Update player Player.vel = math.min(Player.vel + 0.3, 1.85) Player.y = math.max(math.min(Player.y + Player.vel, 128), 0); -- Check colitions for i, p in pairs(Pipes.active) do if AABB(Player.x + 1, Player.y + 1, 6, 6, p.x + 2, 0, 12, p.y - 10) or AABB(Player.x + 1, Player.y + 1, 6, 6, p.x + 2, p.y + 26, 12, 80) then game = true elseif AABB(Player.x + 1, Player.y + 1, 6, 6, p.x + 8, p.y - 8, 1, 32) and p.score then Player.score = Player.score + 1 p.score = false end end -- Draw -- Clear screen cls(0) -- Draw map map(t // 400, 0, 32, 17, -((t / 50) % 8), 0, 0) map(t // 80, 17, 32, 17, -((t / 10) % 8), 0, 0) map(t // 8, 34, 32, 17, -((t / 1) % 8), 0, 0) map(t // 8, 51, 32, 17, -((t / 1) % 8), 0, 0) -- Draw pipes for _, p in pairs(Pipes.active) do spr(Pipes.frame, p.x, p.y - 24, 0, 1, 0, 0, 2, 2) for y_offset = p.y - 24 - 8, -8, -8 do spr(Pipes.frame, p.x, y_offset, 0, 1, 0, 0, 2, 1) end spr(Pipes.frame, p.x, p.y + 24, 0, 1, 2, 0, 2, 2) for y_offset = p.y + 24 + 8, HEIGHT + 8, 8 do spr(Pipes.frame, p.x, y_offset, 0, 1, 2, 0, 2, 1) end end -- Draw palyer Player.draw() -- Print score local score_width = print(Player.score, 0, -16, 0, true, 2) print(Player.score, (240 - score_width) // 2, 5, 2, true, 2) end