Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Rambling

Woke up only a bit late today, kitty had no wet food so she was a bit upset, but not too upset, considering... 😆 (image of kitty here)

Pico-8

Hopped right back into pico-8, though my os'... system input? isn't working. The taskbar, desktop, and shortcut keys aren't responding, so I'll probably restart here in a bit 😆 (I can still save so I can still work 😆)

Getting movement and apple spawning right now, going to get the body stuff later.

NerdyTeachers & the pico-8 cheatsheet, have been my main references for this project so far, it's nice to have them open in a second monitor so you can easily reference them! I like to have the pico-8 window itself as big as I can get it without going fullscreen in the center of my monitor. I'm not using an external editor for this project, nor git, since those would just get in the way of actually making the game, which is what I want practice for right now.

I'm making the distinction between grid space and screen space, I've been converting between the two with:

x = (s_head.x * 7) + x_o
y = (s_head.y * 7) + y_o

with x_o and y_o being the x and y offsets, since my grid isn't centered (128x128 doesn't lend itself to grid lines 1 pixel wide, 2px wide would work but then I'd have less space 😆)

this was appearing in a lot of places in my code, and recognizing the pattern I made a little helper function that does it for me

function g_to_s(g_x,g_y)
	local s_x, s_y
	s_x = (g_x * 7) + x_o
	s_y = (g_y * 7) + y_o
	return s_x, s_y
end

now wherever I had the first snippet it's one line of code

local x,y = g_to_s(apple.x, apple.y)

I'm sure I could do more to compress it, probably by making a draw_sprite function that takes the x y and sprite values as arguments and just does it by itself, that way it's not repeated, but I only draw three sprites (the head is really four but I'm using dir as direction and sprite number), so it wouldn't save that much space, and I'm not hurting for token space or anything 😆

If I wanted to I would combine the arrays s_head and s_body and use the sprite I'm using for the body for the head too, and then just draw the eyes in accordance with the direction its facing, saving four sprites, and if I wanted to be super frugal with sprite space I could use it for both the apple and the snake, since the apple is just a square with the four corners taken out 😆

If I'd thought about it earlier I might've saved the first pass before the helper function, completed and polished it, then go back and show where and how you could compress it, using the helper function and a draw_sprite function and two pset()s for the eyes, but I didn't 😆

I'm writing a bunch of comments where usually I wouldn't both to help future me and to help whoever is looking at the code, I really like being able to look at Pico-8 cartridges in the editor and learning from them, but alas, comments take up character count (max 65535 or $2^{16}-1$),