v1.1 - ready for release
This commit is contained in:
parent
63b8a7800a
commit
8cb570a2da
47
snowdogs.p8
47
snowdogs.p8
@ -9,6 +9,7 @@ function _init()
|
|||||||
create_particles()
|
create_particles()
|
||||||
mode = "title"
|
mode = "title"
|
||||||
goal = 10000
|
goal = 10000
|
||||||
|
start_time = 0
|
||||||
music(0)
|
music(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -56,7 +57,7 @@ function draw_game()
|
|||||||
trees_dr()
|
trees_dr()
|
||||||
sled_dr()
|
sled_dr()
|
||||||
if npc.draw != nil then
|
if npc.draw != nil then
|
||||||
npc.draw(npc.x, npc.y)
|
npc.draw(npc.x, npc_y())
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -81,6 +82,7 @@ function title_upd()
|
|||||||
|
|
||||||
if btnp(4) then
|
if btnp(4) then
|
||||||
mode = "game"
|
mode = "game"
|
||||||
|
start_time = t()
|
||||||
end
|
end
|
||||||
|
|
||||||
if t() > 10 and t() < 20 then
|
if t() > 10 and t() < 20 then
|
||||||
@ -188,6 +190,10 @@ end
|
|||||||
-->8
|
-->8
|
||||||
-- game entities
|
-- game entities
|
||||||
|
|
||||||
|
function disp_time()
|
||||||
|
return flr(t() - start_time)
|
||||||
|
end
|
||||||
|
|
||||||
function draw_hud()
|
function draw_hud()
|
||||||
rectfill(14,0,114,4,7)
|
rectfill(14,0,114,4,7)
|
||||||
local d = 14+distance/goal*100
|
local d = 14+distance/goal*100
|
||||||
@ -196,6 +202,7 @@ function draw_hud()
|
|||||||
for l=1,dogs do
|
for l=1,dogs do
|
||||||
print("🐱", 1, (l-1)*7, 7)
|
print("🐱", 1, (l-1)*7, 7)
|
||||||
end
|
end
|
||||||
|
print(disp_time(), 3, 45)
|
||||||
print("▒", 108, 0, 0)
|
print("▒", 108, 0, 0)
|
||||||
|
|
||||||
if distance >= goal then
|
if distance >= goal then
|
||||||
@ -209,9 +216,13 @@ end
|
|||||||
|
|
||||||
function draw_bounds()
|
function draw_bounds()
|
||||||
sl, sr = sled_bounds()
|
sl, sr = sled_bounds()
|
||||||
rect(screenx(sl), 128-16*3, screenx(sr), 128)
|
rect(screenx(sl), sled_top(), screenx(sr), 128)
|
||||||
tl, tr = tree_bounds()
|
tl, tr = tree_bounds()
|
||||||
rect(screenx(tl), 100, screenx(tr), 128)
|
rect(screenx(tl), 100, screenx(tr), 128)
|
||||||
|
|
||||||
|
if npc.collide != nil then
|
||||||
|
rect(npc.x-8, npc_y(), npc.x+8, npc_y()+16)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
-->8
|
-->8
|
||||||
-- sled
|
-- sled
|
||||||
@ -223,6 +234,10 @@ sled_x = 64
|
|||||||
dogs = 6
|
dogs = 6
|
||||||
mush_time = 0
|
mush_time = 0
|
||||||
|
|
||||||
|
function sled_top()
|
||||||
|
return 128-16*ceil(dogs/2)
|
||||||
|
end
|
||||||
|
|
||||||
function sled_upd()
|
function sled_upd()
|
||||||
if btn(0) then
|
if btn(0) then
|
||||||
steering = -1
|
steering = -1
|
||||||
@ -232,6 +247,7 @@ function sled_upd()
|
|||||||
steering = 0
|
steering = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
speed = 2 + (distance / 3000)
|
speed = 2 + (distance / 3000)
|
||||||
|
|
||||||
if btnp(4) and t() - mush_time > 1 then
|
if btnp(4) and t() - mush_time > 1 then
|
||||||
@ -240,9 +256,12 @@ function sled_upd()
|
|||||||
--steering = rnd({-2, 2})
|
--steering = rnd({-2, 2})
|
||||||
end
|
end
|
||||||
|
|
||||||
if t() - mush_time < 0.2 then
|
if t() - mush_time < 0.3 then
|
||||||
speed *= 3
|
speed *= 3
|
||||||
end
|
end
|
||||||
|
if btn(3) then
|
||||||
|
speed *= 0.2
|
||||||
|
end
|
||||||
|
|
||||||
distance += speed
|
distance += speed
|
||||||
sled_x += steering * speed
|
sled_x += steering * speed
|
||||||
@ -255,6 +274,8 @@ function sled_upd()
|
|||||||
|
|
||||||
if distance >= goal then
|
if distance >= goal then
|
||||||
state = "win"
|
state = "win"
|
||||||
|
end_time = disp_time()
|
||||||
|
music(0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -262,7 +283,7 @@ function sled_bounds()
|
|||||||
if dogs % 2 == 0 then
|
if dogs % 2 == 0 then
|
||||||
return sled_x-8, sled_x+8
|
return sled_x-8, sled_x+8
|
||||||
else
|
else
|
||||||
return sled_x, sled_x+8
|
return sled_x-8, sled_x
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -400,7 +421,6 @@ end
|
|||||||
|
|
||||||
npc = {
|
npc = {
|
||||||
x=0,
|
x=0,
|
||||||
y=0,
|
|
||||||
dx=0,
|
dx=0,
|
||||||
dy=0,
|
dy=0,
|
||||||
last=0,
|
last=0,
|
||||||
@ -409,6 +429,10 @@ npc = {
|
|||||||
sound=nil,
|
sound=nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function npc_y()
|
||||||
|
return (distance - npc.last)
|
||||||
|
end
|
||||||
|
|
||||||
function npc_upd()
|
function npc_upd()
|
||||||
-- every 200, roll for new npc
|
-- every 200, roll for new npc
|
||||||
if distance - npc.last > 200 then
|
if distance - npc.last > 200 then
|
||||||
@ -431,9 +455,9 @@ function npc_upd()
|
|||||||
npc.sound = 7
|
npc.sound = 7
|
||||||
else
|
else
|
||||||
npc.draw = nil
|
npc.draw = nil
|
||||||
|
npc.collide = nil
|
||||||
end
|
end
|
||||||
npc.last = distance
|
npc.last = distance
|
||||||
npc.y = rnd(40)
|
|
||||||
npc.x = -10
|
npc.x = -10
|
||||||
npc.dx = rnd(1)+1
|
npc.dx = rnd(1)+1
|
||||||
npc.dy = rnd(2)
|
npc.dy = rnd(2)
|
||||||
@ -441,15 +465,18 @@ function npc_upd()
|
|||||||
npc.x += 140
|
npc.x += 140
|
||||||
npc.dx *= -1
|
npc.dx *= -1
|
||||||
end
|
end
|
||||||
|
if npc_y() > 120 then
|
||||||
|
npc.collide = nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- update npc
|
-- update npc
|
||||||
npc.x += npc.dx
|
npc.x += npc.dx
|
||||||
npc.y += npc.dy
|
|
||||||
|
|
||||||
-- check collision
|
-- check collision
|
||||||
l, r = sled_bounds()
|
l, r = sled_bounds()
|
||||||
if npc.y > 80 and npc.x+8 > l and npc.x < r and npc.collide != nil then
|
if npc_y()+16 > sled_top() and npc.x+8 > l and npc.x < r and npc.collide != nil then
|
||||||
|
printh("collide ")
|
||||||
npc.collide()
|
npc.collide()
|
||||||
npc.collide = nil
|
npc.collide = nil
|
||||||
sfx(npc.sound)
|
sfx(npc.sound)
|
||||||
@ -507,10 +534,10 @@ function draw_flag(loser)
|
|||||||
if loser then
|
if loser then
|
||||||
print("better luck next year", 20, 115, 9)
|
print("better luck next year", 20, 115, 9)
|
||||||
else
|
else
|
||||||
music(0)
|
|
||||||
local scale = (sin(t()) + 2)*2.5 * 8
|
local scale = (sin(t()) + 2)*2.5 * 8
|
||||||
sspr(32, 24, 8, 8, 80-scale/2, 48-scale/2, scale, scale)
|
sspr(32, 24, 8, 8, 80-scale/2, 48-scale/2, scale, scale)
|
||||||
print("see you again in '84!", 20, 115, 9)
|
print(end_time .. " !!! a world record!", 20, 110, 9)
|
||||||
|
print("see you again in '84!", 20, 120, 9)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user