Skip to content

Commit

Permalink
修琼晶打攻击就闪退
Browse files Browse the repository at this point in the history
整理代码
  • Loading branch information
MrZ626 committed May 18, 2024
1 parent 143d550 commit c80f513
Show file tree
Hide file tree
Showing 11 changed files with 241 additions and 12 deletions.
File renamed without changes.
9 changes: 7 additions & 2 deletions assets/game/gelaPlayer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,8 @@ function GP:gelaDropped() -- Drop & lock gela, and trigger a lot of things
-- Update field
self:updField()

self:triggerEvent('beforeDiscard')

-- Discard hand
self.hand=false
if self.finished then return end
Expand Down Expand Up @@ -827,7 +829,7 @@ function GP:checkClear()
local g=self.garbageBuffer[i]
if not g then break end
if g._time==g.time then
self:dropGarbage(g.power*2)
self:dropGarbage(g.power)
rem(self.garbageBuffer,i)
self.garbageSum=self.garbageSum-g.power
i=i-1 -- Avoid index error
Expand Down Expand Up @@ -925,7 +927,7 @@ function GP:dropGarbage(count)
F:setCell({
color=555,
diggable=true,
},table.remove(pos,GP:random(w+1-n)),curGenY)
},table.remove(pos,self:random(w+1-n)),curGenY)
end
end
end
Expand Down Expand Up @@ -1493,6 +1495,9 @@ function GP.new()
afterDrop={},
afterLock={},
afterClear={},
beforeCancel={},
beforeSend={},
beforeDiscard={},

-- Update
always={},
Expand Down
2 changes: 1 addition & 1 deletion assets/game/rectField.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function F:drawThumbnail_color(step,size)
for x=1,self._width do
local c=f[y][x]
if c then
gc.setColor(NumColor[c.color])
gc.setColor(CLR9[c.color])
gc.rectangle('fill',(x-1)*step,-y*step,size,size)
end
end
Expand Down
2 changes: 1 addition & 1 deletion assets/scene/tutorial_rotate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ end
local size=60
function scene.draw()
GC.replaceTransform(SCR.xOy_m)
GC.setColor(NumColor[defaultBrikColor[handID]])
GC.setColor(CLR9[defaultBrikColor[handID]])

