alter-ego-by-kyuchumimo.lua 23 KB

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