diff --git a/.gitignore b/.gitignore index 8c1ac73..ac2d29a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,8 @@ release/* *.exe *.dll +*.xcf mini mini_debug data-old +backups diff --git a/data/arcade_config.lua b/data/arcade_config.lua index 9a08d73..1ba6a05 100644 --- a/data/arcade_config.lua +++ b/data/arcade_config.lua @@ -2,7 +2,7 @@ local arcade_config = { org_resolucion = { width = 128, height = 96 }, resolucion = { width = 256, height = 192 }, surface = { width = 256, height = 192 }, - logo_sf = { width = 144, height = 20 }, + --logo_sf = { width = 144, height = 20 }, sprite_size = { w = 32, h = 32 }, escala = 1.0, org2arc_escala = 2.0, diff --git a/data/flow.lua b/data/flow.lua new file mode 100644 index 0000000..0134d60 --- /dev/null +++ b/data/flow.lua @@ -0,0 +1,63 @@ +flow={ + level=1, + step={0}, + paths={ {flow_safe} }, + registre={ } + -- sub_path_enable = false, + -- sub_step = 0, + -- sub_path={} +} + +function flow_safe() + print("FLOW SAFE") +end + +function flow:print() + print("> STEP= "..self.step.." / "..#self.path) + if self.sub_path_enable then + print("> SUB_PATH_ENABLE= TRUE") + else + print("> SUB_PATH_ENABLE= FALSE") + end + print("> SUB_STEP= "..self.sub_step.." / "..#self.sub_path) + print("") +end + +function flow:next() + local level_step = self.step[self.level] + local level_path = self.paths[self.level] + -- print("LEVEL= "..self.level) + -- print("LEVEL_STEP= "..level_step) + if level_step+1 > #level_path then + -- Si s'ha acabat la llista pujar de nivell + if self.level>1 then self.level=self.level-1 end + level_step = self.step[self.level] + -- level_path = self.paths[self.level] + end + + -- següent pas + level_step = level_step+1 + game_update = self.paths[self.level][level_step] + + -- result = self.step[self.level] + self.step[self.level] = level_step +end + +function flow:restore() + local level_step = self.step[self.level] + game_update = self.paths[self.level][level_step] +end + +function flow:call(nom) + game_update = self.registre[nom] +end + +function flow:add_path( path ) + self.level = self.level+1 + self.step[self.level] = 0 + self.paths[self.level] = path +end + +function flow:add(name, fn) + self.registre[name] = fn +end \ No newline at end of file diff --git a/data/game.ini b/data/game.ini index 9337654..2b76d9f 100644 --- a/data/game.ini +++ b/data/game.ini @@ -1,5 +1,5 @@ -title=Cacaus Arcade -config=cacaus_arcade +title=Cacaus Arcade Redo +config=cacaus_arcade_redo width=256 height=192 zoom=3 diff --git a/data/game.lua b/data/game.lua index 1bdd696..4d483e8 100644 --- a/data/game.lua +++ b/data/game.lua @@ -1,16 +1,17 @@ viewport= require("viewport") require "abad" require "cacau" -require "caco" -require "zombie" -require "gota" -require "bol" -require "gorro" require "gps" +require "gorro" require "peu" require "premiere" require "elalien" +require "bol" +require "gota" +require "caco" +require "zombie" require "score" +require "switches" local tile_w = arcade_config.tiles_width local tile_h = arcade_config.tiles_height @@ -82,7 +83,16 @@ end actors={} +function game_exit() + -- mapa_restore_backup() + actors={} + -- cameras={} +end + function game_init(menu) +print("GAME INIT") + actors={} + abad_init() table.insert(actors,abad) @@ -101,6 +111,8 @@ function game_init(menu) elalien.init() table.insert(actors,elalien) + --batman + bol.init() table.insert(actors,bol) @@ -117,6 +129,12 @@ function game_init(menu) table.insert( actors, gota.new(77,2,1,30,-5,-7) ) table.insert( actors, gota.new(77,9,1,25,-5,-7) ) + -- FOC? + -- table.insert(actors,invisible.new(77,40,32)) + -- table.insert(actors,invisible.new(77,48,32)) + -- table.insert(actors,invisible.new(58,16,32)) + -- table.insert(actors,invisible.new(58,16,32)) + table.insert( actors, caco.new(13,3,2,true ) ) table.insert( actors, caco.new(17,3,2,false) ) table.insert( actors, caco.new(20,3,2,false) ) @@ -136,6 +154,24 @@ function game_init(menu) table.insert( actors, zombie.new(68, 3, 3,false) ) table.insert( actors, zombie.new(73, 3, 3,false) ) + -- TRIGGERS + -- if not menu then table.insert(actors,trigger.new(10,57,32,triggers.escena_abad_inici)) end + -- table.insert(actors,trigger.new(11,16,32,triggers.escena_abad_corfes)) + -- + -- table.insert(actors,trigger.new(31,12,32,triggers.escena_abad_portes)) + -- table.insert(actors,trigger.new(31,48,32,triggers.escena_abad_portes)) + -- table.insert(actors,trigger.new(71,56,24,triggers.escena_abad_portes)) + -- + -- table.insert(actors,trigger.new(53,40,32,triggers.escena_abad_porta_casa)) + -- table.insert(actors,trigger.new(56,32,32,triggers.escena_abad_porta_batman)) + -- + -- table.insert(actors,trigger.new(19,32,32,triggers.escena_habitacio_batman)) + -- + -- table.insert(actors,trigger.new(14,40,32,triggers.teleport_a)) + -- table.insert(actors,trigger.new(67,8,32,triggers.teleport_b)) + -- table.insert(actors,trigger.new(29,40,32,triggers.teleport_c)) + -- table.insert(actors,trigger.new(61,8,32,triggers.teleport_d)) + score.create() local abad_x, abad_y = coords.room_to_world ( 10, 4, 3 ) diff --git a/data/helpers.lua b/data/helpers.lua new file mode 100644 index 0000000..6b60533 --- /dev/null +++ b/data/helpers.lua @@ -0,0 +1,121 @@ +function arc_text(str, x, y, col) + font.current(font_sf) + draw.text(str,x,y,col) +end + +function arc_textB(str, x, y, col) + font.current(font_sf) + -- Crear el borde negre + draw.text(str, x-1, y-1, 16) + draw.text(str, x , y-1, 16) + draw.text(str, x+1, y-1, 16) + + draw.text(str, x-1, y, 16) + draw.text(str, x+1, y, 16) + + draw.text(str, x-1, y+1, 16) + draw.text(str, x , y+1, 16) + draw.text(str, x+1, y+1, 16) + -- Escriure la cadena + draw.text(str,x,y,col) +end + +function editor_to_map_tile(editor_tile) + local result = 0 + if editor_tile<256 then result = editor_tile + arcade_config.tiles_offset end + return result +end + +function map_to_editor_tile(map_tile) + local result = map_tile - arcade_config.tiles_offset + if map_tile==0 then result = 256 end + return result +end + +function load_tilemap( sf_mapa ) + local mapa_tw, mapa_th = surf.size(sf_mapa) + local nrooms = mapa_rooms_per_piso*mapa_pisos + local x = 0 + local y = 0 + local yroom = 0 + local xroom = 0 + + map.surf(sf_mapa) + for ty=0,mapa_th-1 do + if y == mapa_room_rows then + yroom = yroom + mapa_rooms_per_piso + y = 0 + end + xroom = yroom + for tx=0,mapa_tw-1 do + local tile=editor_to_map_tile(mapa[1+xroom][1+x+y*mapa_room_cols]) + map.tile(tx, ty, tile) + x = x + 1 + if x == mapa_room_cols then + x = 0 + xroom = xroom + 1 + end + end + y = y +1 + end +end + +-- DEBUG + +-- Imprime cualquier valor, incluyendo tablas anidadas +function dump(value, indent) + indent = indent or "" + if type(value) ~= "table" then + return tostring(value) + end + + local parts = {"{"} + for k, v in pairs(value) do + local key = (type(k) == "string") and k or "["..tostring(k).."]" + table.insert(parts, + string.format("%s %s = %s,", + indent, key, dump(v, indent.." "))) + end + table.insert(parts, indent.."}") + return table.concat(parts, "\n") +end + +function msg_print(x, y, msg, direct_print ) + local scr_x, scr_y + direct_print = direct_print or false + if direct_print then + scr_x = x + scr_y = y + else + scr_x, scr_y = viewp:screen_coords(x, y) + end + draw.rectf(scr_x,scr_y,45,7,16) + draw.text(msg,scr_x+1,scr_y+1,2) +end + +function view_coord(x, y, w, h, color) + local scr_x, scr_y = viewp:screen_coords(x, y) + draw.rect(scr_x, scr_y, w, h, color) +end + +function debug.write_tile(x, y, yplus, print_type, align ) + local scr_x, scr_y = viewp:screen_coords(x, y) + local hab, xx, yy = coords.world_to_tile(x, y) + + yplus = yplus or 0 + print_type = print_type or false + align = align or "R" + + local txt_offset = -7 + if align=="R" then txt_offset = -14 + elseif align=="L" then txt_offset = 0 + end + + draw.rectf(scr_x+txt_offset,scr_y+yplus,14,7,16) + -- local msg = mapa_get_tile(hab,xx,yy) + local msg = arc_get_tile(x,y) + if print_type then + msg = msg.." "..arc_check_tile(x, y) + end + draw.text(msg,scr_x+txt_offset+1,scr_y+1+yplus,2) +end diff --git a/data/intro.lua b/data/intro.lua index 80f6c49..c123764 100644 --- a/data/intro.lua +++ b/data/intro.lua @@ -33,26 +33,33 @@ function draw_item_intro( name, flip ) end function intro_init() - game_update = intro_intro +print("INTRO_INIT") + -- game_update = intro_intro intro_wait=400 surf.source(tiles) surf.target(0) surf.cls(16) fade.fadein() font.current(font_sf) + flow:add_path({intro_intro, intro_update}) + flow:next() end function intro_intro() intro_wait=1 - game_update = intro_update + -- game_update = intro_update + flow:next() fade.fadeoutin() end function intro_update() if key.press(key.ESCAPE) or pad.press(btnPause) then - game_init(true) - fade.fadeoutin() + -- game_init(true) + print("INTRO_UPDATE") + -- game_update = menu_init + -- game_init(true) + intro_end() elseif key.press(key.SPACE) then intro_wait=1 end @@ -112,9 +119,16 @@ function intro_update() -- STEP 8 elseif intro_step==8 then music.play(audio_main_song) - game_init(true) - fade.fadeoutin() + -- game_init(true) + -- game_update = menu_init + intro_end() end intro_wait=50 end +end + +function intro_end() + print("intro_end") + fade.fadeoutin() + flow:next() end \ No newline at end of file diff --git a/data/logo.lua b/data/logo.lua index a04950d..543c734 100644 --- a/data/logo.lua +++ b/data/logo.lua @@ -4,6 +4,10 @@ local logo_anim={} local step1_finished = false local brillo_y = 10 local logo_wait = 400 +local logo_sf = 99 +local font_sf = 99 +local logo_sf_w = 63 +local logo_sf_h = 30 function logo_anim_init () logo_anim={ [1] = {x0=-126, y=80, w=126, h=4, speed= 1, accel= 0.25, x1=65, delay=0}, @@ -13,43 +17,93 @@ function logo_anim_init () [5] = {x0=-126, y=96, w=126, h=4, speed= 1, accel= 0.25, x1=65, delay=16}} end -function logo_init() - game_update = logo_intro - surf.cls(16) - - local font_default = font.current() - font.current(font_sf) - surf.target(back) - surf.cls(16) - draw.text("JAILGAMES",0,0,15) - draw.text("presenta",0,20,14) - draw.text("JAILGAMES",0,40,2) - font.current(font_default) - surf.target(0) - logo_anim_init() +function logo_config(font_surface) + font_sf = font_surface end -function logo_intro() - logo_wait=logo_wait-1 +function logo_init() +-- print("LOGO INIT") + local font_default = font.current() + -- Crear la surface + logo_sf=surf.new(logo_sf_w,logo_sf_h) + -- logo_sf=surf.new(256,192) + -- Netejar el back + surf.target(logo_sf) + surf.cls(0) + -- Font per a escriure + font.current(font_sf) + -- Logo + draw.text("JAILGAMES",0,0,15) + draw.text("presenta",0,10,14) + draw.text("JAILGAMES",0,20,2) + -- Restaurar font + font.current(font_default) + -- Inicialitzar animació + logo_anim_init() + flow:add_path({logo_animate, logo_end}) - if logo_wait==0 or key.press(key.ESCAPE) or key.press(keyShoot) or pad.press(btnShoot) or pad.press(btnPause) then - logo_wait=1 - game_update = logo_update - fade.fadeoutin() - end + -- print("LOGO_ANIMATE= ") + -- print(logo_animate) + -- print("LOGO_END= ") + -- print(logo_end) - surf.source(back) + -- Següent bucle + -- game_update = logo_intro + flow:next() +end + +function logo_draw() +-- print("LOGO DRAW "..logo_step) + -- Seleccionar font i destí + surf.source(logo_sf) surf.target(0) + -- Netejar destí surf.cls(16) -- Animació per a l'aparició del logo if logo_step==1 then + -- Crear les barres draw.surf(0,0,63,2, logo_anim[1].x0,logo_anim[1].y,logo_anim[1].w,logo_anim[1].h) draw.surf(0,2,63,2, logo_anim[2].x0,logo_anim[2].y,logo_anim[2].w,logo_anim[2].h) draw.surf(0,4,63,2, logo_anim[3].x0,logo_anim[3].y,logo_anim[3].w,logo_anim[3].h) draw.surf(0,6,63,2, logo_anim[4].x0,logo_anim[4].y,logo_anim[4].w,logo_anim[4].h) draw.surf(0,8,63,2, logo_anim[5].x0,logo_anim[5].y,logo_anim[5].w,logo_anim[5].h) + end + -- presenta + if logo_step==2 then + draw.surf(0,0,63,10, logo_anim[1].x0,logo_anim[1].y,logo_anim[1].w,logo_anim[1].h*5); -- JAILGAMES + draw.surf(0,10,55,10, 100,102,55,10); -- presenta + end + + -- pausa + if logo_step==3 then + draw.surf(0,0,63,10, logo_anim[1].x0,logo_anim[1].y,logo_anim[1].w,logo_anim[1].h*5); -- JAILGAMES + draw.surf(0,10,55,10, 100,102,55,10); -- presenta + end + + -- Brillo + if logo_step==4 then + draw.surf(0,0,63,10, logo_anim[1].x0,logo_anim[1].y,logo_anim[1].w,logo_anim[1].h*5); -- JAILGAMES + draw.surf(0,10,55,10, 100,102,55,10); -- presenta + + -- if logo_step_wait>=1 then + draw.surf(0,20+math.floor(brillo_y),63,1, + logo_anim[1].x0, logo_anim[1].y+math.floor(brillo_y*2), logo_anim[1].w, 1); + -- end + end + + -- Final + if logo_step>=5 then + draw.surf(0,0,63,10, logo_anim[1].x0,logo_anim[1].y,logo_anim[1].w,logo_anim[1].h*5); -- JAILGAMES + draw.surf(0,10,55,10, 100,102,55,10); -- presenta + end +end + +function logo_update() +-- print("LOGO UPDATE "..logo_step) + -- Animació per a l'aparició del logo + if logo_step==1 then step1_finished = true logo_step_wait = logo_step_wait+1 if logo_step_wait>=1 then @@ -81,17 +135,10 @@ function logo_intro() end -- presenta - if logo_step==2 then - -- draw.surf(0,0, 63,10, 65,80,126,20); -- JAILGAMES - draw.surf(0,0,63,10, logo_anim[1].x0,logo_anim[1].y,logo_anim[1].w,logo_anim[1].h*5); -- JAILGAMES - draw.surf(0,20,55,10, 100,102,55,10); -- presenta - logo_step = 3 - end + if logo_step==2 then logo_step = 3 end -- pausa if logo_step==3 then - draw.surf(0,0,63,10, logo_anim[1].x0,logo_anim[1].y,logo_anim[1].w,logo_anim[1].h*5); -- JAILGAMES - draw.surf(0,20,55,10, 100,102,55,10); -- presenta logo_step_wait = logo_step_wait+1 if logo_step_wait>=20 then logo_step_wait = 0 @@ -101,30 +148,45 @@ function logo_intro() -- Brillo if logo_step==4 then - draw.surf(0,0,63,10, logo_anim[1].x0,logo_anim[1].y,logo_anim[1].w,logo_anim[1].h*5); -- JAILGAMES - draw.surf(0,20,55,10, 100,102,55,10); -- presenta - logo_step_wait = logo_step_wait+1 - if logo_step_wait>=1 then + if logo_step_wait>=2 then logo_step_wait = 0 - draw.surf(0,40+math.floor(brillo_y),63,1, - logo_anim[1].x0, logo_anim[1].y+math.floor(brillo_y*2), logo_anim[1].w, 1); - brillo_y = brillo_y-0.5 - - if brillo_y==0 then logo_step = 5 end + if brillo_y<0 then logo_step = 5 end end end - -- Final - if logo_step>=5 then - draw.surf(0,0,63,10, logo_anim[1].x0,logo_anim[1].y,logo_anim[1].w,logo_anim[1].h*5); -- JAILGAMES - draw.surf(0,20,55,10, 100,102,55,10); -- presenta - if logo_step==5 then logo_wait = 75 end + -- Pausa final + if logo_step==5 then logo_step = 6 - end + logo_wait = 75 + end + + -- Final + if logo_step==6 and logo_wait==0 then logo_step = 7 end end -function logo_update() - intro_init() -end \ No newline at end of file +function logo_end() +-- print("LOGO_END") + -- game_update = intro_init + print("logo_end") + flow:next() + -- surf.free(logo_sf) +end + +function logo_animate() +-- print("LOGO_INTRO "..logo_step) + logo_wait=logo_wait-1 + + -- Següent bucle + if logo_wait==0 or key.press(key.ESCAPE) or key.press(keyShoot) or pad.press(btnShoot) or pad.press(btnPause) then + flow:next() + end + + logo_draw() + logo_update() + + if logo_step==7 then + flow:next() + end +end diff --git a/data/main.lua b/data/main.lua index 017ec89..489debf 100644 --- a/data/main.lua +++ b/data/main.lua @@ -1,19 +1,25 @@ -debug = require "debug" arcade_config = require("arcade_config") coords = require "coords" +require "helpers" -require "fps" -require "fade" -require "audio" require "map" require "mapa" +require "warp" +require "fade" +require "audio" require "logo" require "intro" -require "game" -require "switches" -require "warp" -require "trigger" require "scenes" +require "title" +require "game" + +--require "fps" +--require "title" +--require "menu" +--require "switches" +--require "trigger" + +require "flow" coords.set_config({ tiles_width = arcade_config.tiles_width, @@ -23,82 +29,7 @@ coords.set_config({ rooms_per_floor = mapa_rooms_per_piso, }) -function editor_to_map_tile(editor_tile) - local result = 0 - if editor_tile<256 then result = editor_tile + arcade_config.tiles_offset end - return result -end - -function map_to_editor_tile(map_tile) - local result = map_tile - arcade_config.tiles_offset - if map_tile==0 then result = 256 end - return result -end - -function load_tilemap( sf_mapa ) - local mapa_tw, mapa_th = surf.size(sf_mapa) - local nrooms = mapa_rooms_per_piso*mapa_pisos - local x = 0 - local y = 0 - local yroom = 0 - local xroom = 0 - - map.surf(sf_mapa) - for ty=0,mapa_th-1 do - if y == mapa_room_rows then - yroom = yroom + mapa_rooms_per_piso - y = 0 - end - xroom = yroom - for tx=0,mapa_tw-1 do - local tile=editor_to_map_tile(mapa[1+xroom][1+x+y*mapa_room_cols]) - map.tile(tx, ty, tile) - x = x + 1 - if x == mapa_room_cols then - x = 0 - xroom = xroom + 1 - end - end - y = y +1 - end -end - -function mini.init() - tiles=surf.load("tiles.gif") - surf.source(tiles) - local paleta=pal.load("tiles.gif") - pal.set(paleta) - - -- Crear el warp - warp.init() - - logo=surf.new(arcade_config.logo_sf.width,arcade_config.logo_sf.height) - back=surf.new(arcade_config.surface.width,arcade_config.surface.height) - sf_mapa=surf.new(mapa_room_cols*mapa_rooms_per_piso,mapa_room_rows*mapa_pisos) - load_tilemap( sf_mapa ) - fade.init() - - font_sf=font.load("X2_font.fnt") - - textsf=surf.new(arcade_config.org_resolucion.width,arcade_config.org_resolucion.height) - - -- Càrrega dels audios - audio_text_abad = sound.load(audio_text_abad) - audio_text_premiere = sound.load(audio_text_premiere) - audio_text_elalien = sound.load(audio_text_elalien) - audio_text_batman = sound.load(audio_text_batman) - audio_abad_jump = sound.load(audio_abad_jump) - audio_abad_fall = sound.load(audio_abad_fall) - audio_abad_hit = sound.load(audio_abad_hit) - audio_abad_shot = sound.load(audio_abad_shot) - audio_abad_step[1] = sound.load(audio_abad_step[1]) - audio_abad_step[2] = sound.load(audio_abad_step[2]) - audio_abad_step[3] = sound.load(audio_abad_step[3]) - audio_abad_step[4] = audio_abad_step[2] - audio_switch = sound.load(audio_switch) - audio_hit = sound.load(audio_hit) - audio_low = sound.load(audio_low) - +function keys_init() -- Configuració dels input keyUp = tonumber(config.key("keyup")) or key.UP keyDown = tonumber(config.key("keydown")) or key.DOWN @@ -116,11 +47,70 @@ function mini.init() btnCycle1 = tonumber(config.key("btncycle1")) or pad.RIGHTSHOULDER btnCycle2 = tonumber(config.key("btncycle2")) or pad.LEFTSHOULDER btnPause = tonumber(config.key("btnpause")) or pad.START +end - logo_init() - -- intro_init() - -- game_init() - -- final_init() +function images_init() + tiles=surf.load("tiles.gif") + surf.source(tiles) + local paleta=pal.load("tiles.gif") + pal.set(paleta) + + -- Crear el warp + warp.init(tiles) +end + +function image_close() + surf.free(tiles) + warp.close() +end + +function fonts_init() + font_sf=font.load("X2_font.fnt") +end + +function mapa_init() + sf_mapa=surf.new(mapa_room_cols*mapa_rooms_per_piso,mapa_room_rows*mapa_pisos) + load_tilemap( sf_mapa ) +end + +function audio_init() + -- Càrrega dels audios + audio_text_abad = sound.load(audio_text_abad) + audio_text_premiere = sound.load(audio_text_premiere) + audio_text_elalien = sound.load(audio_text_elalien) + audio_text_batman = sound.load(audio_text_batman) + audio_abad_jump = sound.load(audio_abad_jump) + audio_abad_fall = sound.load(audio_abad_fall) + audio_abad_hit = sound.load(audio_abad_hit) + audio_abad_shot = sound.load(audio_abad_shot) + audio_abad_step[1] = sound.load(audio_abad_step[1]) + audio_abad_step[2] = sound.load(audio_abad_step[2]) + audio_abad_step[3] = sound.load(audio_abad_step[3]) + audio_abad_step[4] = audio_abad_step[2] + audio_switch = sound.load(audio_switch) + audio_hit = sound.load(audio_hit) + audio_low = sound.load(audio_low) +end + +function mini.init() + -- back_sf=surf.new(256,192) + fonts_init() + images_init() + mapa_init() + fade.init() + audio_init() + keys_init() + logo_config(font_sf) + surf.target(0) + surf.cls(16) + flow:add("logo", logo_init) + flow:add("intro", intro_init) + flow:add("title", title_init) + flow:add("game", game_init) + -- flow:add("ending", ending_init) + -- flow:add("credits", credits_init) + flow:add_path( { logo_init, intro_init, title_init, game_init } ) + flow:next() end function mini.update() @@ -138,85 +128,6 @@ function mini.update() end -function arc_text(str, x, y, col) - font.current(font_sf) - draw.text(str,x,y,col) -end - -function arc_textB(str, x, y, col) - font.current(font_sf) - -- Crear el borde negre - draw.text(str, x-1, y-1, 16) - draw.text(str, x , y-1, 16) - draw.text(str, x+1, y-1, 16) - - draw.text(str, x-1, y, 16) - draw.text(str, x+1, y, 16) - - draw.text(str, x-1, y+1, 16) - draw.text(str, x , y+1, 16) - draw.text(str, x+1, y+1, 16) - -- Escriure la cadena - draw.text(str,x,y,col) -end - --- DEBUG - --- Imprime cualquier valor, incluyendo tablas anidadas -function dump(value, indent) - indent = indent or "" - if type(value) ~= "table" then - return tostring(value) - end - - local parts = {"{"} - for k, v in pairs(value) do - local key = (type(k) == "string") and k or "["..tostring(k).."]" - table.insert(parts, - string.format("%s %s = %s,", - indent, key, dump(v, indent.." "))) - end - table.insert(parts, indent.."}") - return table.concat(parts, "\n") -end - -function msg_print(x, y, msg, direct_print ) - local scr_x, scr_y - direct_print = direct_print or false - if direct_print then - scr_x = x - scr_y = y - else - scr_x, scr_y = viewp:screen_coords(x, y) - end - draw.rectf(scr_x,scr_y,45,7,16) - draw.text(msg,scr_x+1,scr_y+1,2) -end - -function view_coord(x, y, w, h, color) - local scr_x, scr_y = viewp:screen_coords(x, y) - draw.rect(scr_x, scr_y, w, h, color) -end - -function debug.write_tile(x, y, yplus, print_type, align ) - local scr_x, scr_y = viewp:screen_coords(x, y) - local hab, xx, yy = coords.world_to_tile(x, y) - - yplus = yplus or 0 - print_type = print_type or false - align = align or "R" - - local txt_offset = -7 - if align=="R" then txt_offset = -14 - elseif align=="L" then txt_offset = 0 - end - - draw.rectf(scr_x+txt_offset,scr_y+yplus,14,7,16) - -- local msg = mapa_get_tile(hab,xx,yy) - local msg = arc_get_tile(x,y) - if print_type then - msg = msg.." "..arc_check_tile(x, y) - end - draw.text(msg,scr_x+txt_offset+1,scr_y+1+yplus,2) -end - +function mini.close() + surf.free(font_sf) +end \ No newline at end of file diff --git a/data/mapa.lua b/data/mapa.lua index d44607e..28ae3ec 100644 --- a/data/mapa.lua +++ b/data/mapa.lua @@ -1,6 +1,4 @@ -require "map" - -local arcade_config = require("arcade_config") +-- require "map" tiletype={void=0,nonpc=1,stair=2,switch=3,half=4,block=5} mapa.wait=0 diff --git a/data/menu.lua b/data/menu.lua new file mode 100644 index 0000000..6c1ed2a --- /dev/null +++ b/data/menu.lua @@ -0,0 +1,276 @@ +function menu_init() +print("MENU INIT") + menu_sel=0 + menu_state=update_main_menu; + abad.update = abad_nop + game_update=update_menu + menu_count=0 + menu_change_room=300 + menu_room=math.random(0,59) + music.play(audio_main_song) +end + +function menu_update() + --game_update=update_game + music.stop() +end + +function draw_hab(hab,x,y) + +end + +function mapa_update(hab1, hab2) + +end + +function redraw_menu_hab() + -- draw_hab(menu_room,16,41) + -- draw.rectf(0,0,15*o2aX,97*o2aX,16) + -- draw.rectf(114*o2aX,0,78*o2aX,97*o2aX,16) + -- draw.rect(15*o2aX,40*o2aX,99*o2aX,50*o2aX,2) + -- mapa_update(abad.hab,menu_room) + + -- for key,actor in pairs(actors) do + -- actor:update() + -- end + -- imp.update() + -- bambolla.update() + -- cacau.update() + -- fireball.update() + -- switches.update() +end + +function update_menu() + menu_change_room=menu_change_room-1 + if menu_change_room==0 then + menu_room = math.random(0,59) + menu_change_room=300 + end + + surf.cls(16) + draw_title(14*o2aX, 0) + menu_state() +end + +function update_options_menu() + menu_count=menu_count+1 + local parpadeig=false + if menu_count>=20 then + parpadeig=true + if menu_count>40 then menu_count=0 end + end + draw.rect(28*o2aX,(28+(10*menu_sel))*o2aX,73*o2aX,9*o2aX,14) + if (not parpadeig) then draw.rect(28*o2aX,(28+(10*menu_sel))*o2aX,73*o2aX,9*o2aX,13) end + + arc_text("MÚSICA", 30*o2aX, 30*o2aX, 14); arc_text(music.enabled() and "SI" or "NO",91*o2aX,30*o2aX,15) + arc_text("SÓ", 30*o2aX, 40*o2aX, 14); arc_text(sound.enabled() and "SI" or "NO",91*o2aX,40*o2aX,15) + arc_text("REDEFINIR TECLAT", 30*o2aX, 50*o2aX, 14) + arc_text("REDEFINIR GAMEPAD", 30*o2aX, 60*o2aX, 14) + arc_text("TORNAR", 30*o2aX, 70*o2aX, 14) + + if key.press(keyShoot) or key.press(key.SPACE) or pad.press(pad.A) or pad.press(btnShoot) then + if menu_sel==0 then + music.enabled(not music.enabled()) + if music.enabled() then music.play(audio_main_song) end + elseif menu_sel==1 then + sound.enabled(not sound.enabled()) + elseif menu_sel==2 then + menu_count=0 + menu_state=update_redefine_keys_menu + elseif menu_sel==3 then + menu_count=0 + menu_state=update_redefine_pad_menu + else + menu_count=0 + menu_sel=0 + menu_state=update_main_menu + end + elseif key.press(keyDown) or key.press(key.DOWN) or pad.press(pad.DOWN) or pad.press(btnDown) then + menu_sel=menu_sel+1 + if menu_sel==5 then menu_sel=0 end + elseif key.press(keyUp) or key.press(key.UP) or pad.press(pad.UP) or pad.press(btnUp) then + menu_sel=menu_sel-1 + if menu_sel==-1 then menu_sel=4 end + elseif key.press(key.ESCAPE) or pad.press(btnPause) then + menu_count=0 + menu_sel=0 + menu_state=update_main_menu + end +end + +function update_main_menu() + menu_count=menu_count+1 + local parpadeig=false + if menu_count>=20 then + parpadeig=true + if menu_count>40 then menu_count=0 end + end + draw.rect(28*o2aX,(18+(10*menu_sel))*o2aX,73*o2aX,9*o2aX,14) + if (not parpadeig) then draw.rect(28*o2aX,(18+(10*menu_sel))*o2aX,73*o2aX,9*o2aX,13) end + arc_text("JUGAR", 54*o2aX, 20*o2aX, 14) + arc_text("OPCIONS", 50*o2aX, 30*o2aX, 14) + --if (not parpadeig or menu_sel~=2) then text("REDEFINIR GAMEPAD", 30, 32, 13) end + + redraw_menu_hab() + + if key.press(keyShoot) or key.press(key.SPACE) or pad.press(pad.A) or pad.press(btnShoot) then + if menu_sel==0 then + game_exit() + game_init() + fade.fadeoutin() + elseif menu_sel==1 then + menu_count=0 + menu_sel=0 + menu_state=update_options_menu--update_redefine_keys_menu; + else + menu_count=0 + menu_state=update_redefine_pad_menu + end + elseif key.press(keyDown) or key.press(key.DOWN) or pad.press(pad.DOWN) or pad.press(btnDown) then + menu_sel=menu_sel+1 + if menu_sel==2 then menu_sel=0 end + elseif key.press(keyUp) or key.press(key.UP) or pad.press(pad.UP) or pad.press(btnUp) then + menu_sel=menu_sel-1 + if menu_sel==-1 then menu_sel=1 end + elseif key.press(key.ESCAPE) or pad.press(btnPause) then + sys.quit() + end +end + +function update_redefine_keys_menu() + if key.press(key.ESCAPE) then + menu_count = 0 + menu_state = update_options_menu; + end + if menu_count==0 then + arc_textB("PULSA TECLA PER A AMUNT", 20*o2aX, 24*o2aX, 13) + local k = key.press(); + if k ~= 0 and k~=key.ESCAPE then + menu_count = 1 + keyUp=k + config.key("keyup", keyUp) + end + elseif menu_count==1 then + arc_textB("PULSA TECLA PER A AVALL", 20*o2aX, 24*o2aX, 13) + local k = key.press(); + if k ~= 0 and k~=key.ESCAPE then + menu_count = 2 + keyDown=k + config.key("keydown", keyDown) + end + elseif menu_count==2 then + arc_textB("PULSA TECLA PER A ESQUERRA", 14*o2aX, 24*o2aX, 13) + local k = key.press(); + if k ~= 0 and k~=key.ESCAPE then + menu_count = 3 + keyLeft=k + config.key("keleft", keyLeft) + end + elseif menu_count==3 then + arc_textB("PULSA TECLA PER A DRETA", 20*o2aX, 24*o2aX, 13) + local k = key.press(); + if k ~= 0 and k~=key.ESCAPE then + menu_count = 4 + keyRight=k + config.key("keyright", keyRight) + end + elseif menu_count==4 then + arc_textB("PULSA TECLA PER A BOTAR", 20*o2aX, 24*o2aX, 13) + local k = key.press(); + if k ~= 0 and k~=key.ESCAPE then + menu_count = 5 + keyJump=k + config.key("keyjump", keyJump) + end + elseif menu_count==5 then + arc_textB("PULSA TECLA PER A DISPAR", 18*o2aX, 24*o2aX, 13) + local k = key.press(); + if k ~= 0 and k~=key.ESCAPE then + menu_count = 0 + menu_state = update_options_menu; + keyShoot=k + config.key("keyshoot", keyShoot) + end + end +end + +function update_redefine_pad_menu() + if key.press(key.ESCAPE) then + menu_count = 0 + menu_state = update_options_menu; + end + if menu_count==0 then + arc_textB("PULSA BOTÓ PER A AMUNT", 22*o2aX, 24*o2aX, 13) + local btn = pad.press(); + if btn ~= -1 then + menu_count = 1 + btnUp=btn + config.key("btnup", btnUp) + end + elseif menu_count==1 then + arc_textB("PULSA BOTÓ PER A AVALL", 22*o2aX, 24*o2aX, 13) + local btn = pad.press(); + if btn ~= -1 then + menu_count = 2 + btnDown=btn + config.key("btndown", btnDown) + end + elseif menu_count==2 then + arc_textB("PULSA BOTÓ PER A ESQUERRA", 16*o2aX, 24*o2aX, 13) + local btn = pad.press(); + if btn ~= -1 then + menu_count = 3 + btnLeft=btn + config.key("keleft", btnLeft) + end + elseif menu_count==3 then + arc_textB("PULSA BOTÓ PER A DRETA", 22*o2aX, 24*o2aX, 13) + local btn = pad.press(); + if btn ~= -1 then + menu_count = 4 + btnRight=btn + config.key("btnright", btnRight) + end + elseif menu_count==4 then + arc_textB("PULSA BOTÓ PER A BOTAR", 22*o2aX, 24*o2aX, 13) + local btn = pad.press(); + if btn ~= -1 then + menu_count = 5 + btnJump=btn + config.key("btnjump", btnJump) + end + elseif menu_count==5 then + arc_textB("PULSA BOTÓ PER A DISPAR", 20*o2aX, 24*o2aX, 13) + local btn = pad.press(); + if btn ~= -1 then + menu_count = 6 + btnShoot=btn + config.key("btnshoot", btnShoot) + end + elseif menu_count==6 then + arc_textB("PULSA BOTÓ PER A GPS ARRERE", 14*o2aX, 24*o2aX, 13) + local btn = pad.press(); + if btn ~= -1 then + menu_count = 7 + btnCycle1=btn + config.key("btncycle1", btnCycle1) + end + elseif menu_count==7 then + arc_textB("PULSA BOTÓ PER A GPS AVANT", 14*o2aX, 24*o2aX, 13) + local btn = pad.press(); + if btn ~= -1 then + menu_count = 8 + btnCycle2=btn + config.key("btncycle2", btnCycle2) + end + elseif menu_count==8 then + arc_textB("PULSA BOTÓ PER A PAUSA", 22*o2aX, 24*o2aX, 13) + local btn = pad.press(); + if btn ~= -1 then + menu_count = 0 + menu_state = update_options_menu; + btnPause=btn + config.key("btnpause", btnPause) + end + end +end diff --git a/data/scenes.lua b/data/scenes.lua index 8fc904d..a093e53 100644 --- a/data/scenes.lua +++ b/data/scenes.lua @@ -162,8 +162,11 @@ function start_scene(scene,offset) music.play(scenes.current_scene[scenes.dnum].musica) end if offset then scenes.offset=offset end - old_update=game_update - game_update=update_scene + -- old_update=game_update + -- game_update=update_scene + -- flow:add("save", game_update) + flow:add("scene",update_scene) + flow:call("scene") end function playtext(snd) @@ -280,7 +283,8 @@ function update_scene() -- final_init() -- fade.fadeoutin() -- else - game_update=old_update + -- game_update=old_update + flow:restore() -- end else scenes.dnum=scenes.dnum+1 @@ -300,7 +304,9 @@ function update_scene() if (key.press(key.ESCAPE) or pad.press(btnPause)) and (scenes.current_scene~=scenes.final) then if scenes.current_scene[scenes.dnum].die then - game_init(true) + -- game_init(true) + flow:next() + -- game_update = menu_init else pause() end @@ -315,7 +321,8 @@ function update_scene() -- final_init() -- fade.fadeoutin() -- else - game_update=old_update + -- game_update=old_update + flow:restore() -- end else scenes.dnum=scenes.dnum+1 diff --git a/data/title.lua b/data/title.lua new file mode 100644 index 0000000..33b99ea --- /dev/null +++ b/data/title.lua @@ -0,0 +1,163 @@ +local char_C = {x=0, y=0, w=6, h=7} +local char_a = {x=6, y=0, w=4, h=5} +local char_c = {x=4, y=7, w=3, h=5} +local char_u = {x=12, y=5, w=4, h=5} +local char_s = {x=12, y=0, w=4, h=5} + +local frame = { {x=0, y=7, w=2, h=1}, --cantó sup esq + {x=2, y=7, w=1, h=1}, --linea sup + {x=3, y=7, w=1, h=1}, -- cantó sup dre 1 + {x=3, y=9, w=1, h=1}, -- cantó sup dre 2 + {x=2, y=8, w=2, h=1}, -- costat dre 1 + {x=2, y=9, w=1, h=1}, -- costat dre 2 + {x=1, y=10, w=2, h=1}, -- costat dre 3 + {x=3, y=10, w=1, h=1}, -- cantó inf dre 1 + {x=3, y=11, w=1, h=1}, -- cantó inf dre 2 + {x=2, y=11, w=1, h=1}, -- linea inf + {x=1, y=11, w=1, h=1}, -- cantó inf esq 1 + {x=0, y=8, w=1, h=4}, -- cantó inf esq 2 + costat esq 1 + {x=1, y=8, w=1, h=2}, -- costat esq 2 + } +local the = {x=7, y=8, w=5, h=2} +local arcade = {x=7, y=10, w=9, h=2} +local cycle_pal = {12, 13, 14} +local cycle_wait = 0 +local cycle_step = 1 + +local menu_sel = 0 + +function title_init() + title_sf=surf.load("title_tiles.gif") + surf.source(title_sf) + flow:add_path({title_show, title_end}) + flow:next() +end + +function title_draw_frame () + pal.subpal(9,cycle_pal[(cycle_step%3)+1]) + -- draw.surf( frame[1].x*8, frame[1].y*8, frame[1].w*8, frame[1].h*8, 20, 58+4, frame[1].w*8, frame[1].h*8) + -- draw.surf( frame[2].x*8, frame[2].y*8, frame[2].w*8, frame[2].h*8, 36, 58+4, 24*frame[2].w*8, frame[2].h*8) + -- draw.surf( frame[3].x*8, frame[3].y*8, frame[3].w*8, frame[3].h*8, 228, 58+4, frame[3].w*8, frame[3].h*8) + -- draw.surf( frame[4].x*8, frame[4].y*8, frame[4].w*8, frame[4].h*8, 236, 58+4, frame[4].w*8, frame[4].h*8) + -- draw.surf( frame[5].x*8, frame[5].y*8, frame[5].w*8, frame[5].h*8, 228, 66+4, frame[5].w*8, frame[5].h*8) + -- draw.surf( frame[6].x*8, frame[6].y*8, frame[6].w*8, frame[6].h*8, 236, 74+4, frame[6].w*8, frame[6].h*8) + -- draw.surf( frame[7].x*8, frame[7].y*8, frame[7].w*8, frame[7].h*8, 236, 82+4, frame[7].w*8, frame[7].h*8) + draw.surf( frame[8].x*8, frame[8].y*8, frame[8].w*8, frame[8].h*8, 244, 90+4, frame[8].w*8, frame[8].h*8) + draw.surf( frame[9].x*8, frame[9].y*8, frame[9].w*8, frame[9].h*8, 236, 90+4, frame[9].w*8, frame[9].h*8) + draw.surf(frame[10].x*8, frame[10].y*8, frame[10].w*8, frame[10].h*8, 28, 90+4, 26*frame[10].w*8, frame[10].h*8) + draw.surf(frame[11].x*8, frame[11].y*8, frame[11].w*8, frame[11].h*8, 20, 90+4, frame[11].w*8, frame[11].h*8) + draw.surf(frame[12].x*8, frame[12].y*8, frame[12].w*8, frame[12].h*8, 12, 66+4, frame[12].w*8, frame[12].h*8) + -- draw.surf(frame[13].x*8, frame[13].y*8, frame[13].w*8, frame[13].h*8, 20, 66+4, frame[13].w*8, frame[13].h*8) + pal.subpal(9,cycle_pal[((cycle_step+1)%3)+1]) + -- draw.surf( frame[1].x*8, frame[1].y*8, frame[1].w*8, frame[1].h*8, 20, 58+2, frame[1].w*8, frame[1].h*8) + -- draw.surf( frame[2].x*8, frame[2].y*8, frame[2].w*8, frame[2].h*8, 36, 58+2, 24*frame[2].w*8, frame[2].h*8) + -- draw.surf( frame[3].x*8, frame[3].y*8, frame[3].w*8, frame[3].h*8, 228, 58+2, frame[3].w*8, frame[3].h*8) + -- draw.surf( frame[4].x*8, frame[4].y*8, frame[4].w*8, frame[4].h*8, 236, 58+2, frame[4].w*8, frame[4].h*8) + -- draw.surf( frame[5].x*8, frame[5].y*8, frame[5].w*8, frame[5].h*8, 228, 66+2, frame[5].w*8, frame[5].h*8) + -- draw.surf( frame[6].x*8, frame[6].y*8, frame[6].w*8, frame[6].h*8, 236, 74+2, frame[6].w*8, frame[6].h*8) + -- draw.surf( frame[7].x*8, frame[7].y*8, frame[7].w*8, frame[7].h*8, 236, 82+2, frame[7].w*8, frame[7].h*8) + draw.surf( frame[8].x*8, frame[8].y*8, frame[8].w*8, frame[8].h*8, 244, 90+2, frame[8].w*8, frame[8].h*8) + draw.surf( frame[9].x*8, frame[9].y*8, frame[9].w*8, frame[9].h*8, 236, 90+2, frame[9].w*8, frame[9].h*8) + draw.surf(frame[10].x*8, frame[10].y*8, frame[10].w*8, frame[10].h*8, 28, 90+2, 26*frame[10].w*8, frame[10].h*8) + draw.surf(frame[11].x*8, frame[11].y*8, frame[11].w*8, frame[11].h*8, 20, 90+2, frame[11].w*8, frame[11].h*8) + draw.surf(frame[12].x*8, frame[12].y*8, frame[12].w*8, frame[12].h*8, 12, 66+2, frame[12].w*8, frame[12].h*8) + draw.rectf(12, 80+2, frame[12].w*8, 8, 16) + -- draw.surf(frame[13].x*8, frame[13].y*8, frame[13].w*8, frame[13].h*8, 20, 66+2, frame[13].w*8, frame[13].h*8) + pal.subpal(9,cycle_pal[((cycle_step+2)%3)+1]) + draw.surf( frame[1].x*8, frame[1].y*8, frame[1].w*8, frame[1].h*8, 20, 58, frame[1].w*8, frame[1].h*8) + draw.surf( frame[2].x*8, frame[2].y*8, frame[2].w*8, frame[2].h*8, 36, 58, 24*frame[2].w*8, frame[2].h*8) + draw.surf( frame[3].x*8, frame[3].y*8, frame[3].w*8, frame[3].h*8, 228, 58, frame[3].w*8, frame[3].h*8) + draw.surf( frame[4].x*8, frame[4].y*8, frame[4].w*8, frame[4].h*8, 236, 58, frame[4].w*8, frame[4].h*8) + draw.surf( frame[5].x*8, frame[5].y*8, frame[5].w*8, frame[5].h*8, 228, 66, frame[5].w*8, frame[5].h*8) + draw.surf( frame[6].x*8, frame[6].y*8, frame[6].w*8, frame[6].h*8, 236, 74, frame[6].w*8, frame[6].h*8) + draw.surf( frame[7].x*8, frame[7].y*8, frame[7].w*8, frame[7].h*8, 236, 82, frame[7].w*8, frame[7].h*8) + draw.surf( frame[8].x*8, frame[8].y*8, frame[8].w*8, frame[8].h*8, 244, 90, frame[8].w*8, frame[8].h*8) + draw.surf( frame[9].x*8, frame[9].y*8, frame[9].w*8, frame[9].h*8, 236, 90, frame[9].w*8, frame[9].h*8) + draw.surf(frame[10].x*8, frame[10].y*8, frame[10].w*8, frame[10].h*8, 28, 90, 26*frame[10].w*8, frame[10].h*8) + draw.surf(frame[11].x*8, frame[11].y*8, frame[11].w*8, frame[11].h*8, 20, 90, frame[11].w*8, frame[11].h*8) + draw.surf(frame[12].x*8, frame[12].y*8, frame[12].w*8, frame[12].h*8, 12, 66, frame[12].w*8, frame[12].h*8) + draw.surf(frame[13].x*8, frame[13].y*8, frame[13].w*8, frame[13].h*8, 20, 66, frame[13].w*8, frame[13].h*8) + pal.subpal(9) + + cycle_wait = cycle_wait+1 + if cycle_wait==18 then + cycle_wait = 0 + cycle_step = (cycle_step+1)%3+1 + end +end + +function title_draw_tile( tile, x, y ) + draw.surf(tile.x*8,tile.y*8,tile.w*8,tile.h*8, x, y) +end + +function title_draw () + title_draw_frame() + title_draw_tile(char_C,30,13) + title_draw_tile(char_a,76,28) + title_draw_tile(char_c,107,28) + title_draw_tile(char_a,129,28) + title_draw_tile(char_u,158,29) + title_draw_tile(char_s,192,28) + title_draw_tile(the,129,76) + title_draw_tile(arcade,162,76) +end + +function title_update() + +end + +function title_show() + -- print("title_show") + surf.source(title_sf) + surf.target(0) + surf.cls(16) + + title_menu_draw() + title_draw() + title_update() + title_menu_update() +end + +function title_end() + if menu_sel==0 then + -- game_exit() + -- game_init() + -- fade.fadeoutin() + to_game() + elseif menu_sel==1 then + -- menu_count=0 + -- menu_sel=0 + -- menu_state=update_options_menu--update_redefine_keys_menu; + to_options() + end +end + +function title_menu_draw() + draw.rect(56,120+(20*menu_sel)-4,146,18,14) + arc_text("JUGAR", 108, 120, 14) + arc_text("OPCIONS", 102, 140, 14) +end + +function title_menu_update() + if key.press(keyShoot) or key.press(key.SPACE) or pad.press(pad.A) or pad.press(btnShoot) then + title_end() + elseif key.press(keyDown) or key.press(key.DOWN) or pad.press(pad.DOWN) or pad.press(btnDown) then + menu_sel=menu_sel+1 + if menu_sel==2 then menu_sel=0 end + elseif key.press(keyUp) or key.press(key.UP) or pad.press(pad.UP) or pad.press(btnUp) then + menu_sel=menu_sel-1 + if menu_sel==-1 then menu_sel=1 end + elseif key.press(key.ESCAPE) or pad.press(btnPause) then + sys.quit() + end +end + +function to_game() + print("to game") + fade.fadeoutin() + flow:next() +end + +function to_options() + print("to options") +end \ No newline at end of file diff --git a/data/title_tiles.gif b/data/title_tiles.gif new file mode 100644 index 0000000..b6665ac Binary files /dev/null and b/data/title_tiles.gif differ diff --git a/data/warp.lua b/data/warp.lua index 7b12647..f7147cf 100644 --- a/data/warp.lua +++ b/data/warp.lua @@ -4,9 +4,11 @@ warp={ update=update_all, } -function warp.init() +function warp.init(tiles_sf) + local curr_source = surf.source() + local curr_target = surf.target() warp_sf=surf.new(32,32) - surf.source(tiles) + surf.source(tiles_sf) surf.target(warp_sf) local sprite_x = 11*16 local sprite_y = 15*16 @@ -14,6 +16,12 @@ function warp.init() draw.surfrot(sprite_x, sprite_y, 16, 16, 15, 0, 90) draw.surfrot(sprite_x, sprite_y, 16, 16, 15, 15, 180) draw.surfrot(sprite_x, sprite_y, 16, 16, 0, 15, 270) + surf.source(curr_source) + surf.target(curr_target) +end + +function warp.close() + surf.free(warp_sf) end function warp.new(_actor) @@ -39,9 +47,12 @@ function warp:draw() if not self.alive then return end local scr_x, scr_y = viewp:screen_coords( self.x, self.y ) local curr_sf=surf.source() + local target_sf=surf.target() surf.source(warp_sf) + surf.target(0) draw.surfrot(0,0,32,32,scr_x,scr_y,self.angle) surf.source(curr_sf) + surf.target(target_sf) end function warp:update() @@ -83,79 +94,3 @@ function warp.update_all() end end --- function warp:draw() --- if self.frame>0 then --- local scr_x, scr_y = viewp:screen_coords( self.x, self.y ) --- draw.surf((self.frame&7)*cw, (self.frame>>cxr2)*ch, cw, ch, scr_x, scr_y, cw, ch, self.flip) --- end --- end - --- function warp:update_normal() --- self.wait=self.wait+1 --- --- if self.wait==18 then --- self.wait=0 --- self.step=(self.step+1)%4 --- self.frame=self.anim[self.step+1] --- end --- --- local step = 1 --- if self.flip then step = -step end --- local inc = 0 --- if self.flip then inc = self.bb.w end --- --- local check_x = self.x+self.bb.x+step --- local check_ywall = self.y+self.h-2 --- local check_yhole = self.y+self.h+1 --- if not self.flip then --- check_x = self.x+self.bb.w+self.bb.x+step --- end --- --- local check_no_wall= arc_check_tile(check_x,check_ywall)=6 then --- self.wait=0 --- self.step=self.step+1 --- if self.step<40 then --- if self.step%2==0 then --- self.frame=16 --- else --- self.frame=-1 --- end --- elseif self.step>=40 then --- self.step=0 --- self.wait=0 --- self.update=warp.update_normal --- end --- end --- end --- --- function warp:hit() --- self.update=warp.update_hit --- end