- [NEW] Animació de caminar i d'estar quet de Morcus activades
- [NEW] Es pot pasar quan es vullga del joc al editor i viceversa - [NEW] Els shaders s'activen en el joc i se desactiven en l'editor
This commit is contained in:
@@ -1,11 +1,17 @@
|
|||||||
|
|
||||||
animations = {
|
animations = {
|
||||||
|
["hero_stand"] = {
|
||||||
|
cycle = {1},
|
||||||
|
frames = {
|
||||||
|
{ frame={x=0,y=0,w=16,h=17}, wait=2 },
|
||||||
|
}
|
||||||
|
},
|
||||||
["hero_walk"] = {
|
["hero_walk"] = {
|
||||||
cycle = {1,2,1,3},
|
cycle = {1,2,1,3},
|
||||||
frames = {
|
frames = {
|
||||||
{ frame={x=0,y=0,w=16,h=17}, wait=4 },
|
{ frame={x=0,y=0,w=16,h=17}, wait=2 },
|
||||||
{ frame={x=16,y=0,w=16,h=17}, wait=4 },
|
{ frame={x=16,y=0,w=16,h=17}, wait=2 },
|
||||||
{ frame={x=32,y=0,w=16,h=17}, wait=4 }
|
{ frame={x=32,y=0,w=16,h=17}, wait=2 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,6 +12,7 @@ editor = {
|
|||||||
enable = function()
|
enable = function()
|
||||||
app.update = editor.update
|
app.update = editor.update
|
||||||
sys.beat(2)
|
sys.beat(2)
|
||||||
|
shader.disable();
|
||||||
end,
|
end,
|
||||||
|
|
||||||
update = function()
|
update = function()
|
||||||
@@ -141,6 +142,20 @@ editor = {
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
play=function()
|
||||||
|
if editor.modified then
|
||||||
|
msgbox.show("IE MEN!",
|
||||||
|
{"Hi ha canvis sense guardar.", "Vols guardar-los abans de jugar?"},
|
||||||
|
{
|
||||||
|
{"Cancel", app.pop},
|
||||||
|
{"No", function() app.pop() game.enable() end},
|
||||||
|
{"Yes", function() app.pop() rooms.save() game.enable() end}
|
||||||
|
} )
|
||||||
|
else
|
||||||
|
game.enable()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
picker = {
|
picker = {
|
||||||
|
|
||||||
show = function()
|
show = function()
|
||||||
|
|||||||
@@ -2,17 +2,23 @@ game = {
|
|||||||
|
|
||||||
enable = function()
|
enable = function()
|
||||||
app.update = game.update
|
app.update = game.update
|
||||||
sys.beat(20)
|
sys.beat(2)
|
||||||
|
shader.enable();
|
||||||
end,
|
end,
|
||||||
|
|
||||||
update = function()
|
update = function()
|
||||||
view.origin(0,0)
|
view.origin(0,0)
|
||||||
surf.target(0)
|
surf.target(0)
|
||||||
|
view.clip()
|
||||||
|
|
||||||
score.draw()
|
score.draw()
|
||||||
|
|
||||||
-- Pintar el mapa i sprites
|
-- Pintar el mapa i sprites
|
||||||
rooms.draw()
|
rooms.draw()
|
||||||
|
sprites.update()
|
||||||
|
|
||||||
|
if key.down(key.ESCAPE) then
|
||||||
|
editor.enable()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@ require "app"
|
|||||||
require "score"
|
require "score"
|
||||||
require "rooms"
|
require "rooms"
|
||||||
require "editor"
|
require "editor"
|
||||||
|
require "game"
|
||||||
|
|
||||||
function mini.init()
|
function mini.init()
|
||||||
surf_sprites = surf.load("sprites.gif")
|
surf_sprites = surf.load("sprites.gif")
|
||||||
@@ -10,6 +11,7 @@ function mini.init()
|
|||||||
pal.trans(0)
|
pal.trans(0)
|
||||||
|
|
||||||
rooms.init()
|
rooms.init()
|
||||||
|
shader.init("lynx.glsl")
|
||||||
editor.enable()
|
editor.enable()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ menu = {
|
|||||||
|
|
||||||
menu.option("FILE")
|
menu.option("FILE")
|
||||||
popup.create("FILE", 1, 8)
|
popup.create("FILE", 1, 8)
|
||||||
|
popup.addOption("FILE", "Play", editor.play)
|
||||||
popup.addOption("FILE", "Save", function() rooms.save() editor.modified=false end)
|
popup.addOption("FILE", "Save", function() rooms.save() editor.modified=false end)
|
||||||
popup.addOption("FILE", "Quit", editor.quit)
|
popup.addOption("FILE", "Quit", editor.quit)
|
||||||
|
|
||||||
|
|||||||
@@ -47,9 +47,6 @@ rooms = {
|
|||||||
--surf.save(rooms.surf_background, "data/rooms_background.bin")
|
--surf.save(rooms.surf_background, "data/rooms_background.bin")
|
||||||
--surf.save(rooms.surf_foreground, "data/rooms_foreground.bin")
|
--surf.save(rooms.surf_foreground, "data/rooms_foreground.bin")
|
||||||
--surf.save(rooms.surf_items, "data/rooms_items.bin")
|
--surf.save(rooms.surf_items, "data/rooms_items.bin")
|
||||||
|
|
||||||
--shader.init("lynx.glsl")
|
|
||||||
--shader.enable();
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
save = function()
|
save = function()
|
||||||
@@ -104,7 +101,6 @@ rooms = {
|
|||||||
--draw.surf(0, 0, 16, 17, 20, 15, 16, 17)
|
--draw.surf(0, 0, 16, 17, 20, 15, 16, 17)
|
||||||
end
|
end
|
||||||
|
|
||||||
sprites.update()
|
|
||||||
-- Pintem la rejilla
|
-- Pintem la rejilla
|
||||||
--for y=0,12 do draw.line(0,y*8, 160, y*8, 27) end
|
--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
|
--for x=0,20 do draw.line(x*8, 0, x*8, 104, 27) end
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 272 B After Width: | Height: | Size: 274 B |
@@ -1,6 +1,6 @@
|
|||||||
score = {
|
score = {
|
||||||
|
|
||||||
draw = function()
|
draw = function()
|
||||||
draw.rectf(0,0,160,7,1)
|
draw.rectf(0,0,160,8,1)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
data/sprites.gif
BIN
data/sprites.gif
Binary file not shown.
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
@@ -9,14 +9,35 @@ sprites = {
|
|||||||
pos = { x=24, y=15 },
|
pos = { x=24, y=15 },
|
||||||
size= { w=16, h=17 },
|
size= { w=16, h=17 },
|
||||||
bbo = { left=0, top=0, right=0, bottom=0 },
|
bbo = { left=0, top=0, right=0, bottom=0 },
|
||||||
animation = "hero_walk",
|
flipped = false,
|
||||||
|
animation = "hero_stand",
|
||||||
current_frame = 1,
|
current_frame = 1,
|
||||||
current_wait = 1
|
current_wait = 1
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
set_animation=function(sprite, animation)
|
||||||
|
if sprite.animation ~= animation then
|
||||||
|
sprite.animation = animation
|
||||||
|
sprite.current_frame = 1
|
||||||
|
sprite.current_wait = 1
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
update = function()
|
update = function()
|
||||||
sprites.update_sprite(sprites.hero)
|
sprites.update_sprite(sprites.hero)
|
||||||
|
|
||||||
|
if key.down(key.LEFT) then
|
||||||
|
sprites.hero.flipped = true
|
||||||
|
sprites.set_animation(sprites.hero, "hero_walk")
|
||||||
|
sprites.hero.pos.x = sprites.hero.pos.x - 1
|
||||||
|
elseif key.down(key.RIGHT) then
|
||||||
|
sprites.hero.flipped = false
|
||||||
|
sprites.set_animation(sprites.hero, "hero_walk")
|
||||||
|
sprites.hero.pos.x = sprites.hero.pos.x + 1
|
||||||
|
else
|
||||||
|
sprites.set_animation(sprites.hero, "hero_stand")
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
update_sprite = function(sprite)
|
update_sprite = function(sprite)
|
||||||
@@ -43,6 +64,6 @@ sprites = {
|
|||||||
draw_sprite = function(sprite)
|
draw_sprite = function(sprite)
|
||||||
local cycle = animations[sprite.animation].cycle[sprite.current_frame]
|
local cycle = animations[sprite.animation].cycle[sprite.current_frame]
|
||||||
local frame = animations[sprite.animation].frames[cycle]
|
local frame = animations[sprite.animation].frames[cycle]
|
||||||
draw.surf(frame.frame.x, frame.frame.y, frame.frame.w, frame.frame.h, sprite.pos.x, sprite.pos.y, sprite.size.w, sprite.size.h)
|
draw.surf(frame.frame.x, frame.frame.y, frame.frame.w, frame.frame.h, sprite.pos.x, sprite.pos.y, sprite.size.w, sprite.size.h, sprite.flipped)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user