This is an open-source cartridge/engine with map collision, player movement, and map scrolling. (206 tokens in total)



That is really optimized, @Lolscope. I ran into this situation doing collision checks with blocks on a previous platformer I was working on.
I'm wondering if there is a way to do just one FGET() per direction instead of 2.
Gold star for distinctly compact coding !



This is pretty compact, but there's a lot of reused code with different values plugged in, so I made a version using some lookup tables. Just 125 tokens.=)
--position table p=split"60,60" --movement table m=split"-1,0,-1,7,-1,8,0,8,7,1,0,-1,7,-1,-1,0,8,7,8,1" function _update() cls(1) x,y=p[1],p[2] for i=0,3 do local n=i*5 if btn(i) and fget(mget((x+m[n+1])/8,(y+m[n+2])/8))!=1 and fget(mget((x+m[n+3])/8,(y+m[n+4])/8))!=1 then p[i\2+1]+=m[n+5] end end map() spr(1,x,y) camera(x\128*128,y\128*128) end |



The original by @Lolscope is 495-chars.
@JadeLombax. Yours is 369 chars, impressive to scan the box for that small size !


Here is mine at 330 chars, though it only scans the edges - still functional for a topview adventure game like Zelda.
I remember doing this years ago myself. The code is likely not all compact though:
https://www.lexaloffle.com/bbs/?tid=36388
In the case though for this particular code, Do I hear a lower number than 330 ? :)



Well, I was trying to minimize tokens instead of character count, but here's a smaller version that fits in a tweet (277 chars, 127 tokens).
c=128p=split"60,60"m=split"-1,0,-1,7,-1,8,0,8,7,1,0,-1,7,-1,-1,0,8,7,8,1" ::_::x,y=p[1],p[2]?'⁶1⁶c1' for i=0,3do n=i*5 if(btn(i)and fget(mget((x+m[n+1])/8,(y+m[n+2])/8))!=1and fget(mget((x+m[n+3])/8,(y+m[n+4])/8))!=1)p[i\2+1]+=m[n+5]end map()spr(1,x,y)camera(x\c*c,y\c*c)goto _ |
--Edit: Fixed camera bug.



Oh, I was in a hurry and didn't test the code before posting. It's fixed now.



Ah ! And there you go, @JadeLombax. So the score I need to beat is 278 characters. I think I can do it.





252-char, @JadeLombax. Yet I'm still only checking one map flag which kinna gives me the leading edge, literally. :)
I also set it so you can peek out the exit and arrive on the other side also peeking in.
. . .
There is another method to this madness mapping. How about the way they do it in Final Fantasy ? In minimal code.
[Please log in to post a comment]