场地晃动加入旋转分量

This commit is contained in:
MrZ626
2021-03-25 15:48:51 +08:00
parent f7ece80bec
commit 1f2652cc5e
5 changed files with 47 additions and 16 deletions

View File

@@ -50,19 +50,22 @@ return{
end
end,
mesDisp=function(P)
local dx,dy=P.fieldOff.x,P.fieldOff.y
setFont(55)
mStr(P.stat.row,69,225)
mText(drawableText.line,69,290)
gc.push("transform")
PLY.draw.applyFieldxOy(P)
PLY.draw.applyFieldOffset(P)
if P.modeData.showMark==0 then
local mark=TEXTURE.puzzleMark
local F=FIELD[P.modeData.finished+1]
for y=1,20 do for x=1,10 do
local T=F[y][x]
if T~=0 then
gc.draw(mark[T],150+30*x-30+dx,600-30*y+dy)
gc.draw(mark[T],150+30*x-30,600-30*y)
end
end end
end
gc.pop()
end,
}

View File

@@ -1,6 +1,6 @@
local gc=love.graphics
local gc_push,gc_pop,gc_clear,gc_origin=gc.push,gc.pop,gc.clear,gc.origin
local gc_translate,gc_scale=gc.translate,gc.scale
local gc_translate,gc_scale,gc_rotate=gc.translate,gc.scale,gc.rotate
local gc_setCanvas,gc_setShader=gc.setCanvas,gc.setShader
local gc_draw,gc_line,gc_rectangle,gc_circle=gc.draw,gc.line,gc.rectangle,gc.circle
local gc_print,gc_printf=gc.print,gc.printf
@@ -520,12 +520,25 @@ function draw.drawNext_hidden(P)
gc_pop()
end
function draw.applyFieldxOy()
gc_translate(150,0)
end
function draw.applyFieldOffset(P)
local O=P.fieldOff
gc_translate(O.x,O.y)
gc_translate(150,300)
gc_rotate(O.a)
gc_translate(-150,-300)
end
function draw.drawTargetLine(P,r)
if r<21+(P.fieldBeneath+P.fieldUp)/30 and r>0 then
gc_setLineWidth(4)
gc_setColor(1,r>10 and 0 or rnd(),.5)
local dx,dy=150+P.fieldOff.x,P.fieldOff.y+P.fieldBeneath+P.fieldUp
gc_line(dx,600-30*r+dy,300+dx,600-30*r+dy)
gc_push("transform")
draw.applyFieldxOy(P)
draw.applyFieldOffset(P)
gc_line(0,600-30*r,300,600-30*r)
gc_pop()
end
end
@@ -538,11 +551,11 @@ function draw.norm(P)
--Field-related things
gc_push("transform")
gc_translate(150,0)
draw.applyFieldxOy(P)
--Things shake with field
gc_push("transform")
gc_translate(P.fieldOff.x,P.fieldOff.y)
draw.applyFieldOffset(P)
--Fill field
gc_setColor(0,0,0,.6)
@@ -698,7 +711,7 @@ function draw.norm_remote(P)
--Field-related things
gc_push("transform")
gc_translate(150,0)
draw.applyFieldxOy(P)
--Draw username
setFont(30)
@@ -707,7 +720,7 @@ function draw.norm_remote(P)
--Things shake with field
gc_push("transform")
gc_translate(P.fieldOff.x,P.fieldOff.y)
draw.applyFieldOffset(P)
--Fill field
gc_setColor(0,0,0,.6)
@@ -900,7 +913,7 @@ function draw.demo(P)
gc_translate(P.x,P.y)
gc_scale(P.size)
gc_push("transform")
gc_translate(P.fieldOff.x,P.fieldOff.y)
draw.applyFieldOffset(P)
--Frame
gc_setColor(0,0,0,.6)

View File

@@ -89,7 +89,11 @@ local function newEmptyPlayer(id,mini)
end
P.update=PLY.update.alive
P.fieldOff={x=0,y=0,vx=0,vy=0}--For shake FX
P.fieldOff={--Shake FX
x=0,y=0,
vx=0,vy=0,
a=0,va=0,
}
P.x,P.y,P.size=0,0,1
P.frameColor=0

View File

@@ -462,6 +462,7 @@ function Player.freshBlock(P,mode)--string mode: push/move/fresh/newBlock
end
if ENV.shakeFX then
P.fieldOff.vy=ENV.shakeFX*.5
P.fieldOff.va=P:getCenterX()*P.gameEnv.shakeFX*5e-4
end
P.curY=P.ghoY
end
@@ -1903,6 +1904,7 @@ function Player.act_hardDrop(P)
P.spinLast=false
if P.gameEnv.shakeFX then
P.fieldOff.vy=P.gameEnv.shakeFX*.6
P.fieldOff.va=P:getCenterX()*P.gameEnv.shakeFX*6e-4
end
if P.sound then
SFX.play("drop",nil,P:getCenterX()*.15)
@@ -2010,6 +2012,7 @@ function Player.act_insDown(P)
end
if ENV.shakeFX then
P.fieldOff.vy=ENV.shakeFX*.5
P.fieldOff.va=P:getCenterX()*P.gameEnv.shakeFX*5e-4
end
P.curY=P.ghoY
P.lockDelay=ENV.lock

View File

@@ -85,10 +85,17 @@ local function updateFXs(P,dt)
--Field shaking
if P.gameEnv.shakeFX then
local O=P.fieldOff
O.vx,O.vy=O.vx*.8-abs(O.x)^1.2*(O.x>0 and .1 or -.1),O.vy*.8-abs(O.y)^1.2*(O.y>0 and .1 or -.1)
O.x,O.y=O.x+O.vx,O.y+O.vy
if abs(O.x)<.3 then O.x=0 end
if abs(O.y)<.3 then O.y=0 end
O.vx=O.vx*.8-abs(O.x)^1.2*(O.x>0 and .1 or -.1)
O.x=O.x+O.vx
if abs(O.x)<.3 then O.x,O.vx=0,0 end
O.vy=O.vy*.8-abs(O.y)^1.2*(O.y>0 and .1 or -.1)
O.y=O.y+O.vy
if abs(O.y)<.3 then O.y,O.vy=0,0 end
O.va=O.va*.8-abs(O.a)^1.2*(O.a>0 and .1 or -.1)
O.a=O.a+O.va
-- if abs(O.a)<.3 then O.a,O.va=0,0 end
end
if P.bonus then
@@ -247,7 +254,8 @@ function update.alive(P,dt)
P:act_insDown()
end
if ENV.shakeFX then
P.fieldOff.vy=ENV.shakeFX*.3
P.fieldOff.vy=ENV.shakeFX*.2
P.fieldOff.va=P:getCenterX()*P.gameEnv.shakeFX*2e-4
end
end
else