Skip to content
Permalink
Browse files
Merge zapp-alike, by @adam_sporka
  • Loading branch information
fweez committed Sep 28, 2016
1 parent 248c46f commit 99ada941c8fa85bcbc34e532ec9b87465d770460
Showing with 102 additions and 16 deletions.
  1. +12 −12 collab_2/gfx/gfx0
  2. +87 −1 collab_2/lua/04.lua
  3. +3 −3 collab_2/sfx/sfx12
@@ -1,15 +1,15 @@
11111111050000502222222233333333000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1222222155555555222222223333333302222222222222200dddddddddddddd00000000000000000000000000000000000000000000000000000000000000000
1211112105c00c5022e22e2233b33b3302000000000000200d000000000000d00000000000000000000000000000000000000000000000000000000000000000
38888883050cc050222ee222333bb33308888888888888800cccccccccccccc00000000000000000000000000000000000000000000000000000000000000000
82828288050cc050222ee222333bb3338882828228282888ccc1c1c11c1c1ccc0000000000000000000000000000000000000000000000000000000000000000
8282828805c00c5022e22e2233b33b338882828228282888ccc1c1c11c1c1ccc0000000000000000000000000000000000000000000000000000000000000000
56888865555555552222222233333333568888888888886565cccccccccccc560000000000000000000000000000000000000000000000000000000000000000
56555565050000502222222233333333560000000000006565000000000000560000000000000000000000000000000000000000000000000000000000000000
44444444555555556666666677777777333366555555555555663131333333330000000000000000000000000000000000000000000000000000000000000000
44444444555555556666666677777777333665555555555555566313331313330000000000000000000000000000000000000000000000000000000000000000
44944944556556556676676677677677336655555555555555556633333133330000000000000000000000000000000000000000000000000000000000000000
44499444555665556667766677766777366555555555555555555663333333330000000000000000000000000000000000000000000000000000000000000000
11111111050000502222222211111111000000000000000000000000000000000000000000000000000000000000000088800000770000000000000000000000
1222222155555555222222221ccdd99102222222222222200dddddddddddddd00000000000000000000000000000000088800000777000000000000000000000
1211112105c00c5022e22e221cc1191102000000000000200d000000000000d00000000000000000000000000000000088000000777000000000000000000000
38888883050cc050222ee2221c11911108888888888888800cccccccccccccc00000000000000000000000000000000000000000000000000000000000000000
82828288050cc050222ee222111911c18882828228282888ccc1c1c11c1c1ccc0000000000000000000000000000000000000000000000000000000000000000
8282828805c00c5022e22e2211911cc18882828228282888ccc1c1c11c1c1ccc0000000000000000000000000000000000000000000000000000000000000000
568888655555555522222222199ddcc1568888888888886565cccccccccccc560000000000000000000000000000000000000000000000000000000000000000
56555565050000502222222211111111560000000000006565000000000000560000000000000000000000000000000000000000000000000000000000000000
44444444555555556666666677777777333366555555555555663131333333330000000000000000000000000000000000000000655500000000000000000000
4444444455555555666666667777777733366555555555555556631333131333000000000000000000000000000000000a000000666600000200000000000000
44944944556556556676676677677677336655555555555555556633333133330000000000000000000000000000000000000000556500000000000000000000
44499444555665556667766677766777366555555555555555555663333333330000000000000000000000000000000000000000666600000000000000000000
44499444555665556667766677766777665555555555555555555566333331310000000000000000000000000000000000000000000000000000000000000000
44944944556556556676676677677677655555555555555555555556333333130000000000000000000000000000000000000000000000000000000000000000
44444444555555556666666677777777555555555555555555555555333333330000000000000000000000000000000000000000000000000000000000000000
@@ -1 +1,87 @@
add(games,{name="tbd",author="tbd",_update = function() win() end}) -- game 4
add(games, {
name="zapp-alike",
author="@adam_sporka",

_init=function(self)
cx,cy,matrix,mask,score,t,started_at,pl=16,16,{},{},0,120,time(),true
for a=0,1023 do
matrix[a]=flr(rnd(2))+12
end
self:clear_mask()
end,

idx=function(x,y)
return x+y*32
end,

clear_mask=function()
for a=0,1023 do mask[a]=false end
lx,ly=-1,-1
end,

toggle=function(self)
i=self.idx(cx,cy)
mask[i],lx,ly=not mask[i],cx,cy
end,

match=function(self)
dx,dy=cx-lx,cy-ly
if (lx<0) return
success,count=1,0
for x=2,29 do
for y=2,29 do
tx,ty=x+dx,y+dy
if (mask[self.idx(x,y)]) then
count+=1
if (mask[self.idx(tx,ty)]) return
if (matrix[self.idx(tx,ty)]!=matrix[self.idx(x,y)]) success=0
end
end
end
score+=success*count^2
sfx(13-success)
for a=0,1023 do
if (mask[a] or mask[a-dy*32-dx]) matrix[a]=29+success
end
self.clear_mask()
end,

_update=function(self)
t=flr(120-time()+started_at)
if t<0 then
if (pl) sfx(14)
pl=false
return
end
if (btnp(0)) cx-=1
if (btnp(1)) cx+=1
if (btnp(2)) cy-=1
if (btnp(3)) cy+=1
cx,cy=(cx-2)%28+2,(cy-2)%28+2
if (btnp(4)) self:toggle()
if (btnp(5)) self:match()
end,

draw_box=function(x,y,c)
rect(x*4-1,y*4-1,x*4+3,y*4+3,c)
end,

_draw=function(self)
cls()
for x=2,29 do
for y=2,29 do
if mask[self.idx(x,y)] then self.draw_box(x,y,3) end
spr(matrix[self.idx(x,y)],x*4,y*4)
end
end
box_color=12
if (mask[self.idx(cx,cy)]) box_color=11
self.draw_box(cx,cy,box_color)
spr(28,lx*4,ly*4)
print("score "..score,8,121,7)
s="game over"
if (t>=0) s="time "..t
print(s,84,121)
end
})

@@ -1,4 +1,4 @@
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
010a0000180551d035000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000a00001d055180551704512045110350c0350b02506025000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
010a00001d055180551704512045110350c0350b02506025030450204501035000350002500025000150001500000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

0 comments on commit 99ada94

Please sign in to comment.