-- Hand shape
GC.translate(-#handMat*size/2,-#handMat*size/2-250)
Expand Down
4 changes: 2 additions & 2 deletions assets/scene/tutorial_shape.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ local function newQuestion()
local piece=Brik.get(choices[i])
choices[i]={
shape=TABLE.copy(piece.shape),
color=NumColor[defaultBrikColor[piece.id]],
color=CLR9[defaultBrikColor[piece.id]],
correct=i==1,
}
if level==2 then
Expand Down Expand Up @@ -224,7 +224,7 @@ function scene.draw()
GC.line(-len*30,y,len*30,y)
end
-- Field
GC.setColor(NumColor[-1])
GC.setColor(CLR9[-1])
for i=1,len do
GC.rectangle('fill',60*(i-1-len/2),380,60,-60*quest[i])
end
Expand Down
2 changes: 1 addition & 1 deletion assets/skin/brik_plastic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local gc_setColor=gc.setColor
local gc_rectangle=gc.rectangle

local unpack=unpack
local NumColor=NumColor
local NumColor=CLR9

---@type Techmino.Skin.Brik
local S={}
Expand Down
2 changes: 1 addition & 1 deletion assets/skin/brik_template.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ local stc_reset,stc_rect,stc_stop=GC.stc_reset,GC.stc_rect,GC.stc_stop
local max,min=math.max,math.min

local COLOR=COLOR
local NumColor=NumColor
local NumColor=CLR9

---@type Techmino.Skin.Brik
local S={}
Expand Down
2 changes: 1 addition & 1 deletion assets/skin/gela_jelly.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local gc=love.graphics
local gc_setColor=gc.setColor
local gc_rectangle,gc_polygon=gc.rectangle,gc.polygon

local NumColor=NumColor
local NumColor=CLR9

---@type Techmino.Skin.Gela
local S={}
Expand Down
2 changes: 1 addition & 1 deletion assets/skin/gela_template.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local gc_setColor=gc.setColor
local gc_rectangle=gc.rectangle
local gc_setLineWidth=gc.setLineWidth

local NumColor=NumColor
local NumColor=CLR9

---@type Techmino.Skin.Gela
local S={}
Expand Down
224 changes: 224 additions & 0 deletions assets/skin/touhou/brik_reimu.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
--[[
Base on brik_template:
]]
local gc=love.graphics
local gc_push,gc_pop=gc.push,gc.pop
local gc_scale,gc_rotate=gc.scale,gc.rotate
local gc_setColor,gc_setLineWidth=gc.setColor,gc.setLineWidth
local gc_draw,gc_line=gc.draw,gc.line
local gc_rectangle,gc_circle,gc_polygon=gc.rectangle,gc.circle,gc.polygon
local gc_setShader=gc.setShader

local stc_reset,stc_rect,stc_stop=GC.stc_reset,GC.stc_rect,GC.stc_stop

local max,min=math.max,math.min

local COLOR=COLOR

---@type Techmino.Skin.Brik
local S={}
S.base='brik_template'

local X=5 -- Cell border width

local function drawCell(B,x,y,r,g,b,a)
gc_setColor(r,g,b,a)
gc_rectangle('fill',0,0,40,40)
gc_setColor(r*.8,g*.8,b*.8,a)
gc_polygon('fill',X,X,X,40-X,15,40-X,25,X)

gc_circle('fill',28,20+6,4)
gc_setColor(r,g,b,a)
gc_circle('fill',12,20-6,4)

gc_setColor(r*.626,g*.626,b*.626,(B[y+1] and B[y+1][x ]) and a*0.3 or a) gc_rectangle('fill', 0, 0,40, X)
gc_setColor(r*.626,g*.626,b*.626,(B[y ] and B[y ][x-1]) and a*0.3 or a) gc_rectangle('fill', 0, 0, X,40)
gc_setColor(r*.626,g*.626,b*.626,(B[y-1] and B[y-1][x ]) and a*0.3 or a) gc_rectangle('fill', 0,40,40,-X)
gc_setColor(r*.626,g*.626,b*.626,(B[y ] and B[y ][x+1]) and a*0.3 or a) gc_rectangle('fill',40, 0,-X,40)
end
local crossR=1
local gridMark=(function()
local l={40,40}
for x=0,39 do
table.insert(l,{'setCL',1,1,1,.062+(math.abs(19.5-x)/62)^1.62})
table.insert(l,{'fRect',x,0, 1,crossR})
table.insert(l,{'fRect',x,39,1,crossR})
end
for y=1,38 do
table.insert(l,{'setCL',1,1,1,.062+(math.abs(19.5-y)/62)^1.62})
table.insert(l,{'fRect',0, y,crossR,1})
table.insert(l,{'fRect',39,y,crossR,1})
end
return GC.load(l)
end)()
function S.drawFieldBackground(fieldW)
gc_setColor(0,0,0,.42)
gc_rectangle('fill',0,0,40*fieldW,-80*fieldW)
gc_setColor(1,1,1)
for x=1,fieldW do for y=1,2*fieldW do
gc_draw(gridMark,x*40-40,-y*40)
end end
end
function S.drawFieldBorder()
gc_setLineWidth(2)

gc_setColor(1,.6,.6,.626)
gc_line(-201,-401,-181,-401)

gc_setColor(1,.7,.7)
gc_line(-201,-401,-201,401)
gc_setColor(1,.8,.8)
gc_line(-201,401,201,401)
gc_setColor(1,.9,.9)
gc_line(201,401,201,-401)

gc_setColor(1,1,1,.626)
gc_line(201,-401,181,-401)
end

local function getCID(F,y,x)
local line=F[y]
return line and line[x] and line[x].cid or false
end
function S.drawFieldCell(C,F,x,y)
local r,g,b=unpack(CLR9[C.color])
local a=C.alpha or 1
gc_setColor(r,g,b,a)
gc_rectangle('fill',0,0,40,40)
gc_setColor(r*.8,g*.8,b*.8,a)
gc_polygon('fill',X,X,X,40-X,15,40-X,25,X)

gc_circle('fill',28,20+6,4)
gc_setColor(r,g,b,a)
gc_circle('fill',12,20-6,4)

local c=C.conn
if c then
gc_setColor(r*.626,g*.626,b*.626,c[getCID(F,y+1,x )] and a*.3 or a) gc_rectangle('fill', 0, 0,40, X)
gc_setColor(r*.626,g*.626,b*.626,c[getCID(F,y ,x+1)] and a*.3 or a) gc_rectangle('fill',40, 0,-X,40)
gc_setColor(r*.626,g*.626,b*.626,c[getCID(F,y ,x-1)] and a*.3 or a) gc_rectangle('fill', 0, 0, X,40)
gc_setColor(r*.626,g*.626,b*.626,c[getCID(F,y-1,x )] and a*.3 or a) gc_rectangle('fill', 0,40,40,-X)
end
end
-- function S.drawFloatHold(C,disabled,B,handX,handY)
-- -- TODO
-- end
-- function S.drawHeightLines(fieldW,maxSpawnH,spawnH,lockoutH,deathH,voidH)
-- -- TODO
-- end
-- function S.drawAsdIndicator(dir,charge,asdMax,aspMax,ash)
-- -- TODO
-- end
-- function S.drawDelayIndicator(color,value)
-- -- TODO
-- end
-- function S.drawGarbageBuffer(garbageBuffer)
-- -- TODO
-- end
local batch=gc.newSpriteBatch(IMG.touhou.ball,15)
for i=1,15 do batch:add(-214+26*i,418) end
local color2map={
any=COLOR.L,
fall=COLOR.R,
none=COLOR.D,
}
function S.drawLockDelayIndicator(freshCondition,freshChance,timeRem)
if timeRem>0 then
gc_setColor(COLOR.hsv(timeRem/2.6,.4,.9,.62))
gc_rectangle('fill',-200,415,400*timeRem,22)
end
if freshChance>0 then
gc_setColor(1,1,1,.42)
for i=1,freshChance do gc_rectangle('fill',-214+26*i,418,16,16) end

stc_reset()
stc_rect(-200,415,400*timeRem,22)
SHADER.dualColor:send('color1',COLOR.hsv((freshChance-1)/14/2.6,.6,.8))
SHADER.dualColor:send('color2',unpack(color2map[freshCondition]))
gc_setShader(SHADER.dualColor)
batch:setDrawRange(1,freshChance)
gc_draw(batch)
gc_setShader()
stc_stop()
end
end

function S.drawGhostCell(C,B,x,y)
local r,g,b=unpack(CLR9[C.color])
drawCell(B,x,y,r,g,b,.26)
end

function S.drawHandCell(C,B,x,y)
local r,g,b=unpack(CLR9[C.color])
drawCell(B,x,y,r,g,b,1)
end

local disabledColor={.6,.6,.6}

-- function S.drawNextBorder(mode)
-- TODO
-- end
function S.drawNextCell(C,disabled,B,x,y)
local r,g,b=unpack(disabled and disabledColor or CLR9[C.color])
drawCell(B,x,y,r,g,b,1)
end

function S.drawHoldBorder(mode,slot)
gc_setLineWidth(2)
if mode=='hold' then
gc_setColor(0,0,0,.26)
gc_rectangle('fill',-170,0,140,100*slot)
gc_setColor(1,.7,.7)
gc_rectangle('line',-170,0,140,100*slot)
elseif mode=='swap' then
gc_setColor(0,0,0,.26)
gc_rectangle('fill',430,0,140,100*slot)
gc_setColor(1,.7,.7)
gc_rectangle('line',430,0,140,100*slot)
end
end
function S.drawHoldCell(C,disabled,B,x,y)
local r,g,b=unpack(disabled and disabledColor or CLR9[C.color])
drawCell(B,x,y,r,g,b,1)
end
-- function S.drawTime(time)
-- -- TODO
-- end
-- function S.drawInfoPanel(x,y,w,h)
-- -- TODO
-- end
function S.drawStartingCounter(readyDelay)
gc_push('transform')
local num=math.ceil((readyDelay-S.getTime())/1000)
local r,g,b=.8,.8,.8
local d=1-S.getTime()%1000/1000 -- from .999 to 0

if num<=3 and d>.75 then
if num==1 then gc_scale(1,1+(d/.25-3)^2)
elseif num==2 then gc_scale(1+(d/.25-3)^2,1)
elseif num==3 then gc_rotate((d-.75)^3*40)
end
end
if num%2==1 then r=1 end

FONT.set(100)

-- Warping number
gc_push('transform')
gc_scale((1.5-d*.6)^1.5)
gc_setColor(r,g,b,d/(.5+num/3))
GC.mStr(num,0,-70)
gc_setColor(r,g,b,(1.5*d-0.5)/(.5+num/3))
GC.mStr(num,0,-70)
gc_pop()

-- Scaling + Fading number
gc_scale(min(d/.333,1)^.4)
gc_setColor(r,g,b)
GC.mStr(num,0,-70)
gc_setColor(r,g,b,1.5*d-0.5)
GC.mStr(num,0,-70)
gc_pop()
end

return S
4 changes: 2 additions & 2 deletions main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ KEYMAP=require'assets.keymap'
SKIN=require'assets.skin'
CHAR=require'assets.char'
SETTINGS=require'assets.settings'
NumColor=require'assets.numcolor'
CLR9=require'assets.color9'
FMOD=require'assets.fmod20221'
DEBUG.checkLoadTime("Load game modules")

Expand All @@ -78,7 +78,7 @@ ZENITHA.setMaxFPS(260)
ZENITHA.setDebugInfo{
{"Cache", gcinfo},
{"Tasks", TASK.getCount},
{"Mouse", function() return ("%d %d"):format(SCR.xOy:inverseTransformPoint(love.mouse.getPosition())) end},
{"Mouse", function() return ("%d, %d"):format(SCR.xOy:inverseTransformPoint(love.mouse.getPosition())) end},
-- {"FMOD", function() local a,b,c=FMOD.studio:getMemoryUsage() return a..","..b..","..c end}, -- Only available in logging builds Fmod
}

Expand Down

0 comments on commit c80f513

Please sign in to comment.