- [FIX] Si hi ha que ficar un offset en algun frame de animació, es fà des de la propia animació, no canviant la posició del personatge
- [NEW] rooms.reload() - [FIX] Al tornar al editor, se recarrega tot de nou - [NEW] Si se juga des de un mini de debug comença en l'editor. Si se juga des del mini normal comença en el joc.
This commit is contained in:
@@ -36,9 +36,9 @@ animations = {
|
||||
["hero_shoot"] = {
|
||||
cycle = {1,2,3},
|
||||
frames = {
|
||||
{ frame={x=64,y=0,w=24,h=17}, wait=4 },
|
||||
{ frame={x=88,y=0,w=24,h=17}, wait=2 },
|
||||
{ frame={x=88,y=0,w=24,h=17}, wait=2 }
|
||||
{ frame={x=64,y=0,w=24,h=17}, offset={flipped={x=-8,y=0}}, wait=4 },
|
||||
{ frame={x=88,y=0,w=24,h=17}, offset={flipped={x=-8,y=0}}, wait=2 },
|
||||
{ frame={x=88,y=0,w=24,h=17}, offset={flipped={x=-8,y=0}}, wait=2 }
|
||||
}
|
||||
},
|
||||
["bullet"] = {
|
||||
|
||||
@@ -63,7 +63,8 @@ game = {
|
||||
game.apply_light()
|
||||
|
||||
if key.press(key.ESCAPE) or key.press(key.F9) then
|
||||
rooms.retrieve_original_items()
|
||||
rooms.reload()
|
||||
sprites.add_from_room(rooms.pos.x, rooms.pos.y)
|
||||
editor.enable()
|
||||
elseif key.press(key.GRAVE) then
|
||||
console.enable()
|
||||
|
||||
@@ -21,7 +21,11 @@ function mini.init()
|
||||
|
||||
rooms.init()
|
||||
shader.init("lynx.glsl")
|
||||
editor.enable()
|
||||
if sys.debug() then
|
||||
editor.enable()
|
||||
else
|
||||
game.enable()
|
||||
end
|
||||
sprites.add_from_room(rooms.pos.x, rooms.pos.y)
|
||||
end
|
||||
|
||||
|
||||
@@ -20,8 +20,7 @@ rooms = {
|
||||
return (rooms.pos.x//20) + (rooms.pos.y//12) * 8
|
||||
end,
|
||||
|
||||
init = function()
|
||||
rooms.pos.x, rooms.pos.y = 0,4*12
|
||||
reload = function()
|
||||
if rooms.surf_background ~= nil then surf.free(rooms.surf_background) end
|
||||
rooms.surf_background = surf.load("rooms_background"..ROOM_FILE_EXT)
|
||||
--rooms.surf_background = surf.new(20*8,12*8)
|
||||
@@ -33,27 +32,12 @@ rooms = {
|
||||
if rooms.surf_items ~= nil then surf.free(rooms.surf_items) end
|
||||
rooms.surf_items = surf.load("rooms_items"..ROOM_FILE_EXT)
|
||||
--rooms.surf_items = surf.new(20*8,12*8)
|
||||
|
||||
rooms.surf_original_items = surf.new(20*8,12*8)
|
||||
rooms.update_original_items()
|
||||
--surf.source(rooms.surf_items)
|
||||
--surf.target(rooms.surf_original_items)
|
||||
--draw.surf(0,0,160,96,0,0)
|
||||
end,
|
||||
|
||||
init = function()
|
||||
rooms.pos.x, rooms.pos.y = 0,4*12
|
||||
rooms.reload()
|
||||
sprites.init()
|
||||
|
||||
--map.surf(rooms.surf_background)
|
||||
--for y=0,12*8 do
|
||||
-- for x=0,20*8 do
|
||||
-- map.tile(x,y,38)
|
||||
-- end
|
||||
--end
|
||||
--map.surf(rooms.surf_foreground)
|
||||
--map.tile(10,10,16)
|
||||
|
||||
--surf.save(rooms.surf_background, "data/rooms_background.bin")
|
||||
--surf.save(rooms.surf_foreground, "data/rooms_foreground.bin")
|
||||
--surf.save(rooms.surf_items, "data/rooms_items.bin")
|
||||
end,
|
||||
|
||||
save = function()
|
||||
@@ -143,16 +127,4 @@ rooms = {
|
||||
pal.color(1, 1, 1, 1)
|
||||
return "HOLA OTHER UNIT"
|
||||
end,
|
||||
|
||||
retrieve_original_items = function()
|
||||
surf.source(rooms.surf_original_items)
|
||||
surf.target(rooms.surf_items)
|
||||
draw.surf(0,0,160,96,0,0)
|
||||
end,
|
||||
|
||||
update_original_items = function()
|
||||
surf.source(rooms.surf_items)
|
||||
surf.target(rooms.surf_original_items)
|
||||
draw.surf(0,0,160,96,0,0)
|
||||
end
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
@@ -258,7 +258,6 @@ sprites = {
|
||||
-- A no ser que siga l'ultim frame, en tal cas tornem a estar de peu i au
|
||||
if sprites.hero.current_frame==3 then
|
||||
sprites.hero.shooting = false
|
||||
if sprites.hero.flipped then sprites.hero.pos.x=sprites.hero.pos.x+8 end
|
||||
sprites.set_animation(sprites.hero, "hero_stand")
|
||||
else
|
||||
return
|
||||
@@ -360,10 +359,8 @@ sprites = {
|
||||
elseif (sprites.hero.cooldown==0) and (key.down(key.Z) or pad.down(pad.B)) then
|
||||
sprites.hero.shooting = true
|
||||
sprites.hero.cooldown = 20
|
||||
local x = sprites.hero.flipped and sprites.hero.pos.x+8 or sprites.hero.pos.x-8
|
||||
local bullet = templates.create("bullet", {pos={x=sprites.hero.pos.x, y=sprites.hero.pos.y+7}, flipped=sprites.hero.flipped})
|
||||
table.insert(sprites.list, bullet)
|
||||
if sprites.hero.flipped then sprites.hero.pos.x=sprites.hero.pos.x-8 end
|
||||
anim = "hero_shoot"
|
||||
end
|
||||
end
|
||||
@@ -422,12 +419,21 @@ sprites = {
|
||||
draw_sprite = function(sprite)
|
||||
local cycle = animations[sprite.animation].cycle[sprite.current_frame]
|
||||
local frame = animations[sprite.animation].frames[cycle]
|
||||
local ox, oy = 0, 0
|
||||
if frame.offset then
|
||||
if sprite.flipped then
|
||||
if frame.offset.flipped then ox,oy = frame.offset.flipped.x,frame.offset.flipped.y end
|
||||
else
|
||||
if frame.offset.normal then ox,oy = frame.offset.normal.x,frame.offset.normal.y end
|
||||
end
|
||||
end
|
||||
|
||||
if not frame then
|
||||
print(sprite.current_frame)
|
||||
end
|
||||
local reversed = frame.reversed or false
|
||||
surf.source(sprite.surf)
|
||||
draw.surf(frame.frame.x, frame.frame.y, frame.frame.w, frame.frame.h, sprite.pos.x, sprite.pos.y, frame.frame.w, frame.frame.h, (not reversed) ~= (not sprite.flipped))
|
||||
draw.surf(frame.frame.x, frame.frame.y, frame.frame.w, frame.frame.h, sprite.pos.x+ox, sprite.pos.y+oy, frame.frame.w, frame.frame.h, (not reversed) ~= (not sprite.flipped))
|
||||
if cheats.showaabb then
|
||||
local x,y,w,h = util.aabb(sprite)
|
||||
draw.rect(x,y,w,h,8)
|
||||
|
||||
Reference in New Issue
Block a user