win screen
This commit is contained in:
parent
134d1f426e
commit
45a68c15c4
161
toomgis.p8
161
toomgis.p8
@ -2,7 +2,9 @@ pico-8 cartridge // http://www.pico-8.com
|
||||
version 41
|
||||
__lua__
|
||||
|
||||
state = "ampm"
|
||||
function _init()
|
||||
start_winscreen()
|
||||
end
|
||||
|
||||
function _draw()
|
||||
cls()
|
||||
@ -12,6 +14,8 @@ function _draw()
|
||||
level_draw()
|
||||
elseif state == "gameover" then
|
||||
gameover_draw()
|
||||
elseif state == "winscreen" then
|
||||
winscreen_draw()
|
||||
end
|
||||
end
|
||||
|
||||
@ -24,13 +28,11 @@ function _update()
|
||||
level_upd()
|
||||
elseif state == "gameover" then
|
||||
gameover_upd()
|
||||
elseif state == "winscreen" then
|
||||
winscreen_upd()
|
||||
end
|
||||
end
|
||||
|
||||
function _init()
|
||||
ampm_init()
|
||||
end
|
||||
|
||||
function sprm(n, x, y, w, h)
|
||||
-- mirrored sprite draw
|
||||
spr(n, x, y, w, h)
|
||||
@ -39,9 +41,10 @@ end
|
||||
-->8
|
||||
-- ampm logo
|
||||
|
||||
ampm_t = 0
|
||||
|
||||
function ampm_init()
|
||||
function start_ampm()
|
||||
ampm_t = 0
|
||||
px = 0
|
||||
py = 0
|
||||
for i=2, 14 do
|
||||
add2body(i)
|
||||
add2body(i)
|
||||
@ -97,6 +100,10 @@ function ampm_upd()
|
||||
ampm_t = 0
|
||||
end
|
||||
tangle -= 0.02
|
||||
|
||||
if btn(❎) then
|
||||
start_level(1)
|
||||
end
|
||||
end
|
||||
|
||||
-->8
|
||||
@ -107,12 +114,6 @@ tbody = {
|
||||
} -- array of items in body
|
||||
pieces = 1
|
||||
MAX_PIECES = 200
|
||||
px = 0
|
||||
py = 0
|
||||
vx = 0
|
||||
vy = 0
|
||||
yacc = 0
|
||||
streak = 0
|
||||
|
||||
function toomgis_radius()
|
||||
return 8 + (pieces / MAX_PIECES) * 40
|
||||
@ -163,6 +164,7 @@ function toomgis_upd()
|
||||
end
|
||||
for idx in all(to_remove) do
|
||||
deli(tbody, idx)
|
||||
pieces -= 1
|
||||
end
|
||||
end
|
||||
-->8
|
||||
@ -174,8 +176,10 @@ levels = {
|
||||
sky=7,
|
||||
gnd=5,
|
||||
mapy=2,
|
||||
bad_item_ratio=0.2,
|
||||
bad_item_ratio=0.12,
|
||||
unit="CM",
|
||||
time=60,
|
||||
next=2,
|
||||
},
|
||||
{
|
||||
name="city nights",
|
||||
@ -184,6 +188,8 @@ levels = {
|
||||
mapy=5,
|
||||
bad_item_ratio=0.2,
|
||||
unit="M",
|
||||
time=80,
|
||||
next=nil,
|
||||
},
|
||||
}
|
||||
horizon = 64
|
||||
@ -194,6 +200,12 @@ function start_level(n)
|
||||
-- toomgis reset
|
||||
tbody = {}
|
||||
pieces = 1
|
||||
px = 0
|
||||
py = 0
|
||||
vx = 0
|
||||
vy = 0
|
||||
yacc = 0
|
||||
streak = 0
|
||||
-- level reset
|
||||
lvl = levels[n]
|
||||
lvl_start_time = time()
|
||||
@ -233,6 +245,16 @@ function level_draw()
|
||||
|
||||
toomgis_draw(20, 96-py)
|
||||
|
||||
-- draw item shadows
|
||||
shadow_pal()
|
||||
for item in all(items) do
|
||||
if item.n != 0 then
|
||||
spr(item.n, item.x-px+1, item.y+1)
|
||||
end
|
||||
end
|
||||
|
||||
-- reset
|
||||
pal()
|
||||
for item in all(items) do
|
||||
if item.n != 0 then
|
||||
spr(item.n, item.x-px, item.y)
|
||||
@ -246,7 +268,6 @@ function level_draw()
|
||||
end
|
||||
|
||||
-- hud
|
||||
local size = max(flr(pieces/MAX_PIECES*100), 1)
|
||||
local streak_str = streak2mult()
|
||||
if streak_str == 1 then
|
||||
streak_str = ""
|
||||
@ -254,13 +275,13 @@ function level_draw()
|
||||
streak_str = streak_str.."X"
|
||||
end
|
||||
rectfill(0, 0, 128, 8, 2)
|
||||
print("SIZE "..size..lvl.unit.." "..streak_str.." ", 1, 1, 9)
|
||||
print("SIZE "..pieces..lvl.unit.." "..streak_str.." ", 1, 1, 9)
|
||||
print(time_left().."S", 60, 1, 9)
|
||||
print("GOAL 100"..lvl.unit, 88, 1, 9)
|
||||
end
|
||||
|
||||
function time_left()
|
||||
return flr(max(0, (90+lvl_start_time)-time()))
|
||||
return flr(max(0, (lvl.time+lvl_start_time)-time()))
|
||||
end
|
||||
|
||||
function streak2mult()
|
||||
@ -283,6 +304,19 @@ function draw_stink(x, y)
|
||||
end
|
||||
|
||||
function level_upd()
|
||||
printh(px)
|
||||
|
||||
if time_left() <= 0 then
|
||||
if pieces < 100 then
|
||||
start_gameover()
|
||||
elseif lvl.next != nil then
|
||||
start_level(lvl.next)
|
||||
else
|
||||
start_winscreen()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if btn(➡️) then
|
||||
vx += 0.1
|
||||
end
|
||||
@ -333,7 +367,7 @@ function level_upd()
|
||||
end
|
||||
-- add item if inactive (chance increases as more slots inactive)
|
||||
to_check = rnd(items)
|
||||
if to_check.n == 0 then
|
||||
if to_check != nil and to_check.n == 0 then
|
||||
-- good items 2-14, bad items 18-30
|
||||
if rnd() < lvl.bad_item_ratio then
|
||||
to_check.n = flr(rnd(12)+18)
|
||||
@ -362,6 +396,95 @@ function dist(x0,y0,x1,y1)
|
||||
return sqrt(dsq)*64
|
||||
end
|
||||
|
||||
function shadow_pal()
|
||||
for i=0,16 do
|
||||
pal(i, 1)
|
||||
end
|
||||
end
|
||||
|
||||
-- gameover
|
||||
function start_gameover()
|
||||
state = "gameover"
|
||||
py = 0
|
||||
px = 64
|
||||
tbody = {}
|
||||
for i=18,26 do
|
||||
add2body(i)
|
||||
add2body(i)
|
||||
add2body(i)
|
||||
end
|
||||
end
|
||||
|
||||
function gameover_draw()
|
||||
cls(1)
|
||||
toomgis_draw(px, py)
|
||||
shadow_pal()
|
||||
sprm(32, px+1, py+13, 1, 2)
|
||||
pal()
|
||||
sprm(32, px, py+12, 1, 2)
|
||||
|
||||
-- gritpy
|
||||
sprm(15, px-20, py-70, 1, 4)
|
||||
-- grimace is backwards
|
||||
spr(64, px+30, py-85, 2, 4)
|
||||
spr(64, px+30-16, py-85, 2, 4, true)
|
||||
|
||||
print("WE RUN THIS TOWN", px-45, py-80, 9)
|
||||
print("CRUSH HIM", px+20, py-95, 2)
|
||||
print("GAME OVER", 50, py-110, 8)
|
||||
end
|
||||
|
||||
function gameover_upd()
|
||||
px += rnd(2) - 1
|
||||
py += 0.3
|
||||
|
||||
if py > 200 then
|
||||
start_gameover()
|
||||
end
|
||||
end
|
||||
|
||||
-- winscreen
|
||||
|
||||
function start_winscreen()
|
||||
state = "winscreen"
|
||||
px = 64
|
||||
py = -100
|
||||
tbody = {}
|
||||
for i=2,18 do
|
||||
add2body(i)
|
||||
add2body(i)
|
||||
add2body(i)
|
||||
add2body(i)
|
||||
end
|
||||
for i=129,190 do
|
||||
add2body(i)
|
||||
end
|
||||
end
|
||||
|
||||
function winscreen_draw()
|
||||
cls(1)
|
||||
toomgis_draw(px, py)
|
||||
|
||||
-- gritty
|
||||
sprm(15, px-20, py+70, 1, 4)
|
||||
-- grimace is backwards
|
||||
spr(64, px+30, py+85, 2, 4)
|
||||
spr(64, px+30-16, py+85, 2, 4, true)
|
||||
|
||||
print("WE REGRET EVERYTHING", px-45, py+60, 9)
|
||||
print("I REPENT", px+20, py+75, 2)
|
||||
print("YOU WIN", 50, py-60, 8)
|
||||
print("TOOMGIS WILL RETURN", 20, py-100, 8)
|
||||
end
|
||||
|
||||
function winscreen_upd()
|
||||
py += 0.5
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
|
||||
__gfx__
|
||||
000022220000000000444400000ee000aaaaaaaa0000000000555500045454000099990000087000000000000cccccc00077700000000a0000ffff0000005555
|
||||
000222220000000004eee440009ea9000aa77aa0060000000088880004545400099999900007400009f9f9f0cc1111cc06444660000a0a000fff4ff000055555
|
||||
|
Loading…
Reference in New Issue
Block a user