更真实的3D方块
This commit is contained in:
@@ -44,62 +44,93 @@ local function boardTransform(mode)
|
||||
end
|
||||
end
|
||||
end
|
||||
local function drawField(P)
|
||||
local V,F=P.visTime,P.field
|
||||
local start=int((P.fieldBeneath+P.fieldUp)/30+1)
|
||||
local edge=P.gameEnv.upEdge
|
||||
local rep=GAME.replaying
|
||||
local function drawRow(h,V,L)
|
||||
local texture=SKIN.curText
|
||||
if P.falling==-1 then--Blocks only
|
||||
local t=TIME()*4
|
||||
for j=start,min(start+21,#F)do
|
||||
for i=1,10 do
|
||||
if F[j][i]>0 then
|
||||
if V[j][i]>0 then
|
||||
gc_setColor(1,1,1,V[j][i]*.05)
|
||||
gc_draw(texture[F[j][i]],30*i-30,-30*j)-- drawCell(j,i,F[j][i])
|
||||
if edge and(not F[j+1]or F[j+1][i]<=0)then
|
||||
local r,g,b=unpack(SKIN.libColor[F[j][i]])
|
||||
gc_setColor((r+2)/3,(g+2)/3,(b+2)/3,V[j][i]*.05)
|
||||
gc_rectangle("fill",30*i-30,-30*j,30,-4)
|
||||
end
|
||||
elseif rep then
|
||||
gc_setColor(1,1,1,.3+.08*sin(.5*(j-i)+t))
|
||||
gc_rectangle("fill",30*i-30,-30*j,30,30)
|
||||
end
|
||||
end
|
||||
local t=TIME()*4
|
||||
for i=1,10 do
|
||||
if L[i]>0 then
|
||||
if V[i]>0 then
|
||||
local a=V[i]*.05
|
||||
gc_setColor(1,1,1,a)
|
||||
gc_draw(texture[L[i]],30*i-30,-30*h)-- drawCell(j,i,L[i])
|
||||
elseif GAME.replaying then
|
||||
gc_setColor(1,1,1,.3+.08*sin(.5*(h-i)+t))
|
||||
gc_rectangle("fill",30*i-30,-30*h,30,30)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
local function drawField(P)
|
||||
local ENV=P.gameEnv
|
||||
local V,F=P.visTime,P.field
|
||||
local start=int((P.fieldBeneath+P.fieldUp)/30+1)
|
||||
|
||||
--Sorry, I think using FLAG & GOTO is the easiest way to make this simple.
|
||||
--I just want reuse the for-block without using function, because this
|
||||
--is called EXTREME FREQUENTLY, and PASSING VARIABLES IS TOO COMPLEX.
|
||||
--[[
|
||||
Normal style:
|
||||
if ENV.upEdge then
|
||||
{set shader and coords};
|
||||
<< draw field block >> (FOR-block)
|
||||
{restore shader and coords};
|
||||
end
|
||||
<< draw field block >> (FOR-block)
|
||||
|
||||
Simplified by me:
|
||||
flag=ENV.upEdge
|
||||
if flag then
|
||||
{set shader and coords};
|
||||
end
|
||||
::label::
|
||||
<< draw field block >> (FOR-block)
|
||||
if flag then
|
||||
{restore shader and coords};
|
||||
flag=false
|
||||
goto label
|
||||
end
|
||||
]]
|
||||
local flag=ENV.upEdge
|
||||
if P.falling==-1 then--Blocks only
|
||||
if flag then
|
||||
gc.setShader(SHADER.lighter)
|
||||
gc.translate(0,-4)
|
||||
end
|
||||
::edgeFinished::
|
||||
for j=start,min(start+21,#F)do drawRow(j,V[j],F[j])end
|
||||
if flag then
|
||||
gc.setShader()
|
||||
gc.translate(0,4)
|
||||
flag=false
|
||||
goto edgeFinished
|
||||
end
|
||||
else--With falling animation
|
||||
local ENV=P.gameEnv
|
||||
local stepY=ENV.smooth and(P.falling/(ENV.fall+1))^2.5*30 or 30
|
||||
local A=P.falling/ENV.fall
|
||||
local h=1
|
||||
gc_push("transform")
|
||||
for j=start,min(start+21,#F)do
|
||||
while j==P.clearingRow[h]do
|
||||
h=h+1
|
||||
gc_translate(0,-stepY)
|
||||
gc_setColor(1,1,1,A)
|
||||
gc_rectangle("fill",0,30-30*j,300,stepY)
|
||||
end
|
||||
for i=1,10 do
|
||||
if F[j][i]>0 then
|
||||
if V[j][i]>0 then
|
||||
gc_setColor(1,1,1,V[j][i]*.05)
|
||||
gc_draw(texture[F[j][i]],30*i-30,-30*j)-- drawCell(j,i,F[j][i])
|
||||
if edge and(not F[j+1]or F[j+1][i]<=0)then
|
||||
local r,g,b=unpack(SKIN.libColor[F[j][i]])
|
||||
gc_setColor((r+2)/3,(g+2)/3,(b+2)/3,V[j][i]*.05)
|
||||
gc_rectangle("fill",30*i-30,-30*j,30,-4)
|
||||
end
|
||||
elseif rep then
|
||||
gc_setColor(1,1,1,.2)
|
||||
gc_rectangle("fill",30*i-30,-30*j,30,30)
|
||||
end
|
||||
end
|
||||
end
|
||||
if flag then
|
||||
gc_push("transform")
|
||||
gc.setShader(SHADER.lighter)
|
||||
gc.translate(0,-4)
|
||||
end
|
||||
::edgeFinished::
|
||||
for j=start,min(start+21,#F)do
|
||||
while j==P.clearingRow[h]do
|
||||
h=h+1
|
||||
gc_translate(0,-stepY)
|
||||
gc_setColor(1,1,1,A)
|
||||
gc_rectangle("fill",0,30-30*j,300,stepY)
|
||||
end
|
||||
drawRow(j,V[j],F[j])
|
||||
end
|
||||
if flag then
|
||||
gc_pop()
|
||||
gc.setShader()
|
||||
flag=false
|
||||
h=1
|
||||
goto edgeFinished
|
||||
end
|
||||
gc_pop()
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
extern float a;
|
||||
vec4 effect(vec4 color,Image text,vec2 pos,vec2 scr_pos){
|
||||
return vec4(1.,1.,1.,sign(Texel(text,pos).a)*a);
|
||||
vec4 effect(vec4 color,Image tex,vec2 tex_coords,vec2 scr_coords){
|
||||
return vec4(1.,1.,1.,sign(Texel(tex,tex_coords).a)*a);
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
#define PI 3.1415926535897932384626
|
||||
extern float w,h;
|
||||
extern float t;
|
||||
vec4 effect(vec4 color,Image text,vec2 pos,vec2 scr_pos){
|
||||
float x=scr_pos.x/w;
|
||||
float y=scr_pos.y/h;
|
||||
vec4 effect(vec4 color,Image tex,vec2 tex_coords,vec2 scr_coords){
|
||||
float x=scr_coords.x/w;
|
||||
float y=scr_coords.y/h;
|
||||
float dx,dy;
|
||||
vec3 V=vec3(0.);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
extern float t,w;
|
||||
vec4 effect(vec4 color,Image text,vec2 pos,vec2 scr_pos){
|
||||
float x=scr_pos.x/w;
|
||||
vec4 effect(vec4 color,Image tex,vec2 tex_coords,vec2 scr_coords){
|
||||
float x=scr_coords.x/w;
|
||||
return vec4(
|
||||
.8-x*.6,
|
||||
.3+.2*sin(t),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
extern float t,h;
|
||||
vec4 effect(vec4 color,Image text,vec2 pos,vec2 scr_pos){
|
||||
float y=scr_pos.y/h;
|
||||
vec4 effect(vec4 color,Image tex,vec2 tex_coords,vec2 scr_coords){
|
||||
float y=scr_coords.y/h;
|
||||
return vec4(
|
||||
.8-y*.6,
|
||||
.2+y*.4,
|
||||
|
||||
9
parts/shaders/lighter.glsl
Normal file
9
parts/shaders/lighter.glsl
Normal file
@@ -0,0 +1,9 @@
|
||||
vec4 effect(vec4 color,Image tex,vec2 tex_coords,vec2 scr_coords){
|
||||
vec4 texcolor=Texel(tex,tex_coords);
|
||||
return vec4(
|
||||
pow(texcolor.r+.26,.7023),
|
||||
pow(texcolor.g+.26,.7023),
|
||||
pow(texcolor.b+.26,.7023),
|
||||
texcolor.a
|
||||
);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
extern float t,w,h;
|
||||
vec4 effect(vec4 color,Image text,vec2 pos,vec2 scr_pos){
|
||||
float x=scr_pos.x/w;
|
||||
float y=scr_pos.y/h;
|
||||
vec4 effect(vec4 color,Image tex,vec2 tex_coords,vec2 scr_coords){
|
||||
float x=scr_coords.x/w;
|
||||
float y=scr_coords.y/h;
|
||||
return vec4(
|
||||
.8-y*.7+.2*sin(t/6.26),
|
||||
.2+y*.5+.15*sin(t/4.),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
extern float t,w,h;
|
||||
vec4 effect(vec4 color,Image text,vec2 pos,vec2 scr_pos){
|
||||
float x=scr_pos.x/w;
|
||||
float y=scr_pos.y/h;
|
||||
vec4 effect(vec4 color,Image tex,vec2 tex_coords,vec2 scr_coords){
|
||||
float x=scr_coords.x/w;
|
||||
float y=scr_coords.y/h;
|
||||
return vec4(
|
||||
.8-y*.8-.1*sin(t/6.26),
|
||||
.4+.1*sin(t/4.)*(y+2.)/(y+5.),
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
extern float w,h;
|
||||
extern float level;
|
||||
vec4 effect(vec4 color,Image text,vec2 pos,vec2 scr_pos){
|
||||
float dx=abs(scr_pos.x/w-0.5);
|
||||
float dy=abs(scr_pos.y/h-0.5);
|
||||
vec4 effect(vec4 color,Image tex,vec2 tex_coords,vec2 scr_coords){
|
||||
float dx=abs(scr_coords.x/w-0.5);
|
||||
float dy=abs(scr_coords.y/h-0.5);
|
||||
float a=(max(dx*2.6,dy*1.8)-.626)*level;
|
||||
return vec4(1.,0.,0.,a);
|
||||
}
|
||||
Reference in New Issue
Block a user