Log In  

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.)

/ Pingo

Cart [#49919#] | Code | 2018-03-04 | No License | Embed

P#49920 2018-03-04 07:51 ( Edited 2018-03-07 21:17)

:: Felice

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.

P#49922 2018-03-04 09:47 ( Edited 2018-03-04 14:57)
:: pingo

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. :)

/ Pingo

P#49923 2018-03-04 10:41 ( Edited 2018-03-04 15:41)
:: elneil

You could use a function reference, like this:

b=btn
if(b(0))x-=2

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.

P#49924 2018-03-04 11:00 ( Edited 2018-03-04 19:28)
:: Felice

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. :)

P#49955 2018-03-05 09:10 ( Edited 2018-03-05 14:11)
:: Felice

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:

r(64)<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:

r()<0x.04

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. :)

P#49964 2018-03-05 11:11 ( Edited 2018-03-05 16:13)
:: pingo

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.

/ Pingo

P#50062 2018-03-07 16:17 ( Edited 2018-03-07 21:17)

[Please log in to post a comment]

About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2019-06-26 10:15 | 0.050s | 4194k | Q:29