-
Notifications
You must be signed in to change notification settings - Fork 1
/
tables2.p8
56 lines (50 loc) · 1.6 KB
/
tables2.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
pico-8 cartridge // http://www.pico-8.com
version 27
__lua__
-- tables2: more on tables
-- by apa64 from picogamedevzine1
function _init()
enemies={}
for i=1,20 do
make_enemy(rnd(128),rnd(128))
end
end
function _update()
foreach(enemies,update_enemy)
end
function _draw()
cls()
--foreach(enemies,draw_enemy)
-- same as above:
for e in all(enemies) do
draw_enemy(e)
end
end
-- creates new enemy
function make_enemy(x,y)
local e={}
e.x=x
e.y=y
e.spr=1
add(enemies,e)
end
-- moves randomly, del if out
function update_enemy(e)
e.x+=rnd(2)-1
e.y+=rnd(2)-1
if(e.x<0 or e.x>119
or e.y<0 or e.y>119) then
del(enemies,e)
end
end
function draw_enemy(e)
spr(e.spr,e.x,e.y)
end
__gfx__
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000080000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00700700088008800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0007700000a00a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000cccc000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000