123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865 |
- -- title: Alter Ego (WIP)
- -- author: ORIGINAL ZX SPECTRUM GAME BY DENIS GRACHEV
- -- NES CONVERSION BY SHIRU
- -- NES MUSIC BY RICHARD "KULOR" ARMIJO
- -- TIC-80 CONVERSION BY KYUCHUMIMO AND PIXELBATH
- -- desc: My first TIC-80 program
- --WARNING: Saved on TIC-80 0.80.xxxx beta. Music doesn't work on previous versions.
- --CHANGELOG:
- --201120 - pixelbath joined the project. Code optimization: 26473 to 21757 bytes. Changelog moved to tic80.com/play?cart=1420
- --INFO:
- --https://tic80.com/play?cart=1420
- --https://www.youtube.com/watch?v=O3uOHAvlsN8
- --http://www.retrosouls.net/?page_id=614
- -- script: lua
- --VARIABLES
- --climb
- c=0
- --sprite flip
- f=0
- --lives
- l=5
- --LEVEL (DEFAULT=0)
- m=0
- --pixels (KEEP AWAY FROM 0)
- px=0
- aepx=0
- --swap
- s=0
- --EVENT TIMER
- et=nil
- --GLOBAL TIMER
- t=0
- --bridge animation trigger
- btrig=0
- --FALL TRIGGER
- ftrig=0
- --PAUSE TRIGGER
- ptrig=0
- --SWAP TRIGGER
- strig=0
- --ALTER EGO mirroring (0=H,1=V)
- aeo=0
- --HERO animation ticks
- anix=0
- aniy=0
- --HERO X position
- animx=0
- --HERO Y position
- animy=0
- --ALTER EGO X position
- aex=0
- --ALTER EGO Y position
- aey=0
- --palette RGB value
- v=0
- options = {
- music = true,
- debug = true,
- }
- cls()
- map()
- --PALETTE STUFF
- local basepalette = {
- 0x1a1c2c, 0x29366f, 0x3b5dc9, 0x493c2b, 0x5d275d, 0x38b764, 0xb13e53, 0x333c57, 0x41a6f6, 0xef7d57, 0x94b0c2, 0xa7f070, 0xe06f8b, 0x73eff7, 0xffcd75, 0xf4f4f4
- }
- function pal(v)
- for i = 1, #basepalette do
- local offset, color = i-1, basepalette[i]
- poke(0x3fc0+(offset*3), ((color//65536) * v))
- poke(0x3fc1+(offset*3), ((color//256)%256) * v)
- poke(0x3fc2+(offset*3), (color%256) * v)
- end
- end
- function fade_out(et)
- if t==(et+(2.1*60)) then
- if mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8)==6 or mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8)==151 or mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8)==152 or mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8)==153 then music() end
- return pal(1)
- end
- if t==(et+(2.2*60)) then return pal(0.75) end
- if t==(et+(2.3*60)) then return pal(0.5) end
- if t==(et+(2.4*60)) then return pal(0.25) end
- if t==(et+(2.5*60)) then return pal(0) end
- end
- function fade_in(et)
- if t==(et+(0*60)+1) then return pal(0) end
- if t==(et+(0.1*60)) then return pal(0.25) end
- if t==(et+(0.2*60)) then return pal(0.5) end
- if t==(et+(0.3*60)) then return pal(0.75) end
- if t==(et+(0.4*60)) then return pal(1) end
- end
- -- PARTICLE/VFX STUFF
- waterlevel = 120 -- y coordinate of the water
- particletype='stars' -- snow|rain|stars
- particles = {}
- local starcolors = { 1, 2, 13, 15}
- function particleinit()
- if particletype == 'stars' then
- for i = 0,15 do
- table.insert(particles, {
- x = math.random() * 240,
- y = math.random() * waterlevel,
- twinkle = math.random() > 0.49, -- randomly pick true/false
- color = starcolors[math.random(#starcolors)],
- t = 0,
- })
- end
- end
- end
- function particleupdate()
- if particletype == 'stars' then
- for i = 1,#particles do
- local p = particles[i]
- if not p.twinkle then goto continue end
- ::continue::
- if t % 15 == 0 and math.random() > 0.1 then
- p.color = starcolors[math.random(#starcolors)]
- end
- end
- end
- end
- function particledraw()
- for i = 1,#particles do
- local p = particles[i]
- pix(p.x, p.y, p.color)
- end
- end
- particleinit()
- --(shx: Xpos, shy: Ypos, shf: flip, sht: timer) CHECK THIS
- function skullh(shx,shy,shf,sht)
- --local shx
- --local shy
- --local sht
- --local shf
- if mget((30*m%240)+((shx-8)//8),(17*(m//8))+((shy+8)//8))==0 or mget((30*m%240)+((shx+8)//8),(17*(m//8))+((shy+8)//8))==0 then
- if shf==0 then shf=1 else shf=0 end
- --sht=0
- spr(288+t%16//4,(shx*8)+(sht//8),(shy*8),0,1,shf,0,1,2)
- else
- --sht=sht+1
- spr(288+t%16//4,(shx*8)-(sht//8),(shy*8),0,1,shf,0,1,2)
- end
-
- if (animx*8+(anix//10))==shx*8 and ((animy*8+(aniy//10))+8)==(shy*8)+8 then
- ftrig=0
- l=l-1
- sfx(56,45,-2,0)
- t=0
- level(m)
- end
-
- --SCREEN SKULL SPR POSITION DEBUG
- --print(shx*8,22,24)
- --print((shy*8)+8,22,30)
- end
-
- --LEVEL PROPERTIES (ANIMX/Y LIMITS(1-28,1-14))
- function level(m)
-
- sync(0,0,false)
- c=0
- f=0
- px=nil
- aepx=nil
- anix=0
- aniy=0
- et=-255
- strig=0
- ftrig=0
-
- --HELLO WORLD
- if m==2 then
- t=0
- s=2
- px=3
- aepx=0
- aeo=0
- animx=21
- animy=3
- end
-
- --PROMENADE
- if m==3 then
- s=2
- px=8
- aepx=0
- aeo=0
- animx=5
- animy=3
- end
- --BROKEN BRIDGE
- if m==4 then
- s=0
- px=8
- aepx=0
- aeo=0
- animx=11
- animy=8
- end
-
- --PHANTOM PIXELS
- if m==5 then
- s=3
- px=2
- aepx=4
- aeo=0
- animx=14
- animy=3
- end
- --ANOTHER PHANTOM
- if m==6 then
- s=4
- px=13
- aepx=0
- aeo=1
- animx=3
- animy=10
- end
- --SKULLS LAIR
- if m==7 then
- s=2
- px=14
- aepx=0
- aeo=0
- animx=17
- animy=13
- end
-
- --ABRACADABRA
- if m==8 then
- s=2
- px=6
- aepx=6
- aeo=0
- animx=9
- animy=10
- end
-
- --VERTICAL ILLUTIONS
- if m==9 then
- s=8
- px=10
- aepx=0
- aeo=1
- animx=4
- animy=9
- end
- --MIRRORS
- if m==10 then
- s=2
- px=4
- aepx=3
- aeo=0
- animx=26
- animy=11
- end
- --16 PIXELS
- if m==11 then
- s=4
- px=16
- aepx=0
- aeo=0
- animx=5
- animy=9
- end
- --PERFECT REFLECT
- if m==12 then
- t=0
- s=1
- px=16
- aepx=0
- aeo=0
- animx=15
- animy=10
- end
- --ICELANDS
- if m==13 then
- s=3
- px=5
- aepx=3
- aeo=0
- animx=15
- animy=9
- end
- --MIDNIGHT
- if m==14 then
- s=2
- px=5
- aepx=0
- aeo=0
- animx=23
- animy=12
- end
-
- --ALONE SKULL
- if m==15 then
- s=3
- px=3
- aepx=2
- aeo=0
- animx=15
- animy=2
- end
- --MADE IN HEAVEN
- if m==16 then
- s=5
- px=9
- aepx=6
- aeo=1
- animx=4
- animy=4
- end
- --UNDERWATER
- if m==17 then
- s=2
- px=3
- aepx=5
- aeo=0
- animx=2
- animy=9
- end
- --ZUPAPIXELS
- if m==18 then
- s=9
- px=8
- aepx=1
- aeo=0
- animx=3
- animy=2
- end
-
- --SKULLOPEDIA
- if m==19 then
- s=4
- px=12
- aepx=0
- aeo=0
- animx=7
- animy=12
- end
- --AFTER THE WAR
- if m==20 then
- s=3
- px=8
- aepx=0
- aeo=1
- animx=3
- animy=2
- end
- --VIRUS KVARTIRUS
- if m==21 then
- s=6
- px=11
- aepx=0
- aeo=0
- animx=24
- animy=13
- end
-
- --END
- if m==22 then
- t=0
- l=143
- s=143
- px=-255
- aepx=-255
- aeo=0
- animx=-1
- animy=-2
- mset((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+((animy*8+(aniy//10))//8),1)
- mset(((30*m%240)+(animx*8+(anix//10))//8)-1,(17*(m//8))+((animy*8+(aniy//10))//8)+1,1)
- mset((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+((animy*8+(aniy//10))//8)+2,1)
- mset(((30*m%240)+(animx*8+(anix//10))//8)+1,(17*(m//8))+((animy*8+(aniy//10))//8)+1,1)
- end
- end
- level(m)
- function TIC()
- --MUSIC (For loop use t%(spd*rows*#patterns used)==0)
- if options.music then
- --TITLE SCREEN
- if m==1 and t==0 then music(0,-1,-1,false) end
- --LEVELS 1-10
- if m>=2 and m<=11 and t==0 then music(1,-1,-1,false) end
- --LEVELS 11-21
- if m>=12 and m<=21 and t==0 then music(2,-1,-1,false) end
- --LEVELS 21-???
- if m>=22 and t==0 then music(3) end
- end
- --TIMER
- if ptrig==0 then t=t+1 end
- --CREDITS
- if m==0 then
- map(0,0,30,17)
- if options.debug then
- print(t,0,0,15,true,1,true)
- print(et,0,6,15,true,1,true)
- end
- fade_in(0)
- if t==(3*60) or keyp(50) then
- et = 180
- t = et+180
- end
- if t>(et+(3*60)) and et>=0 then
- m=m+1
- t=0
- et=-255
- else
- fade_out(et)
- return
- end
- end
-
- --TITLE SCREEN
- if m==1 then
- l=5
- --REMAP
- cls()
- map(30*m%270,17*((m-1)//8),30,17,0,0,0,1)
- fade_in(0)
-
- particleupdate()
- particledraw()
- if t<0.4*60 then return end
- if options.debug then
- print("DEBUG: Press X/A and Y/S to switch levels",8,131)
- print(et,0,0,15,true,1,true)
- end
- if keyp(50) and et<=0 then
- music()
- sfx(51,43,-1,0,15)
- et=t
- end
- if t>(et+(3*60)) and et>=0 then
- m=m+1
- level(m)
- else
- fade_out(et)
- return
- end
- end
- --LEVEL DISPLAY
- if m>1 then
- fade_in(0)
- --REMAP
- cls()
- map(30*m%240,17*(m//8),30,17,0,0,0,1)
-
- particleupdate()
- particledraw()
- --SKULLH LIMITS(1-28,1-14)
- --skullh(12,10,0,0)
- --if btn(5) then skullh(25,3,0,0) end
- --skullh(20,6,0,0)
-
- --LEVEL CLEAR
- if px==0 and aepx==0 and anix==0 and aniy==0 then
- if et<0 then
- sfx(52,36,90,0)
- for i=0,29 do
- mset((30*m%240)+i,(17*(m//8)),0)
- end
- mset((30*m%240)+10,(17*(m//8)),91)
- mset((30*m%240)+11,(17*(m//8)),84)
- mset((30*m%240)+12,(17*(m//8)),101)
- mset((30*m%240)+13,(17*(m//8)),84)
- mset((30*m%240)+14,(17*(m//8)),91)
- mset((30*m%240)+16,(17*(m//8)),82)
- mset((30*m%240)+17,(17*(m//8)),91)
- mset((30*m%240)+18,(17*(m//8)),84)
- mset((30*m%240)+19,(17*(m//8)),80)
- mset((30*m%240)+20,(17*(m//8)),97)
- et=t
- end
- if et>0 then
- spr(257+(f*3),animx*8+(anix//10),animy*8+(aniy//10),0,1,f,0,1,2)
- spr(265,aex,aey,0,1,0,0,1,2)
- fade_out(et)
- end
- if t<et+(3*60) then
- return end
- m=m+1
- t=1
- level(m)
- end
- --STATUS DISPLAY
- mset((30*m%240)+3,(17*(m//8)),112+l)
- mset((30*m%240)+7,(17*(m//8)),112+s)
- end
- --GAME OVER
- if l==0 then
- map(210,119,30,17)
- sfx(-1,-1,-1,0)
- sfx(-1,-1,-1,1)
- sfx(-1,-1,-1,2)
- sfx(-1,-1,-1,3)
- if t==1 then
- music(6,-1,-1,false)
- end
- fade_in(0)
- if t<8*60 then
- return
- end
- m=1
- level()
- t=0
- end
- --DEATH
- if mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8)==6 or mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8)==151 or mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8)==152 or mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8)==153 then
- if et<0 then
- sfx(56,45,-2,0)
- sfx(60,45,-2,1)
- et=t
- end
- if et>0 then
- spr(331+t%8//4,animx*8+(anix//10),animy*8+(aniy//10),0,1,0,0,1,2)
- spr(329+t%8//4,aex,aey,0,1,0,0,1,2)
- fade_out(et)
- end
- if t<et+(3*60) then
- return end
- ftrig=0
- l=l-1
- t=0
- level(m)
- end
-
- --FALL
- if not ((mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==1 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==2 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==17 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==18 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==10 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==11 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==26 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==27 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==5 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==37 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==48 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==49 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==16 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==32 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==5 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==37) and anix==0 and aniy==0 and strig==0 then
- if ftrig==0 and l>0 then sfx(57,82,-1,0) end
- ftrig=1
- animy=animy+1
- aniy=-80
- spr(263+t%8//4,animx*8+(anix//10),animy*8+(aniy//10),0,1,0,0,1,2)
- end
- --NOTHING
- if anix==0 and aniy==0 and t>(2*60) then
- if ftrig==1 and strig==0 then sfx(58,24,-1,0) end
- if strig==0 then
- spr(256+c,animx*8+(anix//10),animy*8+(aniy//10),0,1,f,0,1,2)
- else
- spr(301+t%8//4,animx*8+(anix//10),animy*8+(aniy//10),0,1,f,0,1,2)
- end
- ftrig=0
- btrig=0
- end
- if t<(2*60) then
- spr((256+c)+((t%20//10)*15),animx*8+(anix//10),animy*8+(aniy//10),0,1,f,0,1,2)
- end
-
- if m>1 then
- --CONTROLS, COLLISION and SFX
- --UP(0),DOWN(1),LEFT(2),RIGHT(3)
- if strig==0 and t>(2*60) and ptrig==0 then
- if btn(0) and (mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10))//8)==5 or mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10))//8)==37) and anix==0 and aniy==0 then
- ftrig=0
- sfx(63,84,-1,3)
- animy=animy-1
- aniy=80
- end
- if btn(1) and (mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8)==0 or mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8)==5 or mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8)==37) and anix==0 and aniy==0 then
- ftrig=0
- sfx(63,84,-1,3)
- animy=animy+1
- aniy=-80
- end
- if btn(2) and anix==0 and aniy==0 and not ((mget((30*m%240)+(animx*8+(anix//10)-8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==1 or (mget((30*m%240)+(animx*8+(anix//10)-8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==2 or (mget((30*m%240)+(animx*8+(anix//10)-8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==17 or (mget((30*m%240)+(animx*8+(anix//10)-8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==18 or (mget((30*m%240)+(animx*8+(anix//10)-8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==10 or (mget((30*m%240)+(animx*8+(anix//10)-8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==11 or (mget((30*m%240)+(animx*8+(anix//10)-8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==26 or (mget((30*m%240)+(animx*8+(anix//10)-8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==27) then
- ftrig=0
- --BRIDGE
- if mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8)==48 or mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8)==49 then
- sfx(61,0,-1,3)
- mset((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+((animy*8+(aniy//10))//8)+2,0)
- btrig=1
- else
- sfx(62,0,-1,3)
- end
- animx=animx-1
- anix=80
- end
- if btn(3) and anix==0 and aniy==0 and not ((mget((30*m%240)+(animx*8+(anix//10)+8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==1 or (mget((30*m%240)+(animx*8+(anix//10)+8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==2 or (mget((30*m%240)+(animx*8+(anix//10)+8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==17 or (mget((30*m%240)+(animx*8+(anix//10)+8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==18 or (mget((30*m%240)+(animx*8+(anix//10)+8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==10 or (mget((30*m%240)+(animx*8+(anix//10)+8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==11 or (mget((30*m%240)+(animx*8+(anix//10)+8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==26 or (mget((30*m%240)+(animx*8+(anix//10)+8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8))==27) then
- ftrig=0
- --BRIDGE
- if mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8)==48 or mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8)==49 then
- sfx(61,0,-1,3)
- mset((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+((animy*8+(aniy//10))//8)+2,0)
- btrig=1
- else
- sfx(62,0,-1,3)
- end
- animx=animx+1
- anix=-80
- end
- --A/Z(4),B/X(5),X/A(6),Y/S(7)
- if (btnp(4) or btnp(5)) and m>=2 then
- if s>0 and not (mget((30*m%240)+aex//8,(17*(m//8))+((aey+8)//8))==1 or mget((30*m%240)+aex//8,(17*(m//8))+((aey+8)//8))==2 or mget((30*m%240)+aex//8,(17*(m//8))+((aey+8)//8))==16 or mget((30*m%240)+aex//8,(17*(m//8))+((aey+8)//8))==17 or mget((30*m%240)+aex//8,(17*(m//8))+((aey+8)//8))==18 or mget((30*m%240)+aex//8,(17*(m//8))+((aey+8)//8))==10 or mget((30*m%240)+aex//8,(17*(m//8))+((aey+8)//8))==11 or mget((30*m%240)+aex//8,(17*(m//8))+((aey+8)//8))==26 or mget((30*m%240)+aex//8,(17*(m//8))+((aey+8)//8))==27) then
- sfx(53,72,-1,3)
- s=s-1
- strig=1
- else
- if s==0 then
- sfx(55,31,-1,2)
- else
- sfx(59,60,-1,3)
- end
- end
- end
- if btnp(6) and m<=21 then
- m=m+1
- level(m)
- end
- if btnp(7) and m>=3 and m<=21 then
- m=m-1
- level(m)
- end
- end
- if t>=2*60 then
- if keyp(50) then
- if ptrig==0 then
- sfx(51,43,-1,0,15)
- ptrig=1
- pal(0.5)
- must=peek(0x13ffc)
- musf=peek(0x13ffd)
- musr=peek(0x13ffe)
- musl=peek(0x13fff)
- music()
- else
- sfx(51,43,-1,0,15)
- ptrig=0
- pal(1)
- music(must,musf,musr,musl)
- end
- end
- end
- --MOVEMENT PROPERTIES
- if strig==1 and anix==0 and aniy==0 then
- if aeo==0 then strig=(aex)-(animx*8+(anix//10)) end
- if aeo==1 then strig=(aey)-(animy*8+(aniy//10)) end
- end
- if strig~=1 then
- if strig<0 and ptrig==0 then
- if aeo==0 then animx=animx-0.5 end
- if aeo==1 then animy=animy-0.5 end
- strig=strig+4
- end
- if strig>0 and ptrig==0 then
- if aeo==0 then animx=animx+0.5 end
- if aeo==1 then animy=animy+0.5 end
- strig=strig-4
- end
- end
- if anix>0 then
- if btrig==1 then
- if m<=11 then spr(48,(animx*8)+8,(animy*8+(aniy//10))+16+(8-(math.abs(anix//10))),0) end
- if m>=12 then spr(49,(animx*8)+8,(animy*8+(aniy//10))+16+(8-(math.abs(anix//10))),0) end
- end
- c=0
- f=0
- if ptrig==0 then anix=anix-8 end
- spr(257+t%8//2,animx*8+(anix//10),animy*8+(aniy//10),0,1,f,0,1,2)
- end
- if anix<0 then
- if btrig==1 then
- if m<=11 then spr(48,(animx*8)-8,(animy*8+(aniy//10))+16+(8-(math.abs(anix//10))),0) end
- if m>=12 then spr(49,(animx*8)-8,(animy*8+(aniy//10))+16+(8-(math.abs(anix//10))),0) end
- end
- c=0
- f=1
- if ptrig==0 then anix=anix+8 end
- spr(257+t%8//2,animx*8+(anix//10),animy*8+(aniy//10),0,1,f,0,1,2)
- end
- if aniy>0 then
- c=5
- if ptrig==0 then aniy=aniy-8 end
- spr(261+t%6//3,animx*8+(anix//10),animy*8+(aniy//10),0,1,0,0,1,2)
- end
- if aniy<0 then
- c=5
- if ptrig==0 then aniy=aniy+8 end
- if not ((mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==1 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==2 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==17 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==18 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==10 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==11 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==26 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==27 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==5 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==37 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==48 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==49 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==16 or (mget((30*m%240)+(animx*8+(anix/10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8))==32) then
- spr(263+t%8//4,animx*8+(anix//10),animy*8+(aniy//10),0,1,0,0,1,2)
- else
- if ftrig==1 then c=0 end
- spr(261+t%14//7,animx*8+(anix//10),animy*8+(aniy//10),0,1,0,0,1,2)
- end
- end
- --PIXEL COLLISION
- if mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8)>=64 and mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8)<=71 and strig==0 then
- px=px-1
- sfx(54,72,-1,0)
- mset((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+((animy*8+(aniy//10))//8)+1,0)
- end
- --PHANTOM PIXEL COLLISION
- if mget((30*m%240)+aex//8,(17*(m//8))+((aey+8)//8))>=72 and mget((30*m%240)+aex//8,(17*(m//8))+((aey+8)//8))<=79 and strig==0 then
- aepx=aepx-1
- sfx(54,69,-1,0)
- mset((30*m%240)+aex//8,(17*(m//8))+((aey+8)//8),0)
- end
-
- --HERO DISPLAY
-
- --ALTER EGO DISPLAY
- if aeo==0 then
- --120=ZX spectrum Mirrored, 116=NES Mirrored
- aex=120-((animx*8+(anix//10))-120)
- aey=animy*8+(aniy//10)
- end
- if aeo==1 then
- aex=animx*8+(anix//10)
- aey=64-((animy*8+(aniy//10))-64)
- end
-
- if t>(2*60) then
- if strig==0 then
- spr(265+t%8//2,aex,aey,0,1,0,0,1,2)
- else
- spr(297+t%16//4,aex,aey,0,1,0,0,1,2)
- end
- else
- spr(265+((t%20//10)*6),aex,aey,0,1,0,0,1,2)
- end
-
- end
- if options.debug then
- print("DEBUG",0,0,15,true,1,true)
- --TIMER DEBUG
- print(t,0,6,15,true,1,true)
- --SWAP ACTION INPUT DEBUG
- if btn(4)==true or btn(5)==true then
- print("true",0,12,15,true,1,true)
- else
- print("false",0,12,15,true,1,true)
- end
- --MAP SCREEN DEBUG
- print(m,0,18,15,true,1,true)
- --SWAP TRIGGER DEBUG
- print(strig,22,18,15,true,1,true)
-
- --SCREEN HERO SPR POSITION DEBUG
- print((animx*8+(anix//10)),0,24,15,true,1,true)
- print((animy*8+(aniy//10))+8,0,30,15,true,1,true)
-
- --SCREEN ALTER EGO SPR POSITION DEBUG
- print(aex,22,24,15,true,1,true)
- print(aey+8,22,30,15,true,1,true)
- --MAP HERO SPR POSITION DEBUG
- print((30*m%240)+(animx*8+(anix//10))//8,0,42,15,true,1,true)
- print((17*(m//8))+((animy*8+(aniy//10))//8)+1,0,48,15,true,1,true)
-
- --MAP ALTER EGO SPR POSITION DEBUG
- print((30*m%240)+aex//8,22,42,15,true,1,true)
- print((17*(m//8))+((aey+8)//8),22,48,15,true,1,true)
-
- --MOVEMENT DEBUG
- print(anix//10,0,60,15,true,1,true)
- print(aniy//10,0,66,15,true,1,true)
-
- --PIXEL AND PHANTOM PIXEL DEBUG
- print(px,22,60,15,true,1,true)
- print(aepx,22,66,15,true,1,true)
- --MGET DEBUG
- print(mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10))//8),22,78,15,true,1,true)
- print(mget((30*m%240)+(animx*8+(anix//10)-8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8),0,84,15,true,1,true)
- print(mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8),22,84,15,true,1,true)
- print(mget((30*m%240)+(animx*8+(anix//10)+8)//8,(17*(m//8))+(animy*8+(aniy//10)+8)//8),44,84,15,true,1,true)
- print(mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10)+16)//8),22,90,15,true,1,true)
-
- --MUSIC SPEED DEBUG (0-7)
- --print(peek(0x13e96),0,102)
- --print(peek(0x13ec9),22,102)
- --print(peek(0x13efc),0,108)
- --print(peek(0x13f2f),22,108)
- --print(peek(0x13f62),0,114)
- --print(peek(0x13f95),22,114)
- --print(peek(0x13fc8),0,120)
- --print(peek(0x13ffb),22,120)
- --MUSIC POSITION DEBUG
- print("track:",44,102,15,true,1,true)
- print(peek(0x13ffc),88,102,15,true,1,true)
- print("frame:",44,108,15,true,1,true)
- print(peek(0x13ffd),88,108,15,true,1,true)
- print("row :",44,114,15,true,1,true)
- print(peek(0x13ffe),88,114,15,true,1,true)
- print("loop :",44,120,15,true,1,true)
- print(peek(0x13fff),88,120,15,true,1,true)
-
- --wait: Time event (2 sec)
- --if t<2*60 then return end
- --stuff to do
-
- --spr command: spr(id+t%nf//f,x,y,z,s,f,r,w,h)
- --id=sprite id
- --t=timer
- --f=frames to wait for switch sprites
- --n=number of sprites to switch
- --Compare between f and n variables for speed
- --x=x position
- --y=y position
- --z=colorkey id to set alpha
- --s=scale
- --f=flip(Hflip(1),Vflip(2),HVflip(3))
- --r=rotate(90 deg(1),180 deg(2),270 deg(3))
- --w=width of composite sprite
- --h=height of composite sprite
- end --if options.debug
- --end of function TIC()
- end
|