alter-ego-by-kyuchumimo.lua 25 KB

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