0 4hVpЧp8d%qy;]AsVl$( 2TvͫgE#2Tv2Tv\UfwxVDDTUUE4#xE# 7ޫxgE#l|}D[evw^330#23#233""3##223""3##223""3##223""3##223""3##223""30#233333333333"####223"#"##""3"#"##""33333333####2222""""""""""""""""33333333###32"22"2"3""22"2"3""22""22"2"3""2""""2""2"""""""""""""##""3"#""#""#""""#""""""""""""""""""""""""""""2""""2""2""2"3""22"""""""""""""#""#""""#""3"#"##""@@@@3""2 #" 322223   0000#20""33""#2000""""""""""""""""""""""""""""""""##223""3##223""3##223""3##223""3""22"2"3""22"2"3""22"2"3""22"2"3##""3"#"##""3"#"##223"##33333333""""""""""""""""2222####33333333""22"2"3""22"2"32"22###333333333##""3"#"##""3"#"##""3"#"##""3"#"""""""""""""""""""""#""2##223""33""3##22#""2"""""""""""""""""""""" ""   "" ""   2322 32 #"3""232"3"2""3""2030#3"0#"3""0#""##223""3##""3"#"##""3"#"##""3"#"033#""2#B$2#"D2#"D2#B$2#""2033033#""2#""2#$B2#DD2#B$2#""2033@@@@@    033#B$2#B$2C$B4C$B4#B$2#B$2033"""3"""2""""""""""""""""""""""""3"""#"""""""""""""""""""""""""""##223""3""22"2"3""22"2"3""22"2"3033#""2#B$2#D"2#D"2#B$2#""2033033#""2#B$2#DD2#$B2#""2#""2033#2#2#1233#12#123333#3323333"1"2#"1""1"2#2#33333#0330030333DDDDD@D@@@DD@DD@@@@@@@@DDD@D@D@D@@D@D@DDDDDDD@DDDDD@@@@@@@@@@@@D@DDDDDD@DDD@@@@@@@@DDDDD@@DDDDDDDD@D@DDDDDD@DD@@DDDD@DDDDDDDDDD@DDD@@DDDDDDDAAAADDDDDDDDDDDDD@@@D@@@DDDDDDD@@DDD@@@AAAAAAAADDDDDDDDD@@@D@@DDDD@DDDDDD@DD@@@@DD@DDD@@DDDDDDDAAAADDD""  AA 33DDD3""33@DDD03@@""  AAD33DD03@D@""33DDD@3D  """  A//"""""""""""""""""!AD"""!DD333333033033033034030333@@DOADDD!"A"O"ADD"ADD"AD"DD"AAADDDDDDC30303330#33333233333033#33333030333333333333#33330AADADDA"A!ODAADDDDAADDDDDDD300330030033333333330#3332 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@7@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#$####$$3333333333333333##$ 666666666 4$433$33####$####$#44####4###4#$34$34#4$4343333$#$4$444###44&4$4$4$44####44$$4$443'333$$434$343444$3333#44344$$4#'#'##434#4$$#'#443$33334433$#4$$4$44#4#####'#####5##$4443$33#4$35##'#4333$$45##$44333333$45##$33333334$45#######$$43333333333###44####$44433333333333333333333"2########$###$433333$$443334333433344 #4$333333#4$#4$2#4$34$344334334333$$$$$$$$$4$##4444444443##$33$##$4$434$434$444$"24$4$4$4$434$433333333333334$444444444###############4$$  3333333333$43$$$$$3333333333333333333333333333333333334"433333333  " 0 0 ###444########4 |wfedobRRBM2""@@AAAAACJJIIHIMMLL K JJKLNNNNMM L QRSUVWXYYZ[[\]^^______________! `aaaaaaaaaaabdefgghijklllllllm0pppp3pEpGpip{sTp{rF|  0@Ppzp]<;) =Ea%ACCCCCCCCCCCCCCCCCCCCCCCC B  H    H`00@0``7?DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD!CDDDDDDDDDDDDDDDDDDD!CDDDDDDDDDDDDDDDDDDD43DDDDDDDDDDDDDDDDDDD43DDDDDDDDDDDDDDDDDDDD!3CDDDDDDDDDDDDDDDDDDD33DDDDDDDDDDDDDDDDDDD433CDDDDDDDDDDDDDDDDDDD!33CDDDDDDDDDDDDDDDDDD4!334DDDDDDDDDDDDDDDDDDD3!333DDDDDDDDDDDDDDDDDDD3133DDDDDDDDDDDDDDDDDDD4133CDDDDDDDDDDDDDDDDDD4!"1333DDDDDDDDDDDDDDDDDD4!""""""""333DDDDDDDDDDDDDDDDDDD3!!"""133CDDDDDDDDDDDDDDDDDD3!!"133DDDDDDDDDDDDDDDDDD3""A133DDDDDDDDDDDDDDDDDD3!"""""D33CDDDDDDDDDDDDDDDDD4"""""""""""A!133CDDDDDDDDDDDDDDDD4!!!"""""""""""!A1333DDDDDDDDDDDDDDDD43!!"""""""""""""!AAA"33334DDDDDDDDDDDDDDD3C!""""""""""""""""!ADAA"33C3CDDDDDDDDDDDDD334D!!"""""""""""""""AADD""33C3CDDDDDDDDDD3333CD"""""""""""""""AA""213333C4DDDDDDD3333DDD!"!"""""""""13"""!AAAA"2"13333CDD4DD43333ADDD!""!""""33333!"""!DDDDDDDDDAA""#21333333C33333C3DDDDDD!!""""133333!""""!DDDDDDA"2""33333333333CDDDDDDDDDD""""3333333"""""!DDD""""2313333333CDDDDDDDDADDDDD""""13DDDD43!""""DA"""333333CDDDDDDDDDDDDDD"""3DDDDDD43""!"D2"##3333313DDDDDDDDDDDDD4"""33DD4DDDD33"""!DDA""323333CCC33DDDDDCDDDDDD4"""133DDDCDDD43!DADDDDDDDDADDADA""2233334DCD"""1333DD43CDDDDD4"""133CDDDDDDD3333DDADADADADDA""233334CDDC!""!3333333CDDDDD3!""3CDDDDDDD43333!DADDDAAADAAA""3#333334DC!3333333DDDD3!""33?3DDDDDDD4333DADDDAADDAA""3#333C3DDCD!!1333DDD3"""1331CDDDDDDDD3!DAAADAAAA"#2#33333CCC!!133ADD3"""3D413DDDDADD!DAAAADDAADDDD"#2"333C3CCCD!""433"""CD3?CDDD3DD3!DAAAADAAAA"3#3333DD44DD!""3331!""DD13DD4ADD4!DADDDDADADAAA"2#3333C4DD4D!"33333!""DD33D4CDD4!ADDADDADDADAA"2"333333D!1433!""1DDD?33CDD4!ADDDADDDAADDADDAA"2#33333A133!""1DD4AD1CDD4!AADADDD""2333313331!""3DD4D3DD!"33#3333333!33!""3DD413!"#23333333!13""CDDD3"#2333134C33!!"13""CDDD4AD3!AADAD""33331CDD43!"133""3DDDD3CDD4ADDDDDDDDADDDDDDDDDDADDDDDD"#23331DDDD3!!133""3DDDDDDDD3D!DADADADDADDDADD"333#33DDDD3!!333""3CD4CDDDDAD"!DDDADDDDADAD"##231CDDDD43!!333""1CDD33DDDDDDDD1!"!DADADDDADAD!3331CDADDD3!!13D3""13CD33DDDDDADD13""!DADADDDADADD3!#333C4ADD3!!13D4""3CDD3CDDDDDDD13""!DDADDDADADD312333D4ADD33!3CD4""13DDDCDD43333333""!DADADDDAAADAD!3233D3ADD433CD4""3CDD3DD13!""!DADAADDDAADAD#3313D3ADD43!3CD4""33DDDD!""!DDDDDADDDDADADD#333C4DD433!3DDD""333CDDDDDDDDD!""DDDDDAADDDADADDDD!233C3ADD3313DD!""333DDDDDDDDDD!""DADADDDADDDDAD3!"2331ADD33!333""3331DDDDDDDD3!""!DADAADDADAAD33333ADD33!!13333""33331333333!""!DDADDDAAAAD41D3331D33!!1333"""1331!""!DDAADDDAAD4314133C1333333A?3"""133331!""!DADADDDAAD133C4333C13433!14DD433!""D433133333!"""!DDDAADDAAAD1433C133333333!!ADDD33!""DD413333D3333333!"""!DDADADADADDDDD33D333C4C333"""3DDD33!""DDD13C4CDC433C4"""!ADDDDDDDDADDDDDADDDDDDDDDD43D33333D3333!"""333ADDC""ADD433DDDDD43D4"""ADDDDDDDADDDDADDDDADDDADDDDDDADDDD4343333C3333311333CDDA"""ADDDCC4DCDDD4DD3!""DD3433333CD133333333D4A3"""DDD4C44D3DDDDD1!""!ADC133333C4133"1333C33333D4A3!""DDD4CD43DDDDDD"""!"DD133333CD3""133434433C33D4AD!""DDDDCD3CDDDDDD""""13333334D!""133CDD3D3D4D""DDDDCDCDDDDDD"""AA"23333333DC"""33433DD3C4DD!"DDDDD41CDDDDDD!"""A"22113333C4CCC""""333DDD333DD"DDDDD41CDDDDDDD!"""DA"2"333333CCCCD""""34DDDD313DDADDDDD3CDDDDDDD!"""A""#3233333CC3!"""""13DDDDDD43133ADDADDDD4331CDDDDDD!"""!DAADDA"23#23333C34C"!""""1CDDDDDD4333DDDADDDD4313DDDDDD"""!AAAADADAAA"23333333C3DD!"!"""3DDDDDD333331DDDDDDDC331DDDDDD""""!AADDAA"""3#333333CD""""""1DDDDD43333DDDDD3131CDDDDD!"""AAAAD""###333C33CD!"!""""CDDD433333CD3D33CDDDDD"""AAAAD"##3333333DDD""""""""1D4333331333DDDDD!"""!ADADAAA"""3323333DD"""""""1C3!13333CDDD"""ADDAADDDD""22#33343CD!""!""""""311CDD""""""32233333CD!"!"""""""!!""!""!313DD!!""!DA""333333334D!"""""""""""!""""""!!131CD"!""!AD"""333333CCC!""""""""""!""""""!"!33313D!!!"!""233333343C!"""""""!"!!"""""!!33333A!""!"""##33333CD!""""""!""""""!333C3DD!"!!"2##333333CD!!"""C!!""""""133D4CD!!""3"3#33A33C!""!1C433!""""""1133DDDD!""22#333333C!""13DA3"!"""!1144DDD!"""23"3333343!"11DD1!!""""!!"13D4DDD!"#"233333343D"1CD"""""3DDDD"#"3223333D3C"3D!!"""1CDDDD!"#"323333334D"3D!"!13DDDD"#2233333333D1CD!!1333DDD"""22333333344!1D!"!"333333CDD""322223343D3D"!""!33333DDDDD!""32333333C411CD!1333CDDDDDD""#2#333333C11C""1333DDDDDDD""#"3233333C33D!!"1333CDDDDDDD!""""3233333D33!"333CDDDDDDDD!"""3233333333C!!3333DDDDDDDDD!""#"3"3333313AD!"3333DDDDDDDDDD!""""233333313AD!!1333DDDDDDDDDDD!""#3#33333313C"!"333CDDDDDDDDDDD!"2#3"3333334D"!!1333DDDDDDDDDDDD"2"#"3333334D"1333DDDDDDDDDDDDD!"2""#3333134A!133CDDDDDDDDDDDDD!"22#"3333334AD"333DDDDDDDDDDDDDD!"""2##2333CDCD!133DDDDDDDDDDDDDDD!""23#23333CDD133CDDDDDDDDDDDDDDD!""""2233313DADD!333DDDDDDDDDDDDDDD!""2"#33213DDDD133CDDDDDDDDDDDDDDD""2#""331CDADCD!133DDDDDDDDDDDDDDDD"""22#233DACDD!133CDDDDDDDDDDDDDDDD!"""3"#221CD34CD"133CDDDDDDDDDDDDDDDD!"""3"#333CDC4CD!333DDDDDDDDDDDDDDDDD!"""33#233DD1C44D333CDDDDDDDDDDDDDDDDD"""3"333D1C44D!"333DDDDDDDDDDDDDDDDD"""3#321CD3344D!"113CDDDDDDDDDDDDDDDD"""###21C3344C!"333DDDDDDDDDDDDDDDDDD"""#"33D133C4D!!33333DDDDDDDDDDDDDDDDDD!""""2#3D134CDD!"33333CDDDDDDDDDDDDDDDDD!""#""CD333CCD!!"3331333DDDDDDDDDDDDDDDDDD!""#21D33C4CD!13333333CDDDDDDDDDDDDDDDDD"""CD1334DCD11333333313DDDDDDDDDDDDDDDDDD!"2"31CD3334CCD13133333313DD4DDDDDDDDDDDDDD!"""3DD3CD4D3D1333333313DD3DDDDDDDDDDDDDD"2"1CDD33D43CD3333333333333CDDDDDDDDDDDDD!""3DDD1333CDCDD13333333333CDDDDDDDDDDDDDD"""ADD133DC4CDD33333133ADDDDDDDDDDDDDD""CDD3333CDCDD1333313DDDDDDDDDDDDDD!""CA1333434CDD13DDDDDDDDDDDDDDD""CD3333433CDD!133ADDDAD3DDDDDDDD!""1CD33333344DD""""13ADDDAD3DDDDDDDD"A3CD33333DC4DD13ADDDA4CDDDDDDD!L-- title: The Tower of Einar (demo) -- author: mvu.one -- desc: A short demo of a platformer with no platforms -- script: lua -- TODO -- FLAGS: 0 wall, 1 ceil, 2 death, 7 bump DBG = true jump_pow = 4 grav = 0.3 term_v = 3 hang_grav = 0.25 hang_term_v = 2 speed = 1.8 bump = 1 -- Eventually save and load to pmem MEM = { s_room_x=2, s_room_y=7, intro=0, room3=0, chkpts=0, -- 32 checkpts keys=0, -- 32 keys (binary flags) } function checkpoint(key) if key~=nil then local k=2^key if MEM.chkpts&k~=0 then return end MEM.chkpts=MEM.chkpts|k end MEM.s_room_x=croom[1];MEM.s_room_y=croom[2] end ROOMS = { { -1, 15 }, { 22, 23 }, { 30, 31 }, { 38, 39 }, { 46, 47 }, { -1, 55 }, { -1, 63 }, } objs = {} -- stuff currently in room room_changed = true function cpc(x,y,s) -- collidepc return pc.x > x-s and pc.x < x+s and pc.y > y-s and pc.y < y+s end -- keys function check_key(key) return MEM.keys & (2^key) ~= 0 end function set_key(key)MEM.keys=MEM.keys|(2^key) end function make_key(x,y,key) return {tic=function() if not check_key(key) then if cpc(x,y,6) then set_key(key) GETKEY() local shake = mk_shake(2, 12).tic pulse.p = {{x=x+4,y=y+4,t=0}} table.insert(objs, {tic=function()shake();prtcl(pulse)end}) else spr(37,x,y,0,1) end end end} end function door_remap(keyvar) return function(tile,x,y) if tile == 53 or tile == 54 then if check_key(keyvar) then return 0 end end return tile end end ROOM_CONF = { [63] = {u=function() if MEM.intro==0 then st=false;MEM.intro=1 ctscene.scene=intro_scene() end objs[1]={tic=function()print("LEFT & RIGHT to jump\n\nor tap L/R screen", 8, 40, 1, false, 1, true)end} end}, [55] = {u=function() tblup(objs, { [1]={tic=function()print("HOLD to jump higher", 8, 40, 1, false, 1, true)end}, })end}, [47] = {u=function() if MEM.room3==0 then st=false;MEM.room3=1 ctscene.scene=room_3_scn() checkpoint() end end}, [46]={u=function()checkpoint(1)end}, [38]={u=function()checkpoint(2)end}, [31]={u=function()checkpoint(3)end}, [23]={ u=function() objs[1]=make_key(32, 24,0) end, remap=door_remap(0) }, [22]={ u=function()checkpoint(4)end, remap=door_remap(0) }, [15]={ u=function()ctscene.scene=demo_end()end } } -- utility function rooms(inx) return ROOMS[inx[2]][inx[1]] end M_LAST=false M_CURR=false M_X=0 function moused(dir) -- 2 or 3 if dir == 2 and M_CURR and M_X < 120 then return true elseif dir == 3 and M_CURR and M_X >=120 then return true end return false end function mousep(dir) if M_LAST then return false end return moused(dir) end function room2map(r) return { x = r % 8 * 30, y = r // 8 * 17 } end function dbg(s, x, y) if DBG then print(s, x, y, 8) end end function tblup(t, nt) for k, v in pairs(nt) do t[k] = v end end function anybtnp() return btnp(0) or btnp(1) or btnp(2) or btnp(3) or btnp(4) or mousep(2) or mousep(3) end function inputp(dir) return btnp(dir) or mousep(dir) end function inputd(dir) return btn(dir) or moused(dir) end -- math function rnd(mn, mx) return math.random(mn, mx) end function easeOut(t) return -(t * (t - 2)) end function clamp(x, mn, mx) return math.max(math.min(x, mx), mn) end -- Effects function mk_shake(intense,time) local t=time local i=intense return { tic=function() if t>0 then poke(0x3FF9, rnd(-i,i));poke(0x3FF9+1, rnd(-i,i));t=t-1 elseif t==0 then memset(0x3FF9,0,2);t=t-1 end end} end -- PARTICLES function prtcl(sys) for i = #sys.p, 1, -1 do local p = sys.p[i] sys.iter(p) if p.die then table.remove(sys.p, i) else sys.draw(p) end end if sys.r_iter ~= nil then sys.r_iter(sys) end end death_boom = { iter = function(p) p.x = p.x + p.vx p.y = p.y + p.vy if p.t == 0 then p.die = true end p.t = p.t - 1 end, draw = function(p) pix(p.x, p.y, 4) end, p = {} } dust = { iter = function(p) p.t = p.t + rnd(5, 20) / 50 if p.t >= 2 then p.die = true end local s = easeOut(p.t) * p.r local a = p.a * math.pi / 180 p.x = p.x + s * math.cos(a) p.y = p.y + s * math.sin(a) end, draw = function(p) circb(p.x, p.y, p.s, 3) end, p = {} } pulse = { iter = function(p) p.t = p.t + 1; if p.t == 10 then p.die = true end end, draw = function(p) circb(p.x, p.y, (20 / (-p.t - 1.5)) + 10, 4) end, p = { } } function dust_poof(x, y, amnt, st, en) for i = 0, amnt, 1 do table.insert(dust.p, { x = x, y = y, t = 0, a = rnd(st, en), r = rnd(80, 140) / 100, s = rnd(0, 1) } ) end end -- /PARTICLES -- BGM BGM={t=0,f=-1,r=-1} BB=0x13FFC function bgm_resume()if BGM.t>0 then music(BGM.t, BGM.f, BGM.r,true,true) end end function bgm_play(track) BGM={t=1,f=-1,r=-1} bgm_resume() end function bgm_pause() BGM.f=peek(BB+1) BGM.r=peek(BB+2) music() end -- /BGM -- sfx WALLHIT=function()sfx(63, "A-6", 6)end GETKEY=function()sfx(5, "B-6", 12, 0, 10)end BOOSTSFX=function()sfx(6, "B-3", 12, 0, 15)end BSFXC=0 -- /sft -- DIALOGUE dlg = { open = false, spr = false, max = 0, c = 1, d = "", next = nil } function say(text, spr, next) tblup(dlg, { open = true, spr = spr~=nil and spr or dlg.spr, d = text, c = 1, max = #text }) dlg.next = next end function saynext(text, spr, next) return function() say(text, spr, next) end end function saychain(chain, next) local n = next for i=#chain,1,-1 do local v = chain[i] local old_n = n n = function()say(v[1], v[2], old_n)end end n() end function handle_dialogue() map(0, 0, 30, 3, 0, 112, 0) spr(dlg.spr, 0, 112, 0, 1, 0, 0, 3, 3) local cur = dlg.c // 1 if dlg.c < dlg.max then local old = cur dlg.c = dlg.c + 0.5 cur = dlg.c // 1 if old < cur and string.sub(dlg.d, cur, cur) ~= " " then sfx(0, 'C-3', 2);trace('old') end if anybtnp() then dlg.c = dlg.max end else spr(192, 232, 128, 0) if anybtnp() then if dlg.next ~= nil then dlg.next() else dlg.open = false end return end end print(string.sub(dlg.d, 1, cur), 30, 118, 4, false, 1, true) end ddb = { a = { "What manner of cave is this?\nI've never seen such construction!", }, b = { "I'll not forget the friends I've met along the way.", 100, { "like sad lizard." } } } -- /DIALOGUE -- WAITING waiting = 0 function wait(time) if time then waiting = time; return false end waiting = waiting - 1 if waiting < 0 then return true else return false end end function ctswait(s) if wait() then s.done=1 end end -- CUTSCENE SYSTEM?? ctscene = {scene=nil} function handle_cutscene() local act = nil for _,v in ipairs(ctscene.scene.acts) do if not v.done then act = v break end end if act == nil then ctscene.scene = nil return end ctscene.scene.always() act.tic(act) end intro_scene = function() local anim={x=132,y=148} local grav=-6 local ic=257 local odor = true local shake=mk_shake(2,30).tic wait(30) return { always=function()dmap();prtcl(dust);spr(ic,anim.x,anim.y, 0) end, acts={ {tic=ctswait}, -- Fly in {tic=function(s) anim.x=anim.x-2;anim.y=anim.y+grav;grav=grav+0.3; if anim.x<104 then ic=258 anim.x=104;s.done=1;dust_poof(anim.x, anim.y + 7, 50, -90, 90);WALLHIT() wait(40) saychain({ {"I got into tall tower!", 464, }, {"I bet have good thing at top!"}, }) -- reset player here tblup(pc, { vx=0,vy=0,x=anim.x,y=anim.y, j_hold = 0, j_dir = 1, w = {l=1,r=0}, sp="lw" }) end end}, {tic=function(s)shake();ctswait(s)end}, {tic=function(s) handle_dialogue();if not dlg.open then s.done=1 end end} } } end room_3_scn = function() local anim={x=172,y=148} local grav=-6 local ic=257 wait(30) return { -- Draw map and dust always=function()dmap();prtcl(dust);spr(ic,anim.x,anim.y, 0) end, acts={ {tic=ctswait}, -- Fly in {tic=function(s) anim.x=anim.x-2;anim.y=anim.y+grav;grav=grav+0.3; if anim.x<152 then ic=258 anim.x=152;s.done=1;dust_poof(anim.x, anim.y + 7, 50, -90, 90);WALLHIT() wait(40) saychain({ {"...", 464, }, {"This tower strange..."}, {"Made of odd smooth stone... has no floors...\nNot like home cave."}, {"..."}, {"No need floors!\nArms big and strong!"}, {"I CLIMB!"} }) -- reset player here tblup(pc, { vx=0,vy=0,x=anim.x,y=anim.y, j_hold = 0, j_dir = 1, w = {l=1,r=0}, sp="lw" }) end end}, {tic=ctswait}, {tic=function(s) handle_dialogue();if not dlg.open then s.done=1;bgm_play(1) end end} } } end function demo_end() local anim={x=172,y=148} local grav=-6 local ic=257 music() wait(30) return { -- Draw map and dust always=function()dmap();prtcl(dust);spr(ic,anim.x,anim.y, 0) end, acts={ {tic=ctswait}, -- Fly in {tic=function(s) anim.x=anim.x-2;anim.y=anim.y+grav;grav=grav+0.3; if anim.x<152 then ic=258 anim.x=144;s.done=1;dust_poof(anim.x, anim.y + 7, 50, -90, 90);WALLHIT() wait(40) saychain({ {"Made it!", 464}, {"............."}, {"... nothing here?"}, {"Nope! This is just the demo!", 467}, {"The full game will have lasers and double jumps\nand you can fight God!"}, {"...............", 464}, {"...............", 467}, {"... Talking lizard????", 464}, {"Uh.. Please submit any feedback if you can!", 467}, {"Eh??", 464}, {"Use the comments below to let us know\nhow we can make the game better!", 467}, {"Thank you for playing!"} }) tblup(pc, { vx=0,vy=0,x=anim.x,y=anim.y, j_hold = 0, j_dir = 1, w = {l=1,r=0}, sp="lw" }) end end}, {tic=ctswait}, {tic=function(s) handle_dialogue(); end} } } end function lizard_1() saychain({ {"...lizard?", 464}, {"Ah! A fellow climber of the Tower of Einar!\nAnd the first of your race I've seen here!", 477}, {"...", 464}, {"It is good to meet another with the will to defy God!\nTo climb and claim godhood for one's own!", 477}, {"Such might of heart! Such strength of mind!\nIt makes my cold blood run hot!"}, {"Alas my own climb goes poorly. It is a kindness that climbers cannot\nperish so long as their will remains strong."}, {"...", 464}, {"Lizard..........\nhow you talk?"}, {"Ah! Within the tower all being can communicate freely!\nThe wonders of the tower are unending!", 477}, {"..................................\nyou are smart lizard?"}, {"... quite."}, }) return { {} } end -- /CUTSCENES -- player and map stuff function mcoo(x, y) m = room2map(rooms(croom)) return { x = m.x + x // 8, y = m.y + y // 8 } end function tile(x, y) if x < 0 or x > 239 or y < 0 or y > 135 then return -1 end m = mcoo(x, y) local t = mget(m.x, m.y) if conf and conf.remap ~= nil then return conf.remap(t) else return t end end function flag(x, y, f) m = mcoo(x, y) return fget(tile(x, y), f) end croom = { MEM.s_room_x, MEM.s_room_y } function find_start_point() -- find the X tile for x = 0, 239, 8 do for y = 0, 135, 8 do if tile(x, y) == 25 then return { x = x, y = y } end end end end spmap = { lw = 258, rw = 259, lf = 257, rf = 256, b= 260 } function clear_room() dust.p = {} objs = {} conf = ROOM_CONF[croom] room_changed = true if conf ~= nil and conf.d ~= nil then conf.d() end end function restart() music() bgm_resume() clear_room() croom = { MEM.s_room_x, MEM.s_room_y } local s = find_start_point() pc = { x = s.x, y = s.y, vx = 0, vy = 0, j = 0, j_hold = 0, j_dir = 1, w = {}, sp = "" } if flag(pc.x - 2, pc.y + 2, 0) then pc.w = { l = 1, r = 0 } pc.sp = "lw" else pc.w = { l = 0, r = 1 } pc.sp = "rw" end dust.p = {} st = false freeze = false death = false end restart() trace(room2map(rooms(croom))["y"]) function go_n() croom[2] = croom[2] - 1; pc.y = pc.y + 130 trace("north") trace(croom[1] .. " " .. croom[2]) end function go_s() croom[2] = croom[2] + 1; pc.y = pc.y - 130 end function go_e() croom[1] = croom[1] + 1; pc.x = pc.x - 240 end function go_w() croom[1] = croom[1] - 1; pc.x = pc.x + 240 end function crnr() -- gets player corner functions -- ignore OOB corners local tiles = { tl = tile(pc.x, pc.y), tr = tile(pc.x + 7, pc.y), tc = tile(pc.x + 4, pc.y), bl = tile(pc.x, pc.y + 7), br = tile(pc.x + 7, pc.y + 7), bc = tile(pc.x + 4, pc.y + 7), cc = tile(pc.x+4,pc.y+4), dtl = tile(pc.x+1, pc.y+1), dtr = tile(pc.x+6, pc.y+1), dbl = tile(pc.x+1, pc.y+6), dbr = tile(pc.x+6, pc.y+6), } return { ftl = function(f) return fget(tiles.tl, f) end, ftr = function(f) return fget(tiles.tr, f) end, ftc = function(f) return fget(tiles.tc, f) end, fbl = function(f) return fget(tiles.bl, f) end, fbr = function(f) return fget(tiles.br, f) end, fbc = function(f) return fget(tiles.bc, f) end, fcc = function(f) return fget(tiles.cc, f) end, ttl = tiles.tl, ttr = tiles.tr, ttc = tiles.tc, tbl = tiles.bl, tbr = tiles.br, tbc = tiles.bc, tcc = tiles.cc, -- 1 extra pixel of tolerance for death stuff fdtl = function(f) return fget(tiles.dtl, f) end, fdtr = function(f) return fget(tiles.dtr, f) end, fdbl = function(f) return fget(tiles.dbl, f) end, fdbr = function(f) return fget(tiles.dbr, f) end, } end function pflags() c = crnr() return { cwalL = c.ftl(0) or c.fbl(0), cwalR = c.ftr(0) or c.fbr(0), croof = c.ftr(1) or c.ftl(1), cbump = c.fbc(7), die = c.fdbl(2) or c.fdbr(2) or c.fdtl(2) or c.fdtr(2), boost = (function() if c.fcc(3) then return c.tcc end end)(), chroom = (function() if pc.y+3 < 0 then return go_n end if pc.y+3 > 136 then return go_s end if pc.x+3 > 240 then return go_e end if pc.x+3 < 0 then return go_w end end)() } end function dmap() r = room2map(rooms(croom)); map(r.x, r.y, 30, 17, 0, 0, 0, 1, conf and conf.remap or nil) end function dp() spr(spmap[pc.sp], pc.x, pc.y, 0) end function stick_l() pc.vx=0;pc.w.l=1;pc.w.r=0;pc.sp="lw" pc.x = math.ceil(pc.x / 8) * 8 dust_poof(pc.x, pc.y + 7, 50, -90, 90) WALLHIT() end function stick_r() pc.vx=0;pc.w.r=1;pc.w.l=0;pc.sp="rw" pc.x = pc.x // 8 * 8 dust_poof(pc.x + 7, pc.y + 7, 50, 90, 270) WALLHIT() end function p_jump() pc.vy = clamp(pc.vy + grav, -jump_pow, term_v) pc.vx = clamp(pc.vx + pc.j_dir * 0.8, -speed, speed) -- variable jump if pc.j_hold ~= 0 and not inputd(pc.j_hold) and pc.vy < 0 then pc.j_hold = 0 pc.vy = pc.vy / 2 end if pc.vy > term_v then pc.vy = term_v end if fl.croof and pc.vy < 0 then pc.vy = 0 pc.y = math.ceil(pc.y / 8) * 8 elseif fl.cbump then --pc.y = math.floor(pc.y/8)*8 if pc.vy > 0 then pc.vy = -bump end elseif fl.cwalL and pc.vx < 0 then pc.vy = 0;pc.j=0 stick_l() elseif fl.cwalR and pc.vx > 0 then pc.vy = 0;pc.j=0 stick_r() end end function p_hang() pc.vy = pc.vy + 0.25 if pc.vy > 1 then pc.vy = 1 end if pc.w.l > 0 then dust_poof(pc.x, pc.y + 4, 4, -90, -80) if not flag(pc.x - 2, pc.y + 2, 0) then pc.w.r = -1 pc.w.l = -1 end elseif pc.w.r > 0 then dust_poof(pc.x + 7, pc.y + 4, 4, -100, -90) if not flag(pc.x + 9, pc.y + 2, 0) then pc.w.r = -1 pc.w.l = -1 end end end function p_fall() if pc.vx > 0 then pc.sp = 'lf' else pc.sp = 'rf' end pc.vy = pc.vy + grav if pc.vy > term_v then pc.vy = term_v end if fl.cwalR or flag(pc.x + 8, pc.y + 6, 0) then pc.x = pc.x + 1 stick_r() elseif fl.cwalL or flag(pc.x - 1, pc.y + 6, 0) then -- Fudge left a pixel pc.x = pc.x - 1 stick_l() end end function p_boost(tile) pc.sp='b' pc.w.l = -1; pc.w.r = -1 pc.j_hold = 0 local cx = (pc.x+4) // 8*8 local cy = (pc.y+4) // 8*8 if (tile == 35 or tile == 51) then pc.y = cy elseif (tile == 36 or tile == 52) then pc.x = cx end -- if (tile == 35 or tile == 51) then -- if (pc.vy > 0) then pc.y = math.ceil(pc.y/8) * 8 -- else pc.y = pc.y // 8 * 8 end -- elseif (tile == 36 or tile == 52) then -- if (pc.vx > 0) then pc.x = math.ceil(pc.x/8) * 8 -- else pc.x = pc.x // 8 * 8 end -- end if tile == 35 then pc.vx = 3 pc.vy = 0 elseif tile == 36 then pc.vx = 0 pc.vy = 3 elseif tile == 51 then pc.vx = -3 pc.vy = 0 elseif tile == 52 then pc.vx = 0 pc.vy = -3 end end --say("Now we have a dialogue system!",464,saynext("....", 464, saynext("..Did we need a dialogue system for a platformer?"))) function TIC() M_LAST=M_CURR M_X,_,M_CURR=mouse() cls(1) if room_changed then trace("Room Changed") conf = ROOM_CONF[rooms(croom)] if conf ~= nil and conf.u ~= nil then conf.u(); trace('setup') end room_changed = false end -- room stuff even if talking if ctscene.scene~=nil then handle_cutscene() return end dmap() for _, o in ipairs(objs) do if o ~= nil then o.tic() end end if dlg.open then handle_dialogue() return end if death then prtcl(death_boom) if #death_boom.p == 0 then restart() end return end if (inputp(2) or inputp(3)) and freeze==false then local pressed if inputp(2) then pressed = 2 elseif inputp(3) then pressed = 3 end if (pc.w.l + pc.w.r > 0) then if pressed == 3 then pc.j_dir = 1; pc.sp = "rf" elseif pressed == 2 then pc.j_dir = -1; pc.sp = "lf" end pc.vy = -jump_pow pc.j_hold = pressed if pc.w.l == 1 then pc.w.l = 0; pc.vx = speed elseif pc.w.r == 1 then pc.w.r = 0 pc.vx = -speed end elseif (pc.w.l + pc.w.r == 0) and pc.j > 0 then pc.j = pc.j - 1 dust_poof(pc.x + 4, pc.y + 7, 6, 60, 120) pc.j_hold = 1 if pc.vy <= -(jump_pow - 2) then pc.vy = -jump_pow else pc.vy = -(jump_pow - 2) end end st = true end if st then pc.x = pc.x + pc.vx pc.y = pc.y + pc.vy fl = pflags() if (fl.chroom ~= nil) then fl.chroom() clear_room() return end if fl.boost ~= nil then BSFXC = BSFXC + 1 if BSFXC == 12 then BSFXC = 0 BOOSTSFX() end p_boost(fl.boost) elseif (pc.w.l + pc.w.r == 0) then p_jump() elseif (pc.w.r + pc.w.l > 0) then p_hang() elseif (pc.w.r + pc.w.l < 0) then p_fall() end if fl.die then death = true bgm_pause() music(0) for i = 1, 1000, 1 do table.insert( death_boom.p, { x = pc.x + 4, y = pc.y + 4, t = rnd(2, 100), vx = rnd(-400, 400) / 100, vy = rnd(-400, 400) / 100 } ) end end end -- if st prtcl(dust) dp() m = mcoo(pc.x, pc.y) end -- function SCN(r) -- pokes color 13 -- local rr = r//4 -- poke(0x3fe7, 39-rr) -- poke(0x3fe8, 39-rr) -- poke(0x3fe9, 39-rr) -- end