fix something idk
This commit is contained in:
parent
c761e5bb40
commit
b6c7b0a06c
114
main.lua
114
main.lua
|
@ -4,6 +4,19 @@ local g=love.graphics
|
||||||
local font=g.newFont(9,"mono")
|
local font=g.newFont(9,"mono")
|
||||||
font:setFilter("nearest")
|
font:setFilter("nearest")
|
||||||
g.setFont(font)
|
g.setFont(font)
|
||||||
|
local ltest=os.time()
|
||||||
|
local ltest=0
|
||||||
|
local hookdbg=false
|
||||||
|
if hookdbg then
|
||||||
|
debug.sethook(function()
|
||||||
|
ltest=ltest+1
|
||||||
|
if ltest>=1000 then
|
||||||
|
print("!! we are in a freezer !!",debug.traceback())
|
||||||
|
ltest=0
|
||||||
|
end
|
||||||
|
end,"",1000)
|
||||||
|
end
|
||||||
|
|
||||||
local colors={
|
local colors={
|
||||||
function(a,b)
|
function(a,b)
|
||||||
g.setColor(1,0,0,b*a)
|
g.setColor(1,0,0,b*a)
|
||||||
|
@ -52,9 +65,6 @@ local colors={
|
||||||
g.line(0.3,0.5, 0.7,0.5)
|
g.line(0.3,0.5, 0.7,0.5)
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
function pairs(t)
|
|
||||||
return next,t,nil
|
|
||||||
end
|
|
||||||
local gobjs={}
|
local gobjs={}
|
||||||
local cgobjs={}
|
local cgobjs={}
|
||||||
local lgobjs={}
|
local lgobjs={}
|
||||||
|
@ -65,19 +75,13 @@ for k,v in ipairs(colors) do
|
||||||
lgobjs[k]={c=k,super="lines"}
|
lgobjs[k]={c=k,super="lines"}
|
||||||
mgobjs[k]={c=k,super="color"}
|
mgobjs[k]={c=k,super="color"}
|
||||||
end
|
end
|
||||||
local ltest=0
|
|
||||||
debug.sethook(function()
|
|
||||||
ltest=ltest+1
|
|
||||||
if ltest>=10000 then
|
|
||||||
print("!! we are in a freezer !!",debug.traceback())
|
|
||||||
ltest=0
|
|
||||||
end
|
|
||||||
end,"",1000)
|
|
||||||
local cc=3
|
local cc=3
|
||||||
local tt=0
|
local tt=0
|
||||||
local bat=1
|
local bat=1
|
||||||
local batd=bat
|
local batd=bat
|
||||||
local score=0
|
local score=0
|
||||||
|
local taint=0
|
||||||
|
local taintd=taint
|
||||||
local tochar=0
|
local tochar=0
|
||||||
local scored=score
|
local scored=score
|
||||||
local function znoise(...)
|
local function znoise(...)
|
||||||
|
@ -180,7 +184,7 @@ local function badboigemcheck(c,am,ac,rm)
|
||||||
if not c then return end
|
if not c then return end
|
||||||
if ac~=5 and ac~=4 then return end
|
if ac~=5 and ac~=4 then return end
|
||||||
local aa={}
|
local aa={}
|
||||||
for k,v in pairs(am) do
|
for k,v in next,am do
|
||||||
local cc=board[v[1]][v[2]]
|
local cc=board[v[1]][v[2]]
|
||||||
if isgem(cc) and (cc.super and cc.super~="charge") then
|
if isgem(cc) and (cc.super and cc.super~="charge") then
|
||||||
return
|
return
|
||||||
|
@ -240,11 +244,11 @@ local function check(x,y,rm,oam,obm)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if ac>=3 then
|
if ac>=3 then
|
||||||
for k,v in pairs(am) do rm[k]=v end
|
for k,v in next,am do rm[k]=v end
|
||||||
badboigemcheck(c,am,ac,rm)
|
badboigemcheck(c,am,ac,rm)
|
||||||
end
|
end
|
||||||
if bc>=3 then
|
if bc>=3 then
|
||||||
for k,v in pairs(bm) do rm[k]=v end
|
for k,v in next,bm do rm[k]=v end
|
||||||
badboigemcheck(c,bm,bc,rm)
|
badboigemcheck(c,bm,bc,rm)
|
||||||
end
|
end
|
||||||
return next(rm) and rm,oam,obm
|
return next(rm) and rm,oam,obm
|
||||||
|
@ -274,7 +278,7 @@ local function drawboard(x,y,w,h)
|
||||||
local ttx=font:getWidth(sctext)*tty
|
local ttx=font:getWidth(sctext)*tty
|
||||||
g.translate(bw-ttx,-1.1)
|
g.translate(bw-ttx,-1.1)
|
||||||
g.scale(tty)
|
g.scale(tty)
|
||||||
g.setColor(1,1,1)
|
g.setColor(1,1-taintd,1-taintd)
|
||||||
g.print(sctext)
|
g.print(sctext)
|
||||||
g.pop()
|
g.pop()
|
||||||
if not falltest then
|
if not falltest then
|
||||||
|
@ -296,7 +300,7 @@ local function drawboard(x,y,w,h)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for x,falling in ipairs(falling) do
|
for x,falling in ipairs(falling) do
|
||||||
for fall,_ in pairs(falling) do
|
for fall,_ in next,falling do
|
||||||
for i,c in ipairs(fall.figs) do
|
for i,c in ipairs(fall.figs) do
|
||||||
g.push("all")
|
g.push("all")
|
||||||
local tx,ty=fall.x,fall.y-i+1
|
local tx,ty=fall.x,fall.y-i+1
|
||||||
|
@ -308,7 +312,7 @@ local function drawboard(x,y,w,h)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for v,_ in pairs(booms) do
|
for v,_ in next,booms do
|
||||||
g.push("all")
|
g.push("all")
|
||||||
local tx,ty=v.x,v.y
|
local tx,ty=v.x,v.y
|
||||||
g.translate(tx-0.5,ty-0.5)
|
g.translate(tx-0.5,ty-0.5)
|
||||||
|
@ -322,7 +326,7 @@ local function drawboard(x,y,w,h)
|
||||||
end
|
end
|
||||||
local function fall(l)
|
local function fall(l)
|
||||||
local cols={}
|
local cols={}
|
||||||
for k,v in pairs(l) do
|
for k,v in next,l do
|
||||||
local x,y=unpack(v)
|
local x,y=unpack(v)
|
||||||
cols[x]=cols[x] or {l={},m={}}
|
cols[x]=cols[x] or {l={},m={}}
|
||||||
cols.l[#cols+1]=y
|
cols.l[#cols+1]=y
|
||||||
|
@ -381,7 +385,7 @@ local function kill(x,y,rc)
|
||||||
end
|
end
|
||||||
unfell[x]={}
|
unfell[x]={}
|
||||||
local tt={}
|
local tt={}
|
||||||
for k,v in pairs(falling[x]) do
|
for k,v in next,falling[x] do
|
||||||
tt[#tt+1]=k
|
tt[#tt+1]=k
|
||||||
end
|
end
|
||||||
table.sort(tt,function(a,b)
|
table.sort(tt,function(a,b)
|
||||||
|
@ -412,8 +416,8 @@ local function kill(x,y,rc)
|
||||||
board[x][yls[x]]=mfall.figs[ll]
|
board[x][yls[x]]=mfall.figs[ll]
|
||||||
local ccc=0
|
local ccc=0
|
||||||
if love.keyboard.isDown("f6") then
|
if love.keyboard.isDown("f6") then
|
||||||
for x,falling in pairs(falling) do
|
for x,falling in next,falling do
|
||||||
for fall,_ in pairs(falling) do
|
for fall,_ in next,falling do
|
||||||
falling[fall]=nil
|
falling[fall]=nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -425,8 +429,8 @@ local function kill(x,y,rc)
|
||||||
board[x][yls[x]]=mfall.figs[ll]
|
board[x][yls[x]]=mfall.figs[ll]
|
||||||
if eqgem(mfall.figs[ll],occ) then break end
|
if eqgem(mfall.figs[ll],occ) then break end
|
||||||
end
|
end
|
||||||
for x,uf in pairs(unfell) do
|
for x,uf in next,unfell do
|
||||||
for y,v in pairs(uf) do
|
for y,v in next,uf do
|
||||||
board[x][y]=v[1]
|
board[x][y]=v[1]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -435,7 +439,7 @@ end
|
||||||
killall=function(kills,b,...)
|
killall=function(kills,b,...)
|
||||||
if not kills then return end
|
if not kills then return end
|
||||||
if b then
|
if b then
|
||||||
for k,v in pairs(b) do
|
for k,v in next,b do
|
||||||
kills[k]=v
|
kills[k]=v
|
||||||
end
|
end
|
||||||
return killall(kills,...)
|
return killall(kills,...)
|
||||||
|
@ -447,7 +451,7 @@ killall=function(kills,b,...)
|
||||||
news=false
|
news=false
|
||||||
local ko
|
local ko
|
||||||
kills,ko={},kills
|
kills,ko={},kills
|
||||||
for k,v in pairs(ko) do
|
for k,v in next,ko do
|
||||||
kills[k]=v
|
kills[k]=v
|
||||||
if not seen[k] then
|
if not seen[k] then
|
||||||
local x,y=unpack(v)
|
local x,y=unpack(v)
|
||||||
|
@ -472,7 +476,7 @@ killall=function(kills,b,...)
|
||||||
if isgem(c) then
|
if isgem(c) then
|
||||||
local mks={}
|
local mks={}
|
||||||
megascan(x,y,c,mks)
|
megascan(x,y,c,mks)
|
||||||
for k,v in pairs(mks) do
|
for k,v in next,mks do
|
||||||
if not kills[k] then
|
if not kills[k] then
|
||||||
kills[k]=v
|
kills[k]=v
|
||||||
news=true
|
news=true
|
||||||
|
@ -482,7 +486,7 @@ killall=function(kills,b,...)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for k,v in pairs(kills) do
|
for k,v in next,kills do
|
||||||
tt[#tt+1]=v
|
tt[#tt+1]=v
|
||||||
end
|
end
|
||||||
table.sort(tt,function(a,b)
|
table.sort(tt,function(a,b)
|
||||||
|
@ -496,7 +500,7 @@ killall=function(kills,b,...)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local rm,oam,obm={},{},{}
|
local rm,oam,obm={},{},{}
|
||||||
for k,v in pairs(checks) do
|
for k,v in next,checks do
|
||||||
local x,y=unpack(v)
|
local x,y=unpack(v)
|
||||||
check(x,y,rm,oam,obm)
|
check(x,y,rm,oam,obm)
|
||||||
end
|
end
|
||||||
|
@ -521,8 +525,8 @@ local function dropall(off,die)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if die then
|
if die then
|
||||||
for x,falling in pairs(falling) do
|
for x,falling in next,falling do
|
||||||
for fall,_ in pairs(falling) do
|
for fall,_ in next,falling do
|
||||||
fall.die=true
|
fall.die=true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -547,22 +551,25 @@ local function fillboard()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not next(rm) then break end
|
if not next(rm) then break end
|
||||||
for k,v in pairs(rm) do
|
for k,v in next,rm do
|
||||||
local x,y=unpack(v)
|
local x,y=unpack(v)
|
||||||
board[x][y]=randgem()
|
board[x][y]=randgem()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
dropall(-bh)
|
dropall(-bh)
|
||||||
end
|
end
|
||||||
|
local dbg=false
|
||||||
local function resboard()
|
local function resboard()
|
||||||
cc=3
|
cc=3
|
||||||
score=0
|
score=0
|
||||||
bat=1
|
bat=1
|
||||||
|
if not dbg then
|
||||||
|
taint=0
|
||||||
|
end
|
||||||
gemrng=love.math.newRandomGenerator(991)
|
gemrng=love.math.newRandomGenerator(991)
|
||||||
tochar=bw*bh+gemrng:random(bw)
|
tochar=bw*bh+gemrng:random(bw)
|
||||||
fillboard()
|
fillboard()
|
||||||
end
|
end
|
||||||
local dbg=false
|
|
||||||
local playdbg=false
|
local playdbg=false
|
||||||
|
|
||||||
function love.load()
|
function love.load()
|
||||||
|
@ -697,7 +704,9 @@ function love.mousemoved()
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.update(dt)
|
function love.update(dt)
|
||||||
|
if hookdbg then
|
||||||
ltest=0
|
ltest=0
|
||||||
|
end
|
||||||
dt=math.min(dt,0.2)*(speeds[slow])
|
dt=math.min(dt,0.2)*(speeds[slow])
|
||||||
accumdt=math.min(0.6,accumdt+dt)
|
accumdt=math.min(0.6,accumdt+dt)
|
||||||
local fcc=0
|
local fcc=0
|
||||||
|
@ -726,7 +735,7 @@ function love.update(dt)
|
||||||
board[px][py],board[ix][iy]
|
board[px][py],board[ix][iy]
|
||||||
local kills=check(ix,iy,check(px,py))
|
local kills=check(ix,iy,check(px,py))
|
||||||
local kc=0
|
local kc=0
|
||||||
for k,v in pairs(kills or {}) do
|
for k,v in next,kills or {} do
|
||||||
if v[3] and v[3].super=="color" then
|
if v[3] and v[3].super=="color" then
|
||||||
kc=kc+50
|
kc=kc+50
|
||||||
elseif v[3] then
|
elseif v[3] then
|
||||||
|
@ -756,6 +765,7 @@ function love.update(dt)
|
||||||
bat=math.max(0,bat-dt*0.015*(math.max(bat,0.0625)^0.5))
|
bat=math.max(0,bat-dt*0.015*(math.max(bat,0.0625)^0.5))
|
||||||
batd=interp(batd,bat,dt)
|
batd=interp(batd,bat,dt)
|
||||||
scored=interp(scored,score,dt)
|
scored=interp(scored,score,dt)
|
||||||
|
taintd=interp(taintd,taint,dt)
|
||||||
end
|
end
|
||||||
if bat==0 and not dying then
|
if bat==0 and not dying then
|
||||||
dying=true
|
dying=true
|
||||||
|
@ -764,7 +774,7 @@ function love.update(dt)
|
||||||
animc=0
|
animc=0
|
||||||
entc=0
|
entc=0
|
||||||
boomc=0
|
boomc=0
|
||||||
for k,v in pairs(anims) do
|
for k,v in next,anims do
|
||||||
animc=animc+1
|
animc=animc+1
|
||||||
v.cx=interp(v.cx,v.tx,dt*2)
|
v.cx=interp(v.cx,v.tx,dt*2)
|
||||||
v.cy=interp(v.cy,v.ty,dt*2)
|
v.cy=interp(v.cy,v.ty,dt*2)
|
||||||
|
@ -775,12 +785,12 @@ function love.update(dt)
|
||||||
local tk={}
|
local tk={}
|
||||||
if running then
|
if running then
|
||||||
for x,falling in ipairs(falling) do
|
for x,falling in ipairs(falling) do
|
||||||
for fall,_ in pairs(falling) do
|
for fall,_ in next,falling do
|
||||||
entc=entc+1
|
entc=entc+1
|
||||||
fall.vel=fall.vel+dt*gacc
|
fall.vel=fall.vel+dt*gacc
|
||||||
fall.y=fall.y+fall.vel*dt
|
fall.y=fall.y+fall.vel*dt
|
||||||
local iy=math.floor(fall.y)
|
local iy=math.floor(fall.y)
|
||||||
for fallb,_ in pairs(falling) do
|
for fallb,_ in next,falling do
|
||||||
if fall~=fallb and inters(
|
if fall~=fallb and inters(
|
||||||
fall.y-#fall.figs+1-0.5,fall.y+0.5,
|
fall.y-#fall.figs+1-0.5,fall.y+0.5,
|
||||||
fallb.y-#fallb.figs+1-0.5,fallb.y+0.5
|
fallb.y-#fallb.figs+1-0.5,fallb.y+0.5
|
||||||
|
@ -842,7 +852,7 @@ function love.update(dt)
|
||||||
local good=false
|
local good=false
|
||||||
for ix=1,bw do
|
for ix=1,bw do
|
||||||
for iy=1,bh do
|
for iy=1,bh do
|
||||||
for _,a in pairs{{1,0},{-1,0},{0,1},{0,-1}} do
|
for _,a in next,{{1,0},{-1,0},{0,1},{0,-1}} do
|
||||||
local px,py=ix+a[1],iy+a[2]
|
local px,py=ix+a[1],iy+a[2]
|
||||||
if px>=1 and py>=1 and px<=bw and py<=bh then
|
if px>=1 and py>=1 and px<=bw and py<=bh then
|
||||||
board[ix][iy],board[px][py]=
|
board[ix][iy],board[px][py]=
|
||||||
|
@ -858,12 +868,12 @@ function love.update(dt)
|
||||||
toplchi=plchint
|
toplchi=plchint
|
||||||
end
|
end
|
||||||
local oam,obm,rm={},{},{}
|
local oam,obm,rm={},{},{}
|
||||||
for k,v in pairs(tk) do
|
for k,v in next,tk do
|
||||||
local x,y=unpack(v)
|
local x,y=unpack(v)
|
||||||
check(x,y,rm,oam,obm)
|
check(x,y,rm,oam,obm)
|
||||||
end
|
end
|
||||||
killall(rm)
|
killall(rm)
|
||||||
for v,_ in pairs(booms) do
|
for v,_ in next,booms do
|
||||||
boomc=boomc+1
|
boomc=boomc+1
|
||||||
v.a=v.a-dt/math.abs(v.a)*4
|
v.a=v.a-dt/math.abs(v.a)*4
|
||||||
if v.a<=0.01 then
|
if v.a<=0.01 then
|
||||||
|
@ -885,22 +895,26 @@ function love.keypressed(k)
|
||||||
if dbg and tonumber(k) then
|
if dbg and tonumber(k) then
|
||||||
print(gobjs[tonumber(k)],tonumber(k))
|
print(gobjs[tonumber(k)],tonumber(k))
|
||||||
board[x][y]=gobjs[tonumber(k)] or board[x][y]
|
board[x][y]=gobjs[tonumber(k)] or board[x][y]
|
||||||
|
taint=1
|
||||||
end
|
end
|
||||||
if dbg and isgem(board[x][y]) then
|
if dbg and isgem(board[x][y]) then
|
||||||
local c=board[x][y].c
|
local c=board[x][y].c
|
||||||
if k=="h" then
|
if k=="h" then
|
||||||
board[x][y]=cgobjs[c]
|
board[x][y]=cgobjs[c]
|
||||||
|
taint=1
|
||||||
elseif k=="j" then
|
elseif k=="j" then
|
||||||
board[x][y]=lgobjs[c]
|
board[x][y]=lgobjs[c]
|
||||||
|
taint=1
|
||||||
elseif k=="k" then
|
elseif k=="k" then
|
||||||
board[x][y]=mgobjs[c]
|
board[x][y]=mgobjs[c]
|
||||||
|
taint=1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if k=="f2" then
|
if k=="f2" and dbg then
|
||||||
yes=not yes
|
yes=not yes
|
||||||
elseif k=="f3" then
|
elseif k=="f3" then
|
||||||
dbg=not dbg
|
dbg=not dbg
|
||||||
elseif k=="f4" then
|
elseif k=="f4" and dbg then
|
||||||
local unfell={}
|
local unfell={}
|
||||||
local yls={}
|
local yls={}
|
||||||
local cx=x
|
local cx=x
|
||||||
|
@ -914,7 +928,7 @@ function love.keypressed(k)
|
||||||
end
|
end
|
||||||
unfell[x]={}
|
unfell[x]={}
|
||||||
local tt={}
|
local tt={}
|
||||||
for k,v in pairs(falling[x]) do
|
for k,v in next,falling[x] do
|
||||||
tt[#tt+1]=k
|
tt[#tt+1]=k
|
||||||
end
|
end
|
||||||
table.sort(tt,function(a,b)
|
table.sort(tt,function(a,b)
|
||||||
|
@ -930,16 +944,22 @@ function love.keypressed(k)
|
||||||
end
|
end
|
||||||
yls[x]=yl
|
yls[x]=yl
|
||||||
end
|
end
|
||||||
elseif k=="f5" then
|
taint=1
|
||||||
|
elseif k=="f5" and dbg then
|
||||||
slow=slow%3+1
|
slow=slow%3+1
|
||||||
elseif k=="f7" then
|
taint=1
|
||||||
|
elseif k=="f7" and dbg then
|
||||||
falltest=not falltest
|
falltest=not falltest
|
||||||
elseif k=="f8" then
|
taint=1
|
||||||
|
elseif k=="f8" and dbg then
|
||||||
bat=bat*0.25
|
bat=bat*0.25
|
||||||
elseif k=="f9" then
|
taint=1
|
||||||
|
elseif k=="f9" and dbg then
|
||||||
bat=bat*2
|
bat=bat*2
|
||||||
elseif k=="f10" then
|
taint=1
|
||||||
|
elseif k=="f10" and dbg then
|
||||||
playdbg=not playdbg
|
playdbg=not playdbg
|
||||||
|
taint=1
|
||||||
elseif k=="f11" then
|
elseif k=="f11" then
|
||||||
love.window.setFullscreen(not love.window.getFullscreen())
|
love.window.setFullscreen(not love.window.getFullscreen())
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue