ΞΜΜΜ̈ˆˆ¬ͺͺͺ¬ˆˆˆ¬ΜΜΜ¬ΜΐΜ¬ΜΐΜ¬ΜΐΜΜΜμΜξͺͺΐΐξΜ¬ΐΜΐ¬ΐΐΐ¬ΐΐΐ¬ΐΐΞΜΜΜ̈ˆˆ¬ͺͺͺ¬ˆˆˆ¬ΜΜΜ¬ΜΜΜ¬ΜΐΜ¬ΜΐΜΜΜμΜξͺͺΐΐξΜ¬ΐΜΜ¬ΐΐΐ¬ΐΐΐ¬ΐΐ¬ΜΜΜ¬ͺͺͺ¬ͺ¬ͺ¬ͺΚΜ¬ͺͺͺŒˆˆˆΜΐΜΞΜΜΞΜ¬Μͺͺΐμ¬ͺΐξͺͺΐξͺͺΐΜξΐμξΜΜξξ¬ΜΜΜ¬ͺͺͺ¬ͺ¬ͺ¬ͺΚΜ¬ͺͺͺŒˆˆˆΜΐΜΞΜΜΞΜ¬Μͺͺΐμ¬ͺΐξͺͺΐξͺͺΐΜξΐμξΜΜξξ >œ?ΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜ""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""ΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜ333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333ΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜ™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™1C3A13@3@3σ@3#A@031C3ήMέNπΤέ@έM@έM@ένD@ΣAέMήMέ@@@ ΰ@O@O@Τ@0τΤΠ@@@@ @Ο@O@τ@Bτπ@@@@@3D@3Τ@3σ04@D@@@@@έL@έ$@έύ@έ<@Lτπ@@@@@O@M@ON@ΠτM@ @@@ΰD3 @3Σ@O@3#Σ@OπLN4DMC @ΐΐΞέΐέύΐΐΐέένΠΟήΰένίέΐΐΜΐΜΜΜΐΜΜΜΜΜΜΜ ΜΜΜΜ ΜΜΜΜ ΐΜΜΜΐΜΜΜΐΜ»»»»»»»»»»»»»»»»»»»»»»»» »»»»»»»»»»»»»»»»»»»»»»»» ΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜ ΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜ ΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜ ΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜΜ πξΠήπ οξ Ππξνώ Πνξνήνή πν οξ ΠοΠ ήΰώ π Π Π π π οο ΰ π ΠπΠώπήΰού Π Π ώΰ ώύ πνΠοΰίοΠίώ Π Π π π νίώ πνΠΰΰΠήέίνξή νξήνξνήνή έί πΠΠΰΰΠπ Π Π π ΰ ώΰ ξ y-- title: TIC Breakout -- author: Muse for Terry -- desc: Breakout for TIC-80 - bounce the ball, smash the bricks, don't let it past your paddle -- script: lua -- input: gamepad -- saveid: tic_breakout -- TIC Breakout for TIC-80, 240x136 - the arcade brick-breaker. -- Left/Right: move the paddle. X: start / launch the ball. -- Z: pause. Smash every brick to clear the level - each new -- level is faster. You have 3 lives. Top rows are worth more. local state = "title" -- title, serve, play, pause, levelclear, gameover local paddle = {x = 102, y = 126, w = 36, h = 5, speed = 3} local ball = {x = 120, y = 120, dx = 0, dy = 0, r = 2} local bricks = {} local score = 0 local best = 0 local lives = 3 local level = 1 local clear_timer = 0 local ball_speed = 1.6 local BRICK_COLS = 10 local BRICK_ROWS = 5 local BRICK_W = 20 local BRICK_H = 8 local BRICK_X0 = 10 local BRICK_Y0 = 24 local ROW_COLORS = {2, 3, 4, 5, 9} local ROW_POINTS = {50, 40, 30, 20, 10} local function build_bricks() bricks = {} for r = 1, BRICK_ROWS do for c = 1, BRICK_COLS do bricks[#bricks + 1] = { x = BRICK_X0 + (c - 1) * (BRICK_W + 2), y = BRICK_Y0 + (r - 1) * (BRICK_H + 2), w = BRICK_W, h = BRICK_H, row = r, alive = true } end end end local function reset_ball() ball.x = paddle.x + paddle.w / 2 ball.y = paddle.y - ball.r - 1 ball.dx = 0 ball.dy = 0 end local function new_game() score = 0 lives = 3 level = 1 ball_speed = 1.6 paddle.x = 102 build_bricks() reset_ball() state = "serve" end local function next_level() level = level + 1 ball_speed = 1.6 + (level - 1) * 0.2 paddle.x = 102 build_bricks() reset_ball() state = "serve" end local function launch() ball.dx = ball_speed * 0.5 ball.dy = -ball_speed state = "play" end local function lose_life() lives = lives - 1 if lives <= 0 then if score > best then best = score end state = "gameover" else reset_ball() state = "serve" end end local function bricks_left() local n = 0 for i = 1, #bricks do if bricks[i].alive then n = n + 1 end end return n end local function move_paddle() if btn(2) then paddle.x = paddle.x - paddle.speed end if btn(3) then paddle.x = paddle.x + paddle.speed end if paddle.x < 8 then paddle.x = 8 end if paddle.x > 232 - paddle.w then paddle.x = 232 - paddle.w end end local function bounce_paddle() local offset = (ball.x - (paddle.x + paddle.w / 2)) / (paddle.w / 2) if offset > 1 then offset = 1 end if offset < -1 then offset = -1 end ball.dy = -math.abs(ball.dy) ball.dx = offset * ball_speed * 0.9 ball.y = paddle.y - ball.r - 1 end local function update_ball() local px, py = ball.x, ball.y ball.x = ball.x + ball.dx ball.y = ball.y + ball.dy -- side walls if ball.x - ball.r < 8 then ball.x = 8 + ball.r ball.dx = math.abs(ball.dx) elseif ball.x + ball.r > 232 then ball.x = 232 - ball.r ball.dx = -math.abs(ball.dx) end -- top wall if ball.y - ball.r < 16 then ball.y = 16 + ball.r ball.dy = math.abs(ball.dy) end -- paddle if ball.dy > 0 and ball.y + ball.r >= paddle.y and ball.y - ball.r <= paddle.y + paddle.h and ball.x >= paddle.x - ball.r and ball.x <= paddle.x + paddle.w + ball.r then bounce_paddle() end -- bricks for i = 1, #bricks do local b = bricks[i] if b.alive and ball.x + ball.r > b.x and ball.x - ball.r < b.x + b.w and ball.y + ball.r > b.y and ball.y - ball.r < b.y + b.h then b.alive = false score = score + ROW_POINTS[b.row] -- bounce off the side the ball came from if px + ball.r <= b.x or px - ball.r >= b.x + b.w then ball.dx = -ball.dx else ball.dy = -ball.dy end if bricks_left() == 0 then score = score + level * 100 state = "levelclear" clear_timer = 90 end break end end -- missed the paddle if ball.y - ball.r > 136 then lose_life() end end local function update() if state == "title" then if btnp(4) or btnp(5) then new_game() end elseif state == "serve" then move_paddle() reset_ball() if btnp(4) then launch() end elseif state == "play" then move_paddle() if btnp(5) then state = "pause" return end update_ball() elseif state == "pause" then if btnp(5) or btnp(4) then state = "play" end elseif state == "levelclear" then clear_timer = clear_timer - 1 if clear_timer <= 0 then next_level() end elseif state == "gameover" then if btnp(4) or btnp(5) then state = "title" end end end -- ---- drawing ---- local function draw_hud() rect(0, 0, 240, 16, 0) print("SCORE " .. score, 4, 5, 12) print("BEST " .. best, 96, 5, 4) print("LV " .. level .. " LIVES " .. lives, 168, 5, 5) end local function draw_walls() rect(0, 16, 8, 120, 14) rect(232, 16, 8, 120, 14) end local function draw_bricks() for i = 1, #bricks do local b = bricks[i] if b.alive then rect(b.x, b.y, b.w, b.h, ROW_COLORS[b.row]) rect(b.x, b.y, b.w, 2, 12) end end end local function draw_paddle() rect(paddle.x, paddle.y, paddle.w, paddle.h, 12) rect(paddle.x, paddle.y, paddle.w, 2, 11) end local function draw_ball() circ(ball.x, ball.y, ball.r, 12) end local function draw_title() cls(0) draw_hud() draw_walls() -- demo bricks on the title screen for r = 1, 5 do for c = 1, 10 do local x = BRICK_X0 + (c - 1) * 22 local y = 40 + (r - 1) * 10 rect(x, y, 20, 8, ROW_COLORS[r]) end end rect(0, 96, 240, 24, 0) print("TIC BREAKOUT", 84, 102, 12) print("TIC BREAKOUT", 83, 101, 4) print("BY MUSE FOR TERRY", 78, 124, 13) print("ARROWS: PADDLE X: LAUNCH Z: PAUSE", 36, 112, 12) end local function draw_serve() cls(0) draw_hud() draw_walls() draw_bricks() draw_paddle() draw_ball() print("PRESS X TO LAUNCH", 76, 72, 12) end local function draw_pause() cls(0) draw_hud() draw_walls() draw_bricks() draw_paddle() draw_ball() rect(72, 56, 96, 24, 0) print("PAUSED", 96, 64, 12) end local function draw_levelclear() cls(0) draw_hud() draw_walls() rect(56, 48, 128, 40, 0) print("LEVEL " .. level .. " CLEAR!", 84, 56, 5) print("BONUS " .. (level * 100), 92, 68, 4) end local function draw_gameover() cls(0) draw_hud() draw_walls() rect(56, 48, 128, 48, 0) print("GAME OVER", 88, 56, 2) print("SCORE " .. score, 92, 68, 12) print("BEST " .. best, 96, 80, 4) print("PRESS X TO PLAY AGAIN", 64, 108, 13) end local function draw() if state == "title" then draw_title() return end if state == "serve" then draw_serve() return end if state == "pause" then draw_pause() return end if state == "levelclear" then draw_levelclear() return end if state == "gameover" then draw_gameover() return end cls(0) draw_hud() draw_walls() draw_bricks() draw_paddle() draw_ball() end function TIC() update() draw() end