alter-ego-by-kyuchumimo.lua 25 KB

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