There's nothing on TV in the future. Practicing some techniques. I don't have anywhere else to go with this, so here it is. Coding feedback welcome.
Since you're asking for coding feedback, I'll give you some, in general and relating to the game itself.
First off, you're calling cls() with an argument. I'm not sure why you're doing that, that doesn't do anything (it works, but the argument gets ignored). If you want to fill a screen with a certain colour, do cls() followed by rectfill(0, 0, 127, 127, your_color). You don't have to do that last line if the colour is black, though.
Next, the semantics of the change_channel() function are contradictory to the name. The function adds or subtracts "ch" from the channel variable, but the name implies that it will set channel = ch. You could call the function something like add_to_channel(), perhaps.
Thirdly, what happened to channels 2 and 1? It's kind of odd that those are missing...
The show_channel() function is a mess. You're printing a bunch of black text that's invisible, and only a single line of that function, the last one, actually does anything the player can see.
At last, checking for whether either O or X is pressed can be simplified as follows:
if btnp() >= 16 then -- your code here end
That's about all, really.
Love the fuzz effect! Any plans to extend this? It's neat.
Not to be contrarian, but I have to disagree with most of the advice @tlm offered. Nothing personal!
Your function name is fine the way it is. And being explicit with "btnp(4) or btn(5)" is preferable to "btnp() >= 16" unless you're in dire need of tokens for some reason. Always be explicit like that when you can.
Also.. calling cls with a color parameter /does/ fill the screen with that color. Just try typing cls(8) into the pico-8 console and you'll see the screen turn red.
He is right about that palt(0,False) being unnecessary. With how your program is set up currently, the only required palt call is the one on line 44 (so you could move that to init() if you wanted). This is because CLS ignores the transparency settings for the fill color. But honestly it isn't hurting anything. So whatever ¯_(ツ)/¯
Good job. Hope you add some animations or something to some of the channels. It's a neat little toy as-is. :)
Thanks tlm, I appreciate this feedback as a coding n00b! The lack of channel 1/2 is just how I remember TV channels working as a kid. On second thought there was a channel 2, but no 1.
And thank you enargy. Good to clear stuff up.
I'll go over the code again tonight. Trying to develop good habits now so thanks again.
@enargy: Well I'll be! The cls() feature isn't documented at all, which is a shame, it does seem useful. Regarding which way to use btnp(), you might be right in that it reads cleaner (which if you're actually planning to share the source is somewhat important), but I feel like the version with a single call may be quite a bit faster performance-wise. I... doubt that's an actual issue for anyone, but still. Maybe being stuck with pico-8's editor tiny line length I'm starting to shorten names and code when it's not really necessary. As long as you yourself understand the code it's not an issue, so I just figured I'd share a little trick -- counts as advice, heh. Either way, it's not like you should take mine (or, for that matter, anyone's) advice unless you feel it's actually useful to you. I recommend borrowing things which make sense and seem like they'd improve your games and just ignoring whatever everyone else rants on about :)
@EatMoreCheese: I haven't seen a single TV where channels would start at a number different from 1. Maybe channel 1 was unconfigured on your set or something, but I don't think that's a common occurence.
but the apocalypse has already happened! it's called DVB-T. old (analog, and mostly crt) tvs have been doing exactly that for years. at least in europe, I think.
(btnp()>=16) is a bad idea since it's also true when you press ANY second controller button. (band(btnp(),48)!=0) would do what you want, but it's quite silly for just 2 buttons. though (btnp()!=0) could be useful for 'press any key' situations.
[Please log in to post a comment]