alter-ego-by-kyuchumimo.lua 24 KB

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