-
Notifications
You must be signed in to change notification settings - Fork 1
/
talon.p8
157 lines (133 loc) · 8.62 KB
/
talon.p8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
pico-8 cartridge // http://www.pico-8.com
version 42
__lua__
function _init()
fps=60
assert(fps==30 or fps==60)
if fps==30 then
dt=0x0000.0888
else
dt=0x0000.0444
end
play_init()
end
function play_make_ent(o)
return add(pl_ents,o or {})
end
function play_init()
pl_ents={}
g={
t=0
}
g.ship=play_make_ent({
x=42,y=120,
t=0,
sprite={
id=20,w=2,h=2,
sox=6,soy=15,
post=function(e)
if blink(0.05,e.t) then
spr(22,e.sprite.draw_x,
e.sprite.draw_y+8,
2,2)
end
end
},
})
_update=play_update
_draw=play_draw
end
function play_update()
g.t+=dt
foreach(pl_ents,ent_update)
end
function play_draw()
cls(12)
local lt=g.t%1
map(0,0,0,(lt-1)*128,12,16)
map(0,0,0,lt*128,12,16)
foreach(pl_ents,ent_draw)
camera()
-- hud
rect(0,0,127,127,5)
rectfill(96,1,126,126,6)
line(96,1,96,126,5)
end
function ent_update(e)
e.t+=dt
end
function ent_draw(e)
if not e.sprite then
return
end
local sw=e.sprite.w or 1
local sh=e.sprite.h or 1
-- normalized sprite anchor
-- 0,0 topleft
-- 0.5,0.5 center
-- 1,1 botright
local ox=e.sprite.ox or 0.5
local oy=e.sprite.oy or 0.5
-- screen space offset
local soffx=e.sprite.sox or sw*ox*8-1
local soffy=e.sprite.soy or sh*oy*8-1
e.sprite.draw_x=e.x-soffx
e.sprite.draw_y=e.y-soffy
if (e.sprite.pre) e.sprite.pre(e)
spr(e.sprite.id,
e.sprite.draw_x,
e.sprite.draw_y,
e.sprite.w,
e.sprite.h)
if (e.sprite.post) e.sprite.post(e)
end
-->8
-- util
function blink(hz,t0)
local t0=t0 or t()
local hz=hz or 1
local hhz=hz/2
return t0%hz>=hhz
end
__gfx__
0000000000000000000000000000000000000000000000000000000000000000000000004444ffffffff44440000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000444ffff00ffff4440000000000000000000000000000000000000000
0070070000000000000000000000000000000000000000000000000000000000000000004444f000000f44440000000000000000000000000000000000000000
000770000000000000000000000000000000000000000000000000000000000000000000444ff000000ff4440000000000000000000000000000000000000000
000770000000000000000000000000000000000000000000000000000000000000000000444fff0000fff4440000000000000000000000000000000000000000
007007000000000000000000000000000000000000000000000000000000000000000000444fff0000fff4440000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000004444f000000f44440000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000044ffff0000ffff440000000000000000000000000000000000000000
0000000000000000000000000000000000000dd000000000000000000000000000000000444ffff00ffff4440000000000000000000000000000000000000000
000dd00000000000000000000000000000000dd0000000000000000000000000000000004444ff0000ff44440000000000000000000000000000000000000000
80d77d080000000000000000000000000000dddd0000000000000000000000000000000044444f0000f444440000000000000000000000000000000000000000
5dd77dd500000000d0d0000000000d0d0000d66d000000000011000011000000000000004444fff00fff44440000000000000000000000000000000000000000
5dd77dd500000000d0d0000000000d0d009d6666d900000001cc1001cc100000000000004444fff00fff44440000000000000000000000000000000000000000
d5d55d5d00000000ddd000dddd000ddd099d6666d9900000017710017710000000000000444ff000000ff4440000000000000000000000000000000000000000
dd5005dd00000000d9d00d1111d00d9d099d6666d99000001c77c11c77c1000000000000444fff0000fff4440000000000000000000000000000000000000000
dd0000dd00000000d9d0d111111d0d9d099d6666d99000001cccc11cccc1000000000000444ffff00ffff4440000000000000000000000000000000000000000
0000000000000000d9ddd111111ddd9dd99d6666d99d000001111001111000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000d9dddddddddddd9dd99d6556d99d000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000d9dddddddddddd9ddd9d6556d9dd000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000d9dddddddddddd9ddddd6556dddd000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000d9dddddddddddd9ddd11d55d11dd000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000d9d5d5dddd5d5d9d0d66d55d66d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000d555555dd555555d01661dd16610000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000555555005555550011110011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000
__map__
09000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
19000000000000000000001a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
09000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
19000000000000000000001a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
09000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
19000000000000000000001a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
09000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
19000000000000000000001a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
09000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
19000000000000000000001a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
09000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
19000000000000000000001a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
09000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
19000000000000000000001a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
09000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
19000000000000000000001a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000