com.panic.b360
com.tpmcosoft.battleship
com.a-m.beats-bleeps-boogie
com.radstronomical.CasualBirder
com.uvula.crankin
com.crookedpark.demonquest85
com.samanthazero.echoicmemory
com.davemakes.execgolf
com.serenityforge.elevator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const dist = (x1: number, y1: number, x2: number, y2: number) => Math.sqrt(Math.pow((x1 - x2), 2) + Math.pow((y1 - y2), 2)); | |
export class LineSegment { | |
x0: number = 0; | |
y0: number = 0; | |
x1: number = 0; | |
y1: number = 0; | |
constructor (x0: number, y0: number, x1: number, y1: number) { | |
this.x0 = x0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local CRC32_LUT = nil | |
local function crc32_init() | |
if not CRC32_LUT then | |
CRC32_LUT = table.create(255, 0) | |
local rem | |
for i = 0, 255 do | |
rem = i | |
for j = 1, 8 do | |
if (rem & 1 == 1) then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Prism.languages.lua = { | |
'comment': /^#!.+|--(?:\[(=*)\[[\s\S]*?\]\1\]|.*)/m, | |
// \z may be used to skip the following space | |
'string': { | |
pattern: /(["'])(?:(?!\1)[^\\\r\n]|\\z(?:\r\n|\s)|\\(?:\r\n|[^z]))*\1|\[(=*)\[[\s\S]*?\]\2\]/, | |
greedy: true | |
}, | |
'number': /\b0x[a-f\d]+(?:\.[a-f\d]*)?(?:p[+-]?\d+)?\b|\b\d+(?:\.\B|(?:\.\d*)?(?:e[+-]?\d+)?\b)|\B\.\d+(?:e[+-]?\d+)?\b/i, | |
'keyword': /\b(?:and|break|do|else|elseif|end|false|for|function|goto|if|in|local|nil|not|or|repeat|return|then|true|until|while)\b/, | |
'function': /(?!\d)\w+(?=\s*(?:[({]))/, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { unzlibSync } from 'fflate'; | |
function assert(condition: boolean, errMsg: string = 'Assert failed'): asserts condition { | |
if (!condition) { | |
console.trace(errMsg); | |
throw new Error(errMsg); | |
} | |
} | |
function readChars(data: DataView, ptr: number, size?: number) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// run in node.js, version 16.0 or later | |
// assumes sound effects will be in a folder called 'pda', located next to the script (replace all instances of './pda' to change this) | |
const fs = require('fs'); | |
function assert(condition, errMsg = 'Assert failed') { | |
if (!condition) { | |
console.trace(errMsg); | |
throw new Error(errMsg); | |
} |
- For repeated expensive drawing options, such as drawing a rotated sprite or a large amount of text, it's a good idea to cache the result to an image once and draw that repeatedly instead.
- Audio formats in order of decode speed, fastest to slowest: 16-bit pcm wav, 8-bit pcm wav, adpcm, mp3.
- The Playdate's audio sample rate is 44100, but if you're experiencing lag when playing audio at that rate, you can try halving the rate to 22050.
- The Playdate has a weak CPU but a comparatively generous amount of memory. Favour memory-based optimisation techniques, such as lookup tables.
- Where possible, move branch statements outside of loops, even if it means duplicating the code for the loop. (probably applies to Lua too?)
- If you need to parse a binary file, use playdate->file->seek to jump to the parts you need and playdate->file->read to only read the data you want. Try to avoid memcpy-ing the whole file to memory in one go.
- If you're blitting to the frame buffer and need to ap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- bezier curve drawing functions for playdate lua | |
-- these are based on de Casteljau's algorithm | |
-- this site has a nice interactive demo to compare both types of curve: https://pomax.github.io/bezierinfo/#flattening | |
-- draws a curve starting at x1,y1, ending at x3,y3, with x2,y2 being a control point that "pulls" the curve towards it | |
-- steps is the number of line segments to use, lower is better for performance, higher makes your curve look smoother | |
-- the playdate is kinda slow, so it's recommended to find a relatively low step number that looks passable enough! | |
function drawQuadraticBezier(x1, y1, x2, y2, x3, y3, steps) | |
steps = steps or 8 | |
local d = 1 / steps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// adpcm.h | |
#define CLAMP(n, l, h) \ | |
if (n < l) n = l; \ | |
if (n > h) n = h; | |
#define min(a,b) (((a) < (b)) ? (a) : (b)) | |
static const int8_t indexTable[8] = | |
{ -1, -1, -1, -1, 2, 4, 6, 8 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int width = 0; | |
int height = 0; | |
int stride = 0; | |
int hasMask = 0; | |
u8* bitmapBuffer; | |
pd->graphics->getBitmapData(bitmap, &width, &height, &stride, &hasMask, &bitmapBuffer); | |
// bitmap data is comprised of two maps for each channel, one after the other | |
int mapSize = height * stride; |
NewerOlder