alter-ego-by-kyuchumimo.lua 24 KB

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