- [ONGOING] Treballant en la clase "level"
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
title=PAKU SIMBEL PROFANATION
|
title=PAKU SIMBEL PROFANATION
|
||||||
config=paku
|
config=paku
|
||||||
width=160
|
width=160
|
||||||
height=144
|
height=104
|
||||||
zoom=3
|
zoom=4
|
||||||
|
|||||||
@@ -1,36 +1,90 @@
|
|||||||
level = {
|
level = {
|
||||||
background = nil,
|
surf_background = nil,
|
||||||
foreground = nil,
|
surf_foreground = nil,
|
||||||
|
surf_items = nil,
|
||||||
|
surf_original_items = nil,
|
||||||
|
|
||||||
|
pos = {x=0, y=0},
|
||||||
|
|
||||||
init = function()
|
init = function()
|
||||||
level.background = surf.new(20*8,17*8)
|
level.pos.x, level.pos.y = 0,0
|
||||||
level.foreground = surf.new(20*8,17*8)
|
if level.surf_background ~= nil then surf.free(level.surf_background) end
|
||||||
map.surf(level.background)
|
--level.surf_background = surf.load("rooms_background.bin")
|
||||||
for y=0,17*8 do
|
level.surf_background = surf.new(20*8,12*8)
|
||||||
|
|
||||||
|
if level.surf_foreground ~= nil then surf.free(level.surf_foreground) end
|
||||||
|
--level.surf_foreground = surf.load("rooms_foreground.bin")
|
||||||
|
level.surf_foreground = surf.new(20*8,12*8)
|
||||||
|
|
||||||
|
if level.surf_items ~= nil then surf.free(level.surf_items) end
|
||||||
|
--level.surf_items = surf.load("rooms_items.bin")
|
||||||
|
level.surf_items = surf.new(20*8,12*8)
|
||||||
|
|
||||||
|
level.surf_original_items = surf.new(20*8,12*8)
|
||||||
|
surf.source(level.surf_items)
|
||||||
|
surf.target(level.surf_original_items)
|
||||||
|
draw.surf(0,0,160,96,0,0)
|
||||||
|
|
||||||
|
map.surf(level.surf_background)
|
||||||
|
for y=0,12*8 do
|
||||||
for x=0,20*8 do
|
for x=0,20*8 do
|
||||||
map.tile(x,y,1)
|
map.tile(x,y,1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
map.surf(level.foreground)
|
map.surf(level.surf_foreground)
|
||||||
map.tile(10,10,16)
|
map.tile(10,10,16)
|
||||||
|
|
||||||
|
surf.save(level.surf_background, "data/rooms_background.bin")
|
||||||
|
surf.save(level.surf_foreground, "data/rooms_foreground.bin")
|
||||||
|
surf.save(level.surf_items, "data/rooms_items.bin")
|
||||||
|
|
||||||
|
shader.init("lynx.glsl")
|
||||||
|
shader.enable();
|
||||||
end,
|
end,
|
||||||
|
|
||||||
draw_background = function()
|
|
||||||
view.clip(0,8,160,136)
|
draw = function()
|
||||||
view.origin(0,8)
|
-- Retallem la pantalla a la zona de joc
|
||||||
map.surf(level.background)
|
view.clip(0,8,160,96)
|
||||||
|
|
||||||
|
-- Movem la càmara a l'habitació on estem
|
||||||
|
view.origin(level.pos.x*8,level.pos.y*8+8)
|
||||||
|
|
||||||
|
-- Pintem el background
|
||||||
|
surf.source(tiles)
|
||||||
|
map.surf(level.surf_background)
|
||||||
map.draw()
|
map.draw()
|
||||||
view.origin(4,8+4)
|
|
||||||
map.surf(level.foreground)
|
-- Movem 4x4 pixels la càmara per a pintar les sombres dels sprites i el foreground
|
||||||
|
view.origin(level.pos.x*8+4,level.pos.y*8+12)
|
||||||
|
|
||||||
|
-- Pintem el foreground de negre
|
||||||
|
map.surf(level.surf_foreground)
|
||||||
pal.subpal(0,32,1)
|
pal.subpal(0,32,1)
|
||||||
map.draw()
|
map.draw()
|
||||||
end,
|
|
||||||
|
|
||||||
draw_foreground = function()
|
-- Pintem els sprites de negre
|
||||||
view.origin(0,8)
|
-- [TODO]
|
||||||
|
surf.source(sprites)
|
||||||
|
draw.surf(0, 0, 16, 17, 10, 10, 16, 17)
|
||||||
|
|
||||||
|
-- Movem la càmara al lloc que toca de nou, i tornem la paleta normal
|
||||||
|
view.origin(level.pos.x*8,level.pos.y*8+8)
|
||||||
pal.subpal()
|
pal.subpal()
|
||||||
map.surf(level.foreground)
|
|
||||||
|
-- Pintem el foreground
|
||||||
|
surf.source(tiles)
|
||||||
|
map.surf(level.surf_foreground)
|
||||||
map.draw()
|
map.draw()
|
||||||
|
|
||||||
|
-- Pintem els sprites
|
||||||
|
-- [TODO]
|
||||||
|
surf.source(sprites)
|
||||||
|
draw.surf(0, 0, 16, 17, 10, 10, 16, 17)
|
||||||
|
|
||||||
|
-- Pintem la rejilla
|
||||||
|
--for y=0,12 do draw.line(0,y*8, 160, y*8, 27) end
|
||||||
|
--for x=0,20 do draw.line(x*8, 0, x*8, 104, 27) end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
peiv = function()
|
peiv = function()
|
||||||
|
|||||||
41
data/lynx.glsl
Normal file
41
data/lynx.glsl
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
varying vec2 tex_coord;
|
||||||
|
varying vec2 pix_coord;
|
||||||
|
|
||||||
|
#if defined(VERTEX)
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
pix_coord = vec2(gl_MultiTexCoord0.x, 1.0-gl_MultiTexCoord0.y)*1.0001;
|
||||||
|
tex_coord = vec2((gl_Vertex.x+1.0)*0.5, (-gl_Vertex.y+1.0)*0.5);
|
||||||
|
vec4 pos = vec4(gl_Vertex.x * 2.0, gl_Vertex.y * 2.0, gl_Vertex.z, gl_Vertex.w);
|
||||||
|
gl_Position = gl_Vertex; //(gl_Vertex*2)-vec3(1.0, 1.0, 1.0);//gl_ModelViewProjectionMatrix * gl_Vertex;
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined(FRAGMENT)
|
||||||
|
|
||||||
|
uniform sampler2D Texture;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
float x = sign(pix_coord.x)*floor(abs(pix_coord.x)+0.5);
|
||||||
|
float column = mod(x,4.0);
|
||||||
|
vec4 color = texture2D(Texture, tex_coord);
|
||||||
|
float xfade = abs((tex_coord.s * 2.0) - 1.0);
|
||||||
|
xfade = xfade * xfade * xfade * xfade * xfade;
|
||||||
|
float yfade = abs((tex_coord.t * 2.0) - 1.0);
|
||||||
|
yfade = yfade * yfade * yfade * yfade * yfade;
|
||||||
|
color = color + vec4(0.7, 0.7, 0.7, 0.0) * (1.0-tex_coord.t) * (1.0-xfade) * (1.0-yfade);
|
||||||
|
vec4 newcolor;
|
||||||
|
if (column == 0.0) {
|
||||||
|
newcolor = color * vec4(1.0, 0.4, 0.6, 1.0);
|
||||||
|
} else if (column == 1.0) {
|
||||||
|
newcolor = color * vec4(0.4, 1.0, 0.4, 1.0);
|
||||||
|
} else if (column == 2.0) {
|
||||||
|
newcolor = color * vec4(0.6, 0.4, 1.0, 1.0);
|
||||||
|
} else {
|
||||||
|
newcolor = color * vec4(0.2, 0.2, 0.2, 1.0);
|
||||||
|
}
|
||||||
|
gl_FragColor = newcolor;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -14,17 +14,20 @@ end
|
|||||||
function mini.update()
|
function mini.update()
|
||||||
view.origin(0,0)
|
view.origin(0,0)
|
||||||
surf.cls(1)
|
surf.cls(1)
|
||||||
|
surf.target(0)
|
||||||
level.draw_background()
|
|
||||||
surf.source(sprites)
|
|
||||||
draw.surf(0, 0, 16, 17, 10, 10, 16, 17)
|
|
||||||
surf.source(tiles)
|
|
||||||
level.draw_foreground()
|
|
||||||
surf.source(sprites)
|
|
||||||
draw.surf(0, 0, 16, 17, 10, 10, 16, 17)
|
|
||||||
surf.source(tiles)
|
|
||||||
|
|
||||||
--draw.surf(0, 0, 64, 64, 10, 10)
|
-- Pintar el marcador
|
||||||
|
-- [TODO]
|
||||||
|
|
||||||
|
-- Pintar el mapa i sprites
|
||||||
|
level.draw()
|
||||||
|
|
||||||
|
view.origin(0,0)
|
||||||
|
local mx, my = mouse.pos()
|
||||||
|
mx, my = math.floor(mx/8)*8, math.floor(my/8)*8
|
||||||
|
|
||||||
|
draw.rect(mx-1, my-1, 10, 10, 28)
|
||||||
|
draw.rect(mx, my, 8, 8, 1)
|
||||||
if (key.down(key.ESCAPE)) then
|
if (key.down(key.ESCAPE)) then
|
||||||
sys.quit()
|
sys.quit()
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user