Moving more playdate files around, adding a playdate-specific gitignore to the subdirectory and adding an easter egg.

This commit is contained in:
Rezmason
2022-06-06 19:18:59 -07:00
parent fadc1ed639
commit 346bbbb84d
7 changed files with 45 additions and 40 deletions

6
playdate/.gitignore vendored Normal file
View File

@@ -0,0 +1,6 @@
matrix_c/build/*
matrix_c/build-device/*
*.pdx
pdex.dylib
pdex.bin

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -6,7 +6,6 @@
// Read the LICENSE file if you want to
//
// #include <stdio.h>
#include <stdlib.h>
#include <math.h>
@@ -29,7 +28,9 @@ static int numColumns;
static int numRows;
static int numCells;
static const int numGlyphs = 133;
static const int numStandardGlyphs = 133;
static const int numPDGlyphs = 10;
static const int numTotalGlyphs = numStandardGlyphs + numPDGlyphs;
static const int numFades = 32;
static const float minSpeed = 0.15;
@@ -75,19 +76,12 @@ static void init()
int fadeGradientWidth;
pd->graphics->getBitmapData(fadeGradient, &fadeGradientWidth, NULL, NULL, NULL, NULL);
LCDBitmap *fadeGradientTransparent = pd->graphics->loadBitmap("images/fade-gradient-transparent", NULL);
int wrongWidth;
pd->graphics->getBitmapData(fadeGradientTransparent, &wrongWidth, NULL, NULL, NULL, NULL);
pd->system->logToConsole("%i should be 512", wrongWidth);
glyphs = pd->system->realloc(NULL, sizeof(LCDBitmap *) * numGlyphs * numFades);
glyphs = pd->system->realloc(NULL, sizeof(LCDBitmap *) * numTotalGlyphs * numFades);
LCDBitmap *glyph = pd->graphics->newBitmap(glyphWidth, glyphWidth, kColorBlack);
pd->graphics->pushContext(glyph);
for (int i = 0; i < numGlyphs; i++) {
for (int i = 0; i < numTotalGlyphs; i++) {
int column = i % spritesheetColumns;
int row = i / spritesheetColumns;
pd->graphics->drawBitmap(glyphSpritesheet, -column * glyphWidth, -row * glyphWidth, kBitmapUnflipped);
@@ -121,7 +115,7 @@ static void init()
cell->glyphCycle = randf();
cell->columnTimeOffset = columnTimeOffset;
cell->columnSpeedOffset = columnSpeedOffset;
cell->glyphIndex = rand() % numGlyphs;
cell->glyphIndex = rand() % numStandardGlyphs;
cell->fadeIndex = -1;
}
}
@@ -148,6 +142,10 @@ static int update(void* ud)
pd->system->resetElapsedTime();
time += delta;
PDButtons currentButtons;
pd->system->getButtonState(&currentButtons, NULL, NULL);
int addPDGlyphs = currentButtons & kButtonA && currentButtons & kButtonB;
for (int i = 0; i < numCells; i++) {
int mustDraw = 0;
Cell *cell = &cells[i];
@@ -171,14 +169,19 @@ static int update(void* ud)
cell->glyphCycle = cell->glyphCycle + delta * 2;
if (cell->glyphCycle > 1) {
cell->glyphCycle = fmod(cell->glyphCycle, 1);
int glyphIndex = (cell->glyphIndex + (rand() % 20)) % numGlyphs;
if (cell->glyphIndex != glyphIndex) {
cell->glyphIndex = glyphIndex;
int lastGlyphIndex = cell->glyphIndex;
while (cell->glyphIndex == lastGlyphIndex) {
cell->glyphIndex = rand();
if (addPDGlyphs && rand() % 4 == 0) {
cell->glyphIndex = numStandardGlyphs + cell->glyphIndex % numPDGlyphs;
} else {
cell->glyphIndex = cell->glyphIndex % numStandardGlyphs;
}
}
if (fadeIndex < numFades - 1) {
mustDraw = 1;
}
}
}
if (mustDraw) {
LCDBitmap *glyph = glyphs[cell->glyphIndex * numFades + cell->fadeIndex];

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -9,7 +9,9 @@ local numColumns <const> = floor(screenWidth / glyphWidth)
local numRows <const> = floor(screenHeight / glyphWidth)
local numCells <const> = numColumns * numRows
local numGlyphs <const> = 133
local numStandardGlyphs <const> = 133
local numPDGlyphs <const> = 10
local numTotalGlyphs <const> = numStandardGlyphs + numPDGlyphs
local numFades <const> = 32
local glyphs = {}
@@ -20,7 +22,7 @@ do
local glyph = gfx.image.new(glyphWidth, glyphWidth, gfx.kColorBlack)
gfx.pushContext(glyph)
for i = 1, numGlyphs do
for i = 1, numTotalGlyphs do
local column = (i - 1) % spritesheetColumns
local row = floor((i - 1) / spritesheetColumns)
glyphSpritesheet:draw(-column * glyphWidth, -row * glyphWidth)
@@ -48,18 +50,6 @@ for i = 1,360 do
sineTable[i] = math.sin(math.pi / 180 * i)
end
-- function fastSin(x)
-- x = x / 360 % 1
-- local sign
-- if x < 0.5 then
-- sign = -1
-- else
-- sign = 1
-- end
-- x = (x % 0.5) * 2 - 0.5
-- return sign * x * x * 4 - 1
-- end
local wobbleA <const> = math.sqrt(2) / 50
local wobbleB <const> = math.sqrt(5) / 50
@@ -74,14 +64,14 @@ for x = 1, numColumns do
cell.glyphCycle = random()
cell.columnTimeOffset = columnTimeOffset
cell.columnSpeedOffset = columnSpeedOffset
cell.glyphIndex = floor(random() * numGlyphs) + 1
cell.glyphIndex = random(numStandardGlyphs)
cell.fadeIndex = -1
cells[#cells + 1] = cell
end
end
playdate.display.setRefreshRate(0)
playdate.display.setRefreshRate(30)
playdate.resetElapsedTime()
function playdate.update()
@@ -96,6 +86,8 @@ function playdate.update()
playdate.resetElapsedTime()
time += delta
local addPDGlyphs = playdate.buttonIsPressed(playdate.kButtonA) and playdate.buttonIsPressed(playdate.kButtonB)
for i = 1, numCells do
local mustDraw = false
local cell = cells[i]
@@ -119,14 +111,18 @@ function playdate.update()
cell.glyphCycle = cell.glyphCycle + delta * 2
if cell.glyphCycle > 1 then
cell.glyphCycle = cell.glyphCycle % 1
local glyphIndex = (cell.glyphIndex + random(20)) % numGlyphs + 1
if cell.glyphIndex ~= glyphIndex then
cell.glyphIndex = glyphIndex
local lastGlyphIndex = cell.glyphIndex
while cell.glyphIndex == lastGlyphIndex do
if addPDGlyphs and random(4) == 1 then
cell.glyphIndex = random(numPDGlyphs) + numStandardGlyphs
else
cell.glyphIndex = random(numStandardGlyphs)
end
end
if fadeIndex < numFades then
mustDraw = true
end
end
end
if mustDraw then
glyphs[cell.glyphIndex][cell.fadeIndex]:draw((cell.x - 1) * glyphWidth, (cell.y - 1) * glyphWidth)

View File

@@ -1,7 +1,7 @@
name=The Playtrix
name=The Playtrix (Lua build)
author=Rezmason
description=A familiar animation of mysterious raining symbols.
bundleID=net.rezmason.theplaytrix
bundleID=net.rezmason.theplaytrix_lua
version=1.0
buildNumber=1
imagePath=path/to/launcher/assets