Work in progress for Game Off 2019!
v0.1 - initial wip submission
v0.1.1 - bugfix: runtime error when scoop is in player path right after completing an order
Having been experimenting with compressing screens of pixels I was wondering if it were possible to write a compressor that returned the results of a dithered image. That is, where the output results would be difficult or impossible to compress effectively using standard methods of image compression.
And this is a 1st stage. Tomorrow if I have time I'll work on and post the 2nd stage. If it's successful it will also dither an image but in a third of the current compression space (less than 512-chars) yet still span the full screen.
For instance this particular image compresses from 16384-chars (raw image) to 1457-chars. Obviously it does not include all 16-colors and instead relies on a black and white table that is a size of 5. Five because I want to have both solid black and white in it.
Yet I think this is useful, especially if someone wants to include a large number of "clipart" images in their cart and for them to be dithered, perhaps for an adventure or mystery game that relies on many pictures.
I spent a while being very, very confused about screen palettes and draw palettes, but I've started to feel like I've got a hang of it? And I decided to make a visual expression of how these work as a PICO-8 cart.
In the default state, the screen palette contains the sixteen colors of the default palette - 0-15 - and the draw palette links the sixteen draw colors 0-15 directly to these default colors.
When the draw palette changes, different colors from the screen palette are loaded into the draw color slots. The sprite still refers to the same draw colors - in this case, 0-3 across the top, 4-7 in the second row, 8-11 in the second-to-bottom row, and 12-15 in the bottom row - but these draw colors have been redefined in terms of the screen palette.
...and the screen palette in turn can be redefined by changing the colors in its 16 slots.
I think how this is intended to be understood is:
- 4 components: video output hardware (5-bit input, RGB output), screen palette RAM (4-bit address, 8-bit output), screen data RAM (14-bit address, 4-bit output), draw palette lookup table RAM (4-bit address, 4-bit output)
- Every sixtieth of a second, one frame of graphics is sent to the monitor. As the hardware scans through the 128x128 pixels of the screen data, the 4-bit screen data output addresses the screen palette RAM, and the high-order bit plus lower 4 bits of the screen palette output goes to the video output hardware. (I can attest from having bugs in my screen palette code for a while that the other bits in the screen palette are ignored.)
- When commands are run to draw graphics on the screen, the 4-bit addresses to be drawn go through the draw palette lookup table to set the 4 bits actually stored in the corresponding addresses of the screen data RAM.
Or, in less technical terms: the data stored for the sprite (or whatever) chooses a row in the draw palette (center) which chooses a row in the screen palette (left) which chooses a color on the screen. Changing the draw palette doesn't change what the screen shows until PICO-8 draws something new to the screen data; changing the screen palette does.
What honestly made it click for me, though, was thinking in practical terms.
The draw palette, for example, is a tool for recoloring images as I draw them. For example, if I have this little gray box stored as a sprite in my sprite sheet:
then I can use the draw palette to declare that I'm drawing it as an orange sprite instead:
The screen palette, on the other hand, I think of as 16 meanings. Rather than thinking of the, say, 11th color in the screen palette as a color, when I am using the screen palette to change the colors of images, I think of it by its purpose: in this case, the color of the character's shirt.
Then, changing that color represents a change corresponding to that meaning: to put the value 136 in screen palette slot 11, then, is to say that the color of the character's shirt is not green, it is red.
These ideas can obviously be combined - perhaps screen palette 1 is the color of player 1's vehicle and screen palette 2 is the color of player 2's vehicle, and which color is drawn when a vehicle sprite is drawn is selected using the draw palette. Thus, both players can select the colors of their vehicles and both vehicles can be drawn using the same sprites.
This is very long and probably well-known in the community, but I figured I'd make the tutorial anyway because I'm proud of figuring this out.
Some people tried to tell me that PICO-8 runs as fast as a host machine does (which, as we all know, is not true).
So I created this little "benchmark" cart with a roto-zoomer effect running in 60FPS. Use up/down keys to change the filled area of a screen. On my computer (MacBook Pro 2017) it consumes 98.2361% of PICO-8 CPU time at 47 lines.
Press left or right to aim,and z to fire.
Match three colors to get points.
When the flashing line reaches the top, game over.
Newball function modified from "Combo Pool".
Slide, my Pico-8 version of the Rush Hour game. It contains 40 levels.
The object of the game is to get the red block out of the grid.
L/R arrow keys to select level
x to start level
arrow keys to choose/move block
x to select/deselect block
c to cancel level and go to menu
As Tweets seem to be of interest, I thought I would share some shortcuts I have found over my time programming in Pico-8 which may save you vital characters to getting that desired 560-characters.
Let's look at some of the commands first:
Can be abbreviated as ? if first character on line
Not well-known will clear your variables and run your program again from the beginning.
Leaving out c and d will draw line from last drawn position using default color.
RECT(a,b,c,d) and RECTFILL(a,b,c,d)
Leaving out c and d will draw hollow or filled rectangle starting from coordinates 0,0, default color.
By itself will choose color 6.
Instead of creating tricky timers, just force your code to run at this FPS, can be higher than 60 too, 120 is possible !
Test that with this code:
_set_fps(15) cls() for i=0,127 do for j=0,127 do pset(j,i) flip() end end
Can be abbreviated as T().
Use ::_:: and goto _ to GO TO a part of your code. Takes less space than REPEAT UNTIL false-condition.
if A==8 THEN A=0 END
Can be abbreviated:
To cut additional corners you can always cut spaces BEFORE any opening or AFTER ANY ending parenthesis ( ).
Likely there are other short-cuts of interest too. What are some you use to minimize your tweets with ?
This is Lucy Loves Pebbles, a game in 559 characters where you feed Lucy Miu with her favorite pellet-based food. #TweetTweetJam
Press X to flip the flippers and try to fling the pebbles into the cat's mouth. If she eats enough, she'll be happy - otherwise, well, nothing happens.
I'd never tried to minify game code before - only demos for #tweetcart. As it turned out, I made two choices that would make this one very difficult to minify: I spent a stupid number of characters drawing the cat head exactly as I wanted (instead of picking cheaper graphics for it) and I chose game mechanics that were really much more complex than I ought to have chosen.
The implementation was fairly straightforward: the left side of the screen (i.e., the cat's face and rail/flipper) are drawn with primitives, then memcpy/spr-flipped to the other side. I use the distance to center to determine what happens when the flippers are pressed, and the height to determine if it makes it in the cat's mouth.
For minifying, I wrote a small python script that would read a less-minified cartridge and output the one I've uploaded. Essentially, it strips indents, some whitespace, and comments, and allows me to use comments to decorate which lines' newline characters can be deleted.
Yes, this may be my worst cartridge, but it was a fun weekend!
Hey guys, I'm trying to add Player 2 controls but it looks like it's not working for me. I'm trying to do btnp(S) and btnp(f) etc for 2nd player controls and that's not working.
Is there anything specific I have to write/do to enable two players?
Made for a class involving learning on Pico-8. Totally understand there are a lot of these clones out here for multiple classes. Thanks for looking.
This was a school project. This is the completed state in which i am turning in. Still plan on working on this and adding more to it in the future.
The goal is to break all the bricks. The game has 3 levels, if you can see what the 3rd level is shaped like post a comment on what you think it is. This is a remake or similar copy of breakout or brick-breaker.
This is my submission for the #TweetTweetJam. Use the arrow keys to dodge things. I was able to fit saving and a sound in the 560 characters as well! Also play on itch.io.
I have a new version with some control improvements, so I hope, that this will be ok for you
This is my first TweetTweetCart (558 chars of code)! Made for TweetTweetJam 3!
<> to move
Z to jump
My best score is 560
Itch page: Rainbow Tunnel