Inspired by the TweetJam-thread, I tried to make a small game myself - but I ended up at 594 chars (though not optimized at all).
Anyone know how to make this smaller?
(It's an "Air Combat" Mini Game... try to shoot down the attacking planes - before they get you! Controls: Arrows and X to shoot. C to restart.)
You have a lot of whitespace that can be deleted, a few variables that are more than one char, you're not using the one-line if format that's peculiar to pico-8, were checking a wrap from 70->0 when you could use modulo, and you could be using the actual glyphs rather than escape codes.
I took a quick run at it. I rearranged a few minor things and applied the ideas above, but did little else. Comes to 450 chars by my count.
x,y,r,f,t,p,l=64,64,rnd,flr,0,0,3::z::cls(12)t+=1t%=70 ?p,90,120,0 if(t==10)u,v=f(r(128)),f(r(128)) ?"+",x,y,1 ?"-<*>-",u,v,10 for q=1,l do ?"♥",20+q*6,120,8 end if(btn(0))x-=2 if(btn(1))x+=2 if(btn(2))y-=2 if(btn(3))y+=2 if(btnp(5)and x>u and x<u+16 and y>v-4 and y<v+4)p+=10t=9 if f(r(64))<1then ?"* *",u,v,8 l-=1 end if l==0then cls(8) ?"points:"..p,46,60,0 ?"🅾️ to start",42,70,0 goto en end flip()goto z::en:: if(btnp(4)) l,p=3,0goto z goto en
I'm sure there's more you could do though.
Not sure why you were doing f(r(64))+1==1 btw... how is that different from f(r(64))==0? I changed that. Edit: actually, it can be f(r(64))<1 to save a char, since it's whole numbers and you know rnd(64)>=0.
Felice: Thanks so much!
The white-spaces and variable names I knew about - the rest I didn't. Learned a lot from this, so thank you!
Is there ANY way to reduce amount of chars when checking the BTN-press?
Also - I WOULD like to add a random heart instead of a plane sometimes, so one can actually gain an extra life as well... Not difficult, just difficult to keep chars down. :)
You could use a function reference, like this:
I reckon I could get it shorter than that but need to think...
You might also shave off a few chars by saying things like "score" instead of "points", also "O: begin" rather than "O to start" or whatever.
In fact, with tweetcarts, I'd say you're allowed to expect a lot from the player. Someone playing a tweetcart knows not to expect a robust, goof-proof UI/UX encounter. Simply printing the button they're supposed to press to continue should be enough to prompt them to do it. Or don't print it at all. They'll figure it out. :)
I mean, if it were an official tweetcart competition, they wouldn't be able to play at all if you didn't discard everything but the essentials, so it's not unreasonable to cut corners. The fewer you cut, the more respect you get, but you won't get any respect at all if you can't cut enough corners to enter the competition. :)
Just noticed something. When I said this:
|Not sure why you were doing f(r(64))+1==1 btw... how is that different from f(r(64))==0? I changed that. Edit: actually, it can be f(r(64))<1 to save a char, since it's whole numbers and you know rnd(64)>=0.|
I also missed the fact that you're just doing a 1-in-64-chance test. You don't need to floor it either, you just need to see if it's less than 1/64th of the range, or <1:
As an aside, to save tokens instead of chars, which isn't your goal here but it's still worth noting, you could do this:
Since rnd() returns a value in the range [0..1) and 0x.04 is 1/64. Your original expression is 9 tokens, this is just 4. :)
Thanks elneil and Felice! I really appreciate your input.
Just a note: in this case I kind of gave up the idea of making this "Twitter-friendly" and just tried to make it as small as possible - hence the Game Over texts and whitespaces.
[Please log in to post a comment]