Skip to content

Instantly share code, notes, and snippets.

View lucatronica's full-sized avatar

Luca Harris lucatronica

View GitHub Profile
-- Color palette.
pal({131,3,139,11,138},1)
-- Set dither pattern.
-- `▒` is a global variable inserted by PICO-8 that has the value 23130.5.
-- The value corresponds to a fillp pattern that looks like the glyph itself.
-- We need to floor ▒ to remove the .5, which signifies the pattern should be transparent.
-- (`\` is PICO-8's integer divison operator. So `x\1` floors the left operand.)
fillp(▒\1)
@lucatronica
lucatronica / twitch_vod_local_timestamps.js
Last active February 14, 2021 12:52
Convert Twitch VOD timestamps to local time, and adds a display that shows the local time for given point in the VOD.
// [INSTRUCTIONS]
// Read through this and make sure it's safe to run!
// Set the "vodStart" date to the time the VOD started.
// Paste and run it in your browser console (ctrl+shift+i) on the twitch VOD.
(() => {
// [CHANGE THIS]
// Set this string to the start time of the VOD (try using an "I'm live!" tweet to get an accurate time for this).
let vodStart = new Date(1613241580000); // new Date(Date.parse("5:39:40 AM Feb 14 2021"));

Unity Script Attributes

General

using UnityEngine;

public class MyClass
{
	// [RuntimeInitializeOnLoadMethod]
pal({130,2,136,8,142,135},1)
function _draw()
cls(5)
srand(0x2152)
local f=t()
--sun
circfill(110,18,4,6)
function _draw()
cls(8)
srand(5)
-- Iterate every 8 square pixels of the screen.
-- The `.5` is to make sure the points are at the center of each pixel.
-- We'll draw one wall of the maze in each square.
for y=.5,129,8 do
for x=.5,129,8 do
-- Progress in the rotation cycle. One rotation is [0..1]
-- Set the background color.
pal(0,140,1)
function _update60()
cls()
--Two iterations
-- 0: Splashes
-- 1: Rain
for j=0,1 do
--This code uses the following RGB trick
--https://gist.github.com/lucatronica/6dc7fae058440ab208d99584fe314e5c
--Setting up the RGB colors.
--Unlike the above example, we're using all 16 colors now!
--That's because we're now using the 4th bit of the color index.
--We use this bit (color 8) for the background text color.
pal({
8,11,10,140,14,12,7,
129,8,11,10,140,14,12,7,
-- In RGB displays, each pixel contains 3 subpixels for red, green and blue.
-- The intensity of each subpixel can be changed independently.
-- Mixing different intensities of each allows for a large range of colors.
-- In this program, we'll use a similar approach.
-- Except our RGB subpixels can only be on or off, which limits us to 8 colors.
-- We can treat a PICO-8 color index like an RGB pixel by treating the first 3
-- bits as flags for each RGB subpixel.
-- gumtree.lua
-- coordinates: x,y = ground; z = vertical
-- camera
local gt_cam={
x=0,
y=0,
z=0,
-- spin angle
s=0,
-- gumtree.lua
-- pico-8 3d/voxel library
--
-- coordinates: x,y = ground; z = vertical
--
-- how it works:
-- to make sure shapes in the right order, we need to sort them from back to front.
-- to do this shapes are drawn only once the scene has been populated.
-- we represent shapes as tables, created using gumtree functions.
--