alter-ego-by-kyuchumimo.lua 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860
  1. -- title: Alter Ego (WIP)
  2. -- author: ORIGINAL ZX SPECTRUM GAME BY DENIS GRACHEV
  3. -- NES CONVERSION BY SHIRU
  4. -- NES MUSIC BY RICHARD "KULOR" ARMIJO
  5. -- TIC-80 CONVERSION BY KYUCHUMIMO AND PIXELBATH
  6. -- desc: My first TIC-80 program
  7. --WARNING: Saved on TIC-80 0.80.xxxx beta. Music doesn't work on previous versions.
  8. --CHANGELOG:
  9. --201120 - pixelbath joined the project. Code optimization: 26473 to 21757 bytes. Changelog moved to tic80.com/play?cart=1420
  10. --INFO:
  11. --https://tic80.com/play?cart=1420
  12. --https://www.youtube.com/watch?v=O3uOHAvlsN8
  13. --http://www.retrosouls.net/?page_id=614
  14. -- script: lua
  15. --VARIABLES
  16. --climb
  17. c=0
  18. --sprite flip
  19. f=0
  20. --lives
  21. l=5
  22. --LEVEL (DEFAULT=0)
  23. m=0
  24. --pixels (KEEP AWAY FROM 0)
  25. px=0
  26. aepx=0
  27. --swap
  28. s=0
  29. --EVENT TIMER
  30. et=nil
  31. --GLOBAL TIMER
  32. t=0
  33. --bridge animation trigger
  34. btrig=0
  35. --FALL TRIGGER
  36. ftrig=0
  37. --PAUSE TRIGGER
  38. ptrig=0
  39. --SWAP TRIGGER
  40. strig=0
  41. --ALTER EGO mirroring (0=H,1=V)
  42. aeo=0
  43. --HERO animation ticks
  44. anix=0
  45. aniy=0
  46. --HERO X position
  47. animx=0
  48. --HERO Y position
  49. animy=0
  50. --ALTER EGO X position
  51. aex=0
  52. --ALTER EGO Y position
  53. aey=0
  54. --palette RGB value
  55. v=0
  56. cls()
  57. map()
  58. --PALETTE STUFF
  59. local basepalette = {
  60. 0x1a1c2c, 0x29366f, 0x3b5dc9, 0x493c2b, 0x5d275d, 0x38b764, 0xb13e53, 0x333c57, 0x41a6f6, 0xef7d57, 0x94b0c2, 0xa7f070, 0xe06f8b, 0x73eff7, 0xffcd75, 0xf4f4f4
  61. }
  62. function pal(v)
  63. for i = 1, #basepalette do
  64. local offset, color = i-1, basepalette[i]
  65. poke(0x3fc0+(offset*3), ((color//65536) * v))
  66. poke(0x3fc1+(offset*3), ((color//256)%256) * v)
  67. poke(0x3fc2+(offset*3), (color%256) * v)
  68. end
  69. end
  70. function fade_out(et)
  71. if t==(et+(2.1*60)) then
  72. 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
  73. return pal(1)
  74. end
  75. if t==(et+(2.2*60)) then return pal(0.75) end
  76. if t==(et+(2.3*60)) then return pal(0.5) end
  77. if t==(et+(2.4*60)) then return pal(0.25) end
  78. if t==(et+(2.5*60)) then return pal(0) end
  79. end
  80. function fade_in(et)
  81. if t==(et+(0*60)+1) then return pal(0) end
  82. if t==(et+(0.1*60)) then return pal(0.25) end
  83. if t==(et+(0.2*60)) then return pal(0.5) end
  84. if t==(et+(0.3*60)) then return pal(0.75) end
  85. if t==(et+(0.4*60)) then return pal(1) end
  86. end
  87. -- PARTICLE/VFX STUFF
  88. waterlevel = 120 -- y coordinate of the water
  89. particletype='stars' -- snow|rain|stars
  90. particles = {}
  91. local starcolors = { 1, 2, 13, 15}
  92. function particleinit()
  93. if particletype == 'stars' then
  94. for i = 0,15 do
  95. table.insert(particles, {
  96. x = math.random() * 240,
  97. y = math.random() * waterlevel,
  98. twinkle = math.random() > 0.49, -- randomly pick true/false
  99. color = starcolors[math.random(#starcolors)],
  100. t = 0,
  101. })
  102. end
  103. end
  104. end
  105. function particleupdate()
  106. if particletype == 'stars' then
  107. for i = 1,#particles do
  108. local p = particles[i]
  109. if not p.twinkle then goto continue end
  110. ::continue::
  111. if t % 15 == 0 and math.random() > 0.1 then
  112. p.color = starcolors[math.random(#starcolors)]
  113. end
  114. end
  115. end
  116. end
  117. function particledraw()
  118. for i = 1,#particles do
  119. local p = particles[i]
  120. pix(p.x, p.y, p.color)
  121. end
  122. end
  123. particleinit()
  124. --(shx: Xpos, shy: Ypos, shf: flip, sht: timer) CHECK THIS
  125. function skullh(shx,shy,shf,sht)
  126. --local shx
  127. --local shy
  128. --local sht
  129. --local shf
  130. 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
  131. if shf==0 then shf=1 else shf=0 end
  132. --sht=0
  133. spr(288+t%16//4,(shx*8)+(sht//8),(shy*8),0,1,shf,0,1,2)
  134. else
  135. --sht=sht+1
  136. spr(288+t%16//4,(shx*8)-(sht//8),(shy*8),0,1,shf,0,1,2)
  137. end
  138. if (animx*8+(anix//10))==shx*8 and ((animy*8+(aniy//10))+8)==(shy*8)+8 then
  139. ftrig=0
  140. l=l-1
  141. sfx(56,45,-2,0)
  142. t=0
  143. level(m)
  144. end
  145. --SCREEN SKULL SPR POSITION DEBUG
  146. --print(shx*8,22,24)
  147. --print((shy*8)+8,22,30)
  148. end
  149. --LEVEL PROPERTIES (ANIMX/Y LIMITS(1-28,1-14))
  150. function level(m)
  151. sync(0,0,false)
  152. c=0
  153. f=0
  154. px=nil
  155. aepx=nil
  156. anix=0
  157. aniy=0
  158. et=-255
  159. strig=0
  160. ftrig=0
  161. --HELLO WORLD
  162. if m==2 then
  163. t=0
  164. s=2
  165. px=3
  166. aepx=0
  167. aeo=0
  168. animx=21
  169. animy=3
  170. end
  171. --PROMENADE
  172. if m==3 then
  173. s=2
  174. px=8
  175. aepx=0
  176. aeo=0
  177. animx=5
  178. animy=3
  179. end
  180. --BROKEN BRIDGE
  181. if m==4 then
  182. s=0
  183. px=8
  184. aepx=0
  185. aeo=0
  186. animx=11
  187. animy=8
  188. end
  189. --PHANTOM PIXELS
  190. if m==5 then
  191. s=3
  192. px=2
  193. aepx=4
  194. aeo=0
  195. animx=14
  196. animy=3
  197. end
  198. --ANOTHER PHANTOM
  199. if m==6 then
  200. s=4
  201. px=13
  202. aepx=0
  203. aeo=1
  204. animx=3
  205. animy=10
  206. end
  207. --SKULLS LAIR
  208. if m==7 then
  209. s=2
  210. px=14
  211. aepx=0
  212. aeo=0
  213. animx=17
  214. animy=13
  215. end
  216. --ABRACADABRA
  217. if m==8 then
  218. s=2
  219. px=6
  220. aepx=6
  221. aeo=0
  222. animx=9
  223. animy=10
  224. end
  225. --VERTICAL ILLUTIONS
  226. if m==9 then
  227. s=8
  228. px=10
  229. aepx=0
  230. aeo=1
  231. animx=4
  232. animy=9
  233. end
  234. --MIRRORS
  235. if m==10 then
  236. s=2
  237. px=4
  238. aepx=3
  239. aeo=0
  240. animx=26
  241. animy=11
  242. end
  243. --16 PIXELS
  244. if m==11 then
  245. s=4
  246. px=16
  247. aepx=0
  248. aeo=0
  249. animx=5
  250. animy=9
  251. end
  252. --PERFECT REFLECT
  253. if m==12 then
  254. t=0
  255. s=1
  256. px=16
  257. aepx=0
  258. aeo=0
  259. animx=15
  260. animy=10
  261. end
  262. --ICELANDS
  263. if m==13 then
  264. s=3
  265. px=5
  266. aepx=3
  267. aeo=0
  268. animx=15
  269. animy=9
  270. end
  271. --MIDNIGHT
  272. if m==14 then
  273. s=2
  274. px=5
  275. aepx=0
  276. aeo=0
  277. animx=23
  278. animy=12
  279. end
  280. --ALONE SKULL
  281. if m==15 then
  282. s=3
  283. px=3
  284. aepx=2
  285. aeo=0
  286. animx=15
  287. animy=2
  288. end
  289. --MADE IN HEAVEN
  290. if m==16 then
  291. s=5
  292. px=9
  293. aepx=6
  294. aeo=1
  295. animx=4
  296. animy=4
  297. end
  298. --UNDERWATER
  299. if m==17 then
  300. s=2
  301. px=3
  302. aepx=5
  303. aeo=0
  304. animx=2
  305. animy=9
  306. end
  307. --ZUPAPIXELS
  308. if m==18 then
  309. s=9
  310. px=8
  311. aepx=1
  312. aeo=0
  313. animx=3
  314. animy=2
  315. end
  316. --SKULLOPEDIA
  317. if m==19 then
  318. s=4
  319. px=12
  320. aepx=0
  321. aeo=0
  322. animx=7
  323. animy=12
  324. end
  325. --AFTER THE WAR
  326. if m==20 then
  327. s=3
  328. px=8
  329. aepx=0
  330. aeo=1
  331. animx=3
  332. animy=2
  333. end
  334. --VIRUS KVARTIRUS
  335. if m==21 then
  336. s=6
  337. px=11
  338. aepx=0
  339. aeo=0
  340. animx=24
  341. animy=13
  342. end
  343. --END
  344. if m==22 then
  345. t=0
  346. l=143
  347. s=143
  348. px=-255
  349. aepx=-255
  350. aeo=0
  351. animx=-1
  352. animy=-2
  353. mset((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+((animy*8+(aniy//10))//8),1)
  354. mset(((30*m%240)+(animx*8+(anix//10))//8)-1,(17*(m//8))+((animy*8+(aniy//10))//8)+1,1)
  355. mset((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+((animy*8+(aniy//10))//8)+2,1)
  356. mset(((30*m%240)+(animx*8+(anix//10))//8)+1,(17*(m//8))+((animy*8+(aniy//10))//8)+1,1)
  357. end
  358. end
  359. level(m)
  360. function TIC()
  361. --MUSIC (For loop use t%(spd*rows*#patterns used)==0)
  362. --TITLE SCREEN
  363. if m==1 and t==0 then music(0,-1,-1,false) end
  364. --LEVELS 1-10
  365. if m>=2 and m<=11 and t==0 then music(1,-1,-1,false) end
  366. --LEVELS 11-21
  367. if m>=12 and m<=21 and t==0 then music(2,-1,-1,false) end
  368. --LEVELS 21-???
  369. if m>=22 and t==0 then music(3) end
  370. --TIMER
  371. if ptrig==0 then t=t+1 end
  372. --CREDITS
  373. if m==0 then
  374. map(0,0,30,17)
  375. print(t,0,0,15,true,1,true)
  376. print(et,0,6,15,true,1,true)
  377. fade_in(0)
  378. if t==(3*60) or keyp(50) then et=t end
  379. if t>(et+(3*60)) and et>=0 then
  380. m=m+1
  381. t=0
  382. et=-255
  383. else
  384. fade_out(et)
  385. return
  386. end
  387. end
  388. --TITLE SCREEN
  389. if m==1 then
  390. l=5
  391. --REMAP
  392. cls()
  393. map(30*m%270,17*((m-1)//8),30,17,0,0,0,1,
  394. function(tile)
  395. if tile>=80 and tile<=111 and et==-255 then
  396. return tile*(t%38//19)
  397. end
  398. if tile>=80 and tile<=111 and et~=-255 then
  399. return tile*(t%10//5)
  400. end
  401. return tile
  402. end)
  403. fade_in(0)
  404. particleupdate()
  405. particledraw()
  406. if t<0.4*60 then return end
  407. print("DEBUG: Press X/A and Y/S to switch levels",8,131)
  408. print(et,0,0,15,true,1,true)
  409. if keyp(50) and et<=0 then
  410. music()
  411. sfx(51,43,-1,0,15)
  412. et=t
  413. end
  414. if t>(et+(3*60)) and et>=0 then
  415. m=m+1
  416. level(m)
  417. else
  418. fade_out(et)
  419. return
  420. end
  421. end
  422. --LEVEL DISPLAY
  423. if m>1 then
  424. fade_in(0)
  425. --REMAP
  426. cls()
  427. map(30*m%240,17*(m//8),30,17,0,0,0,1)
  428. particleupdate()
  429. particledraw()
  430. --SKULLH LIMITS(1-28,1-14)
  431. --skullh(12,10,0,0)
  432. --if btn(5) then skullh(25,3,0,0) end
  433. --skullh(20,6,0,0)
  434. --LEVEL CLEAR
  435. if px==0 and aepx==0 and anix==0 and aniy==0 then
  436. if et<0 then
  437. sfx(52,36,90,0)
  438. for i=0,29 do
  439. mset((30*m%240)+i,(17*(m//8)),0)
  440. end
  441. mset((30*m%240)+10,(17*(m//8)),91)
  442. mset((30*m%240)+11,(17*(m//8)),84)
  443. mset((30*m%240)+12,(17*(m//8)),101)
  444. mset((30*m%240)+13,(17*(m//8)),84)
  445. mset((30*m%240)+14,(17*(m//8)),91)
  446. mset((30*m%240)+16,(17*(m//8)),82)
  447. mset((30*m%240)+17,(17*(m//8)),91)
  448. mset((30*m%240)+18,(17*(m//8)),84)
  449. mset((30*m%240)+19,(17*(m//8)),80)
  450. mset((30*m%240)+20,(17*(m//8)),97)
  451. et=t
  452. end
  453. if et>0 then
  454. spr(257+(f*3),animx*8+(anix//10),animy*8+(aniy//10),0,1,f,0,1,2)
  455. spr(265,aex,aey,0,1,0,0,1,2)
  456. fade_out(et)
  457. end
  458. if t<et+(3*60) then
  459. return end
  460. m=m+1
  461. t=1
  462. level(m)
  463. end
  464. --STATUS DISPLAY
  465. mset((30*m%240)+3,(17*(m//8)),112+l)
  466. mset((30*m%240)+7,(17*(m//8)),112+s)
  467. end
  468. --GAME OVER
  469. if l==0 then
  470. map(210,119,30,17)
  471. sfx(-1,-1,-1,0)
  472. sfx(-1,-1,-1,1)
  473. sfx(-1,-1,-1,2)
  474. sfx(-1,-1,-1,3)
  475. if t==1 then
  476. music(6,-1,-1,false)
  477. end
  478. fade_in(0)
  479. if t<8*60 then
  480. return
  481. end
  482. m=1
  483. level()
  484. t=0
  485. end
  486. --DEATH
  487. 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
  488. if et<0 then
  489. sfx(56,45,-2,0)
  490. sfx(60,45,-2,1)
  491. et=t
  492. end
  493. if et>0 then
  494. spr(331+t%8//4,animx*8+(anix//10),animy*8+(aniy//10),0,1,0,0,1,2)
  495. spr(329+t%8//4,aex,aey,0,1,0,0,1,2)
  496. fade_out(et)
  497. end
  498. if t<et+(3*60) then
  499. return end
  500. ftrig=0
  501. l=l-1
  502. t=0
  503. level(m)
  504. end
  505. --FALL
  506. 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
  507. if ftrig==0 and l>0 then sfx(57,82,-1,0) end
  508. ftrig=1
  509. animy=animy+1
  510. aniy=-80
  511. spr(263+t%8//4,animx*8+(anix//10),animy*8+(aniy//10),0,1,0,0,1,2)
  512. end
  513. --NOTHING
  514. if anix==0 and aniy==0 and t>(2*60) then
  515. if ftrig==1 and strig==0 then sfx(58,24,-1,0) end
  516. if strig==0 then
  517. spr(256+c,animx*8+(anix//10),animy*8+(aniy//10),0,1,f,0,1,2)
  518. else
  519. spr(301+t%8//4,animx*8+(anix//10),animy*8+(aniy//10),0,1,f,0,1,2)
  520. end
  521. ftrig=0
  522. btrig=0
  523. end
  524. if t<(2*60) then
  525. spr((256+c)+((t%20//10)*15),animx*8+(anix//10),animy*8+(aniy//10),0,1,f,0,1,2)
  526. end
  527. if m>1 then
  528. --CONTROLS, COLLISION and SFX
  529. --UP(0),DOWN(1),LEFT(2),RIGHT(3)
  530. if strig==0 and t>(2*60) and ptrig==0 then
  531. 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
  532. ftrig=0
  533. sfx(63,84,-1,3)
  534. animy=animy-1
  535. aniy=80
  536. end
  537. 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
  538. ftrig=0
  539. sfx(63,84,-1,3)
  540. animy=animy+1
  541. aniy=-80
  542. end
  543. 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
  544. ftrig=0
  545. --BRIDGE
  546. 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
  547. sfx(61,0,-1,3)
  548. mset((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+((animy*8+(aniy//10))//8)+2,0)
  549. btrig=1
  550. else
  551. sfx(62,0,-1,3)
  552. end
  553. animx=animx-1
  554. anix=80
  555. end
  556. 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
  557. ftrig=0
  558. --BRIDGE
  559. 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
  560. sfx(61,0,-1,3)
  561. mset((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+((animy*8+(aniy//10))//8)+2,0)
  562. btrig=1
  563. else
  564. sfx(62,0,-1,3)
  565. end
  566. animx=animx+1
  567. anix=-80
  568. end
  569. --A/Z(4),B/X(5),X/A(6),Y/S(7)
  570. if (btnp(4) or btnp(5)) and m>=2 then
  571. 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
  572. sfx(53,72,-1,3)
  573. s=s-1
  574. strig=1
  575. else
  576. if s==0 then
  577. sfx(55,31,-1,2)
  578. else
  579. sfx(59,60,-1,3)
  580. end
  581. end
  582. end
  583. if btnp(6) and m<=21 then
  584. m=m+1
  585. level(m)
  586. end
  587. if btnp(7) and m>=3 and m<=21 then
  588. m=m-1
  589. level(m)
  590. end
  591. end
  592. if t>=2*60 then
  593. if keyp(50) then
  594. if ptrig==0 then
  595. sfx(51,43,-1,0,15)
  596. ptrig=1
  597. pal(0.5)
  598. must=peek(0x13ffc)
  599. musf=peek(0x13ffd)
  600. musr=peek(0x13ffe)
  601. musl=peek(0x13fff)
  602. music()
  603. else
  604. sfx(51,43,-1,0,15)
  605. ptrig=0
  606. pal(1)
  607. music(must,musf,musr,musl)
  608. end
  609. end
  610. end
  611. --MOVEMENT PROPERTIES
  612. if strig==1 and anix==0 and aniy==0 then
  613. if aeo==0 then strig=(aex)-(animx*8+(anix//10)) end
  614. if aeo==1 then strig=(aey)-(animy*8+(aniy//10)) end
  615. end
  616. if strig~=1 then
  617. if strig<0 and ptrig==0 then
  618. if aeo==0 then animx=animx-0.5 end
  619. if aeo==1 then animy=animy-0.5 end
  620. strig=strig+4
  621. end
  622. if strig>0 and ptrig==0 then
  623. if aeo==0 then animx=animx+0.5 end
  624. if aeo==1 then animy=animy+0.5 end
  625. strig=strig-4
  626. end
  627. end
  628. if anix>0 then
  629. if btrig==1 then
  630. if m<=11 then spr(48,(animx*8)+8,(animy*8+(aniy//10))+16+(8-(math.abs(anix//10))),0) end
  631. if m>=12 then spr(49,(animx*8)+8,(animy*8+(aniy//10))+16+(8-(math.abs(anix//10))),0) end
  632. end
  633. c=0
  634. f=0
  635. if ptrig==0 then anix=anix-8 end
  636. spr(257+t%8//2,animx*8+(anix//10),animy*8+(aniy//10),0,1,f,0,1,2)
  637. end
  638. if anix<0 then
  639. if btrig==1 then
  640. if m<=11 then spr(48,(animx*8)-8,(animy*8+(aniy//10))+16+(8-(math.abs(anix//10))),0) end
  641. if m>=12 then spr(49,(animx*8)-8,(animy*8+(aniy//10))+16+(8-(math.abs(anix//10))),0) end
  642. end
  643. c=0
  644. f=1
  645. if ptrig==0 then anix=anix+8 end
  646. spr(257+t%8//2,animx*8+(anix//10),animy*8+(aniy//10),0,1,f,0,1,2)
  647. end
  648. if aniy>0 then
  649. c=5
  650. if ptrig==0 then aniy=aniy-8 end
  651. spr(261+t%6//3,animx*8+(anix//10),animy*8+(aniy//10),0,1,0,0,1,2)
  652. end
  653. if aniy<0 then
  654. c=5
  655. if ptrig==0 then aniy=aniy+8 end
  656. 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
  657. spr(263+t%8//4,animx*8+(anix//10),animy*8+(aniy//10),0,1,0,0,1,2)
  658. else
  659. if ftrig==1 then c=0 end
  660. spr(261+t%14//7,animx*8+(anix//10),animy*8+(aniy//10),0,1,0,0,1,2)
  661. end
  662. end
  663. --PIXEL COLLISION
  664. 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
  665. px=px-1
  666. sfx(54,72,-1,0)
  667. mset((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+((animy*8+(aniy//10))//8)+1,0)
  668. end
  669. --PHANTOM PIXEL COLLISION
  670. 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
  671. aepx=aepx-1
  672. sfx(54,69,-1,0)
  673. mset((30*m%240)+aex//8,(17*(m//8))+((aey+8)//8),0)
  674. end
  675. --HERO DISPLAY
  676. --ALTER EGO DISPLAY
  677. if aeo==0 then
  678. --120=ZX spectrum Mirrored, 116=NES Mirrored
  679. aex=120-((animx*8+(anix//10))-120)
  680. aey=animy*8+(aniy//10)
  681. end
  682. if aeo==1 then
  683. aex=animx*8+(anix//10)
  684. aey=64-((animy*8+(aniy//10))-64)
  685. end
  686. if t>(2*60) then
  687. if strig==0 then
  688. spr(265+t%8//2,aex,aey,0,1,0,0,1,2)
  689. else
  690. spr(297+t%16//4,aex,aey,0,1,0,0,1,2)
  691. end
  692. else
  693. spr(265+((t%20//10)*6),aex,aey,0,1,0,0,1,2)
  694. end
  695. end
  696. --DEBUG DISPLAY
  697. print("DEBUG",0,0,15,true,1,true)
  698. --TIMER DEBUG
  699. print(t,0,6,15,true,1,true)
  700. --SWAP ACTION INPUT DEBUG
  701. if btn(4)==true or btn(5)==true then
  702. print("true",0,12,15,true,1,true)
  703. else
  704. print("false",0,12,15,true,1,true)
  705. end
  706. --MAP SCREEN DEBUG
  707. print(m,0,18,15,true,1,true)
  708. --SWAP TRIGGER DEBUG
  709. print(strig,22,18,15,true,1,true)
  710. --SCREEN HERO SPR POSITION DEBUG
  711. print((animx*8+(anix//10)),0,24,15,true,1,true)
  712. print((animy*8+(aniy//10))+8,0,30,15,true,1,true)
  713. --SCREEN ALTER EGO SPR POSITION DEBUG
  714. print(aex,22,24,15,true,1,true)
  715. print(aey+8,22,30,15,true,1,true)
  716. --MAP HERO SPR POSITION DEBUG
  717. print((30*m%240)+(animx*8+(anix//10))//8,0,42,15,true,1,true)
  718. print((17*(m//8))+((animy*8+(aniy//10))//8)+1,0,48,15,true,1,true)
  719. --MAP ALTER EGO SPR POSITION DEBUG
  720. print((30*m%240)+aex//8,22,42,15,true,1,true)
  721. print((17*(m//8))+((aey+8)//8),22,48,15,true,1,true)
  722. --MOVEMENT DEBUG
  723. print(anix//10,0,60,15,true,1,true)
  724. print(aniy//10,0,66,15,true,1,true)
  725. --PIXEL AND PHANTOM PIXEL DEBUG
  726. print(px,22,60,15,true,1,true)
  727. print(aepx,22,66,15,true,1,true)
  728. --MGET DEBUG
  729. print(mget((30*m%240)+(animx*8+(anix//10))//8,(17*(m//8))+(animy*8+(aniy//10))//8),22,78,15,true,1,true)
  730. 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)
  731. 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)
  732. 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)
  733. 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)
  734. --MUSIC SPEED DEBUG (0-7)
  735. --print(peek(0x13e96),0,102)
  736. --print(peek(0x13ec9),22,102)
  737. --print(peek(0x13efc),0,108)
  738. --print(peek(0x13f2f),22,108)
  739. --print(peek(0x13f62),0,114)
  740. --print(peek(0x13f95),22,114)
  741. --print(peek(0x13fc8),0,120)
  742. --print(peek(0x13ffb),22,120)
  743. --MUSIC POSITION DEBUG
  744. print("track:",44,102,15,true,1,true)
  745. print(peek(0x13ffc),88,102,15,true,1,true)
  746. print("frame:",44,108,15,true,1,true)
  747. print(peek(0x13ffd),88,108,15,true,1,true)
  748. print("row :",44,114,15,true,1,true)
  749. print(peek(0x13ffe),88,114,15,true,1,true)
  750. print("loop :",44,120,15,true,1,true)
  751. print(peek(0x13fff),88,120,15,true,1,true)
  752. --wait: Time event (2 sec)
  753. --if t<2*60 then return end
  754. --stuff to do
  755. --spr command: spr(id+t%nf//f,x,y,z,s,f,r,w,h)
  756. --id=sprite id
  757. --t=timer
  758. --f=frames to wait for switch sprites
  759. --n=number of sprites to switch
  760. --Compare between f and n variables for speed
  761. --x=x position
  762. --y=y position
  763. --z=colorkey id to set alpha
  764. --s=scale
  765. --f=flip(Hflip(1),Vflip(2),HVflip(3))
  766. --r=rotate(90 deg(1),180 deg(2),270 deg(3))
  767. --w=width of composite sprite
  768. --h=height of composite sprite
  769. --end of function TIC()
  770. end