Skip to content

Commit

Permalink
arm小程序删除答错自动清空
Browse files Browse the repository at this point in the history
整理代码 框架跟进
  • Loading branch information
MrZ626 committed Aug 11, 2023
1 parent 540099a commit 3fbff37
Show file tree
Hide file tree
Showing 27 changed files with 149 additions and 157 deletions.
2 changes: 1 addition & 1 deletion Zframework
Submodule Zframework updated 4 files
+2 −2 sfx.lua
+16 −16 stringExtend.lua
+3 −3 text.lua
+11 −11 widget.lua
4 changes: 2 additions & 2 deletions parts/backgrounds/lanterns.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- A lantern background which is full of festive atmosphere. Lantern image by ScF
local int,rnd=math.floor,math.random
local floor,rnd=math.floor,math.random
local ins,rem=table.insert,table.remove
local mDraw=mDraw
local back={}
Expand Down Expand Up @@ -41,7 +41,7 @@ function back.draw()
local img=IMG.lanterns
for i=1,#lanterns do
local L=lanterns[i]
mDraw(img[int(L.phase*6)+1],L.x,L.y,nil,L.size)
mDraw(img[floor(L.phase*6)+1],L.x,L.y,nil,L.size)
end
end
return back
4 changes: 2 additions & 2 deletions parts/backgrounds/lightning2.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Fast lightning + spining tetromino
local int,rnd=math.floor,math.random
local floor,rnd=math.floor,math.random
local back={}

local t
Expand All @@ -12,7 +12,7 @@ function back.update(dt)
t=t+dt
end
function back.draw()
local R=7-int(t*.5%7)
local R=7-floor(t*.5%7)
local T=1.2-t%15%6%1.8
if T<.26 then GC.clear(T,T,T)
else GC.clear(0,0,0)
Expand Down
12 changes: 6 additions & 6 deletions parts/data.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local int=math.floor
local floor=math.floor
local char,byte=string.char,string.byte
local ins=table.insert

Expand Down Expand Up @@ -120,7 +120,7 @@ function DATA.pasteBoard(str,page)-- Paste [str] data to [page] board

local id=b%32-1-- Block id
if id>26 then return end-- Illegal blockid
b=int(b/32)-- Mode id
b=floor(b/32)-- Mode id

F[fY][fX]=id
if fX<10 then
Expand Down Expand Up @@ -265,10 +265,10 @@ function DATA.dumpRecording(list,ptr)
prevFrm=list[ptr]
if t>=128 then
buffer2=char(t%128)
t=int(t/128)
t=floor(t/128)
while t>=128 do
buffer2=char(128+t%128)..buffer2
t=int(t/128)
t=floor(t/128)
end
buffer=buffer..char(128+t)..buffer2
else
Expand All @@ -279,10 +279,10 @@ function DATA.dumpRecording(list,ptr)
t=list[ptr+1]
if t>=128 then
buffer2=char(t%128)
t=int(t/128)
t=floor(t/128)
while t>=128 do
buffer2=char(128+t%128)..buffer2
t=int(t/128)
t=floor(t/128)
end
buffer=buffer..char(128+t)..buffer2
else
Expand Down
4 changes: 2 additions & 2 deletions parts/gameFuncs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local gc_setShader=GC.setShader
local gc_draw,gc_rectangle,gc_printf=GC.draw,GC.rectangle,GC.printf

local ins,rem=table.insert,table.remove
local int,rnd=math.floor,math.random
local floor,rnd=math.floor,math.random
local approach=MATH.expApproach

local SETTING,GAME,SCR=SETTING,GAME,SCR
Expand Down Expand Up @@ -283,7 +283,7 @@ function royaleLevelup()
if GAME.curMode.name:find("_u") then
for i=1,#PLY_ALIVE do
local P=PLY_ALIVE[i]
P.gameEnv.drop=int(P.gameEnv.drop*.4)
P.gameEnv.drop=floor(P.gameEnv.drop*.4)
if P.gameEnv.drop==0 then
P.curY=P.ghoY
P:set20G(true)
Expand Down
22 changes: 11 additions & 11 deletions parts/player/draw.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local gc_print,gc_printf=gc.print,gc.printf
local gc_setColor,gc_setLineWidth=gc.setColor,gc.setLineWidth
local gc_stencil,gc_setStencilTest=gc.stencil,gc.setStencilTest

local int,ceil,rnd=math.floor,math.ceil,math.random
local floor,ceil,rnd=math.floor,math.ceil,math.random
local max,min,sin,modf=math.max,math.min,math.sin,math.modf
local setFont=FONT.set
local SKIN,TEXTURE,IMG=SKIN,TEXTURE,IMG
Expand Down Expand Up @@ -124,8 +124,8 @@ local function _applyField(P)

