fix something idk

This commit is contained in:
Kimapr 2023-03-30 06:52:00 +05:00
parent c761e5bb40
commit b6c7b0a06c

114
main.lua
View file

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