-- Apply shaking
if P.shakeTimer>0 then
local dx=int(P.shakeTimer/2)
local dy=int(P.shakeTimer/3)
local dx=floor(P.shakeTimer/2)
local dy=floor(P.shakeTimer/3)
gc_translate(dx^1.6*(dx%2*2-1)*(P.gameEnv.shakeFX+1)/30,dy^1.4*(dy%2*2-1)*(P.gameEnv.shakeFX+1)/30)
end

Expand Down Expand Up @@ -172,7 +172,7 @@ end
local function _drawField(P,showInvis)
local ENV=P.gameEnv
local V,F=P.visTime,P.field
local start=int((P.fieldBeneath+P.fieldUp)/30+1)
local start=floor((P.fieldBeneath+P.fieldUp)/30+1)
local texture=P.skinLib
if P.falling==0 then-- Blocks only
if ENV.upEdge then
Expand Down Expand Up @@ -358,9 +358,9 @@ local function _drawBlock(CB,curX,curY,texture)
end
local function _drawNextPreview(B,fieldH,fieldBeneath)
gc_setColor(1,1,1,.8)
local y=int(fieldH+1-modf(B.RS.centerPos[B.id][B.dir][1]))+ceil(fieldBeneath/30)
local y=floor(fieldH+1-modf(B.RS.centerPos[B.id][B.dir][1]))+ceil(fieldBeneath/30)
B=B.bk
local x=int(6-#B[1]*.5)
local x=floor(6-#B[1]*.5)
local cross=TEXTURE.puzzleMark[-1]
for i=1,#B do for j=1,#B[1] do
if B[i][j] then
Expand All @@ -370,9 +370,9 @@ local function _drawNextPreview(B,fieldH,fieldBeneath)
end
local function _drawHoldPreview(B,fieldH,fieldBeneath)
gc_setColor(1,1,1,.3)
local y=int(fieldH+1-modf(B.RS.centerPos[B.id][B.dir][1]))+ceil(fieldBeneath/30)+.14
local y=floor(fieldH+1-modf(B.RS.centerPos[B.id][B.dir][1]))+ceil(fieldBeneath/30)+.14
B=B.bk
local x=int(6-#B[1]*.5)
local x=floor(6-#B[1]*.5)
local cross=TEXTURE.puzzleMark[-1]
for i=1,#B do for j=1,#B[1] do
if B[i][j] then
Expand Down Expand Up @@ -431,7 +431,7 @@ local function _drawBuffer(atkBuffer,bufferWarn,atkBufferSum1,atkBufferSum)
gc_translate(d^.5*(rnd()-.5)*15,d^.5*(rnd()-.5)*15)
end
end
gc_printf(int(sum),-300,-20,292,'right')
gc_printf(floor(sum),-300,-20,292,'right')
gc_pop()
end
end
Expand Down Expand Up @@ -614,7 +614,7 @@ local _drawDial do
else
gc.circle('line',x+40,y+40,37)
end
setFont(30)GC.mStr(int(speed),x+40,y+19)
setFont(30)GC.mStr(floor(speed),x+40,y+19)
end
end
local function _drawFinesseCombo_norm(P)
Expand Down Expand Up @@ -709,7 +709,7 @@ local function _drawStartCounter(time)
gc_push('transform')
gc_translate(300,300)
local r,g,b
local num=int(time/60)+1
local num=floor(time/60)+1
local d=time%60
if num==3 then
r,g,b=.7,.8,.98
Expand Down
52 changes: 26 additions & 26 deletions parts/player/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

local Player={}-- Player class

local int,ceil,rnd=math.floor,math.ceil,math.random
local floor,ceil,rnd=math.floor,math.ceil,math.random
local max,min,abs,modf=math.max,math.min,math.abs,math.modf
local assert,ins,rem=assert,table.insert,table.remove
local resume,yield,status=coroutine.resume,coroutine.yield,coroutine.status
Expand Down Expand Up @@ -42,7 +42,7 @@ function Player:_rotateField(dir)
end
function Player:shakeField(strength)-- Range: 1~10
if self.gameEnv.shakeFX then
self.shakeTimer=max(self.shakeTimer,3*self.gameEnv.shakeFX+int(4*min(max(strength,1),10)))
self.shakeTimer=max(self.shakeTimer,3*self.gameEnv.shakeFX+floor(4*min(max(strength,1),10)))
end
end
function Player:checkTouchSound()
Expand Down Expand Up @@ -198,7 +198,7 @@ function Player:createBeam(R,send)
local r,g,b=c[1]*2,c[2]*2,c[3]*2
local a=(power+2)*.0626
if self.type~='human' and R.type~='human' then a=a*.2 end
SYSFX.newAttack(1-power*.1,x1,y1,x2,y2,int(send^.7*(4+power)),r,g,b,a)
SYSFX.newAttack(1-power*.1,x1,y1,x2,y2,floor(send^.7*(4+power)),r,g,b,a)
end
end
--------------------------</FX>--------------------------
Expand Down Expand Up @@ -874,7 +874,7 @@ function Player:receive(A,send,time,line)
cd0=time,
time=0,
sent=false,
lv=min(int(send^.69),5),
lv=min(floor(send^.69),5),
})-- Sorted insert(by time)
self.atkBufferSum=self.atkBufferSum+send
self.stat.recv=self.stat.recv+send
Expand Down Expand Up @@ -1127,7 +1127,7 @@ function Player:_checkMission(piece,mission)
elseif mission==9 then
return piece.pc
elseif mission<90 then
return piece.row==mission%10 and piece.name==int(mission/10) and piece.spin
return piece.row==mission%10 and piece.name==floor(mission/10) and piece.spin
end
return false
end
Expand All @@ -1148,8 +1148,8 @@ function Player:resetBlock()-- Reset Block's position and execute I*S
local C=self.cur
local sc=C.RS.centerPos[C.id][C.dir]

self.curX=int(6-#C.bk[1]*.5)
local y=int(self.gameEnv.fieldH+1-modf(sc[1]))+ceil(self.fieldBeneath/30)
self.curX=floor(6-#C.bk[1]*.5)
local y=floor(self.gameEnv.fieldH+1-modf(sc[1]))+ceil(self.fieldBeneath/30)
self.curY=y
self.minY=y+sc[1]

Expand Down Expand Up @@ -1191,7 +1191,7 @@ end

function Player:getNextSpawn()
local cur = self.nextQueue[1]
return int(self.gameEnv.fieldH+1-modf(cur.RS.centerPos[cur.id][cur.dir][1]))+ceil(self.fieldBeneath/30)
return floor(self.gameEnv.fieldH+1-modf(cur.RS.centerPos[cur.id][cur.dir][1]))+ceil(self.fieldBeneath/30)
end

function Player:spin(d,ifpre)
Expand Down Expand Up @@ -1275,9 +1275,9 @@ function Player:hold_norm(ifpre)
x=x+(#C.bk[1]-#H.bk[1])*.5
y=y+(#C.bk-#H.bk)*.5

local iki=phyHoldKickX[x==int(x)]
local iki=phyHoldKickX[x==floor(x)]
local success
for Y=int(y),ceil(y+.5) do
for Y=floor(y),ceil(y+.5) do
for i=1,#iki do
local X=x+iki[i]
if not self:ifoverlap(H.bk,X,Y) then
Expand Down Expand Up @@ -1321,7 +1321,7 @@ function Player:hold_norm(ifpre)
self:_checkSuffocate()
end

self.freshTime=int(min(self.freshTime+ENV.freshLimit*.25,ENV.freshLimit*((self.holdTime+1)/ENV.holdCount),ENV.freshLimit))
self.freshTime=floor(min(self.freshTime+ENV.freshLimit*.25,ENV.freshLimit*((self.holdTime+1)/ENV.holdCount),ENV.freshLimit))
if not ENV.infHold then
self.holdTime=self.holdTime-1
end
Expand All @@ -1344,9 +1344,9 @@ function Player:hold_swap(ifpre)
x=x+(#C.bk[1]-#H.bk[1])*.5
y=y+(#C.bk-#H.bk)*.5

local iki=phyHoldKickX[x==int(x)]
local iki=phyHoldKickX[x==floor(x)]
local success
for Y=int(y),ceil(y+.5) do
for Y=floor(y),ceil(y+.5) do
for i=1,#iki do
local X=x+iki[i]
if not self:ifoverlap(H.bk,X,Y) then
Expand Down Expand Up @@ -1386,7 +1386,7 @@ function Player:hold_swap(ifpre)
self:_checkSuffocate()
end

self.freshTime=int(min(self.freshTime+ENV.freshLimit*.25,ENV.freshLimit*((self.holdTime+1)/ENV.holdCount),ENV.freshLimit))
self.freshTime=floor(min(self.freshTime+ENV.freshLimit*.25,ENV.freshLimit*((self.holdTime+1)/ENV.holdCount),ENV.freshLimit))
if not ENV.infHold then
self.holdTime=self.holdTime-1
end
Expand Down Expand Up @@ -1847,7 +1847,7 @@ do
self:showText(text.clear[cc],0,-30,35,'appear',(8-cc)*.3)
yomi = text.clear[cc]..yomi
atk=cc-.5
sendTime=20+int(atk*20)
sendTime=20+floor(atk*20)
cscore=cscore+clearSCR[cc]
piece.special=false
end
Expand Down Expand Up @@ -1925,10 +1925,10 @@ do
end

-- Send Lines
atk=int(atk*(1+self.strength*.25))-- Badge Buff
atk=floor(atk*(1+self.strength*.25))-- Badge Buff
send=atk
if exblock>0 then
exblock=int(exblock*(1+self.strength*.25))-- Badge Buff
exblock=floor(exblock*(1+self.strength*.25))-- Badge Buff
self:showText("+"..exblock,0,53,20,'fly')
off=off+self:cancel(exblock)
end
Expand Down Expand Up @@ -2017,7 +2017,7 @@ do
cscore=cscore*(.9+self.dropSpeed/600)
end

cscore=int(cscore)
cscore=floor(cscore)
self:popScore(cscore)

piece.row,piece.dig=cc,gbcc
Expand Down Expand Up @@ -2049,7 +2049,7 @@ do
-- Prevent sudden death if hang>0
if ENV.hang>ENV.wait and self.nextQueue[1] then
local B=self.nextQueue[1]
if self:ifoverlap(B.bk,int(6-#B.bk[1]*.5),int(ENV.fieldH+1-modf(B.RS.centerPos[B.id][B.dir][1]))+ceil(self.fieldBeneath/30)) then
if self:ifoverlap(B.bk,floor(6-#B.bk[1]*.5),floor(ENV.fieldH+1-modf(B.RS.centerPos[B.id][B.dir][1]))+ceil(self.fieldBeneath/30)) then
self.waiting=self.waiting+ENV.hang
end
end
Expand All @@ -2075,7 +2075,7 @@ do
if atk>0 then
Stat.atk=Stat.atk+atk
if send>0 then
Stat.send=Stat.send+int(send)
Stat.send=Stat.send+floor(send)
end
if off>0 then
Stat.off=Stat.off+off
Expand Down Expand Up @@ -2642,9 +2642,9 @@ local function update_streaming(P)
P:releaseKey(event-32)
elseif event>0x2000000000000 then-- Sending lines
local sid=event%0x100
local amount=int(event/0x100)%0x100
local time=int(event/0x10000)%0x10000
local line=int(event/0x100000000)%0x10000
local amount=floor(event/0x100)%0x100
local time=floor(event/0x10000)%0x10000
local line=floor(event/0x100000000)%0x10000
for _,p in next,PLY_ALIVE do
if p.sid==sid then
P.netAtk=P.netAtk+amount
Expand All @@ -2665,9 +2665,9 @@ local function update_streaming(P)
if p.sid==sid then
P:receive(
p,
int(event/0x100)%0x100,-- amount
int(event/0x10000)%0x10000,-- time
int(event/0x100000000)%0x10000-- line
floor(event/0x100)%0x100,-- amount
floor(event/0x10000)%0x10000,-- time
floor(event/0x100000000)%0x10000-- line
)
break
end
Expand Down
4 changes: 2 additions & 2 deletions parts/scenes/app_15p.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local gc=love.graphics

local int,rnd=math.floor,math.random
local floor,rnd=math.floor,math.random

local scene={}

Expand Down Expand Up @@ -81,7 +81,7 @@ local function tapBoard(x,y,key)
if pathVis then
SYSFX.newShade(6,x-5,y-5,11,11,1,1,1)
end
x,y=int((x-320)/160)+1,int((y-40)/160)+1
x,y=floor((x-320)/160)+1,floor((y-40)/160)+1
end
local b=board
local moves=0
Expand Down
6 changes: 3 additions & 3 deletions parts/scenes/app_2048.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local gc,kb=love.graphics,love.keyboard
local setColor,rectangle=gc.setColor,gc.rectangle

local int,abs=math.floor,math.abs
local floor,abs=math.floor,math.abs
local rnd,min=math.random,math.min
local ins=table.insert
local setFont=FONT.set
Expand Down Expand Up @@ -400,7 +400,7 @@ function scene.draw()
-- Board
for i=1,16 do
if board[i] then
local x,y=1+(i-1)%4,int((i+3)/4)
local x,y=1+(i-1)%4,floor((i+3)/4)
local N=board[i]
if i~=prevPos or prevSpawnTime==1 then
if not invis or i==prevPos then
Expand Down Expand Up @@ -460,7 +460,7 @@ function scene.draw()
end

-- New tile position
local x,y=1+(prevPos-1)%4,int((prevPos+3)/4)
local x,y=1+(prevPos-1)%4,floor((prevPos+3)/4)
gc.setLineWidth(8)
setColor(.2,.8,0,prevSpawnTime)
local d=25-prevSpawnTime*25
Expand Down
Loading

0 comments on commit 3fbff37

Please sign in to comment.