mirror of
https://github.com/Rezmason/matrix.git
synced 2026-04-14 12:29:30 -07:00
Moving more playdate files around, adding a playdate-specific gitignore to the subdirectory and adding an easter egg.
This commit is contained in:
6
playdate/.gitignore
vendored
Normal file
6
playdate/.gitignore
vendored
Normal 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 |
@@ -6,7 +6,6 @@
|
|||||||
// Read the LICENSE file if you want to
|
// Read the LICENSE file if you want to
|
||||||
//
|
//
|
||||||
|
|
||||||
// #include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
@@ -29,7 +28,9 @@ static int numColumns;
|
|||||||
static int numRows;
|
static int numRows;
|
||||||
static int numCells;
|
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 int numFades = 32;
|
||||||
|
|
||||||
static const float minSpeed = 0.15;
|
static const float minSpeed = 0.15;
|
||||||
@@ -75,19 +76,12 @@ static void init()
|
|||||||
int fadeGradientWidth;
|
int fadeGradientWidth;
|
||||||
pd->graphics->getBitmapData(fadeGradient, &fadeGradientWidth, NULL, NULL, NULL, NULL);
|
pd->graphics->getBitmapData(fadeGradient, &fadeGradientWidth, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
glyphs = pd->system->realloc(NULL, sizeof(LCDBitmap *) * numTotalGlyphs * numFades);
|
||||||
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);
|
|
||||||
|
|
||||||
LCDBitmap *glyph = pd->graphics->newBitmap(glyphWidth, glyphWidth, kColorBlack);
|
LCDBitmap *glyph = pd->graphics->newBitmap(glyphWidth, glyphWidth, kColorBlack);
|
||||||
|
|
||||||
pd->graphics->pushContext(glyph);
|
pd->graphics->pushContext(glyph);
|
||||||
for (int i = 0; i < numGlyphs; i++) {
|
for (int i = 0; i < numTotalGlyphs; i++) {
|
||||||
int column = i % spritesheetColumns;
|
int column = i % spritesheetColumns;
|
||||||
int row = i / spritesheetColumns;
|
int row = i / spritesheetColumns;
|
||||||
pd->graphics->drawBitmap(glyphSpritesheet, -column * glyphWidth, -row * glyphWidth, kBitmapUnflipped);
|
pd->graphics->drawBitmap(glyphSpritesheet, -column * glyphWidth, -row * glyphWidth, kBitmapUnflipped);
|
||||||
@@ -121,7 +115,7 @@ static void init()
|
|||||||
cell->glyphCycle = randf();
|
cell->glyphCycle = randf();
|
||||||
cell->columnTimeOffset = columnTimeOffset;
|
cell->columnTimeOffset = columnTimeOffset;
|
||||||
cell->columnSpeedOffset = columnSpeedOffset;
|
cell->columnSpeedOffset = columnSpeedOffset;
|
||||||
cell->glyphIndex = rand() % numGlyphs;
|
cell->glyphIndex = rand() % numStandardGlyphs;
|
||||||
cell->fadeIndex = -1;
|
cell->fadeIndex = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -148,6 +142,10 @@ static int update(void* ud)
|
|||||||
pd->system->resetElapsedTime();
|
pd->system->resetElapsedTime();
|
||||||
time += delta;
|
time += delta;
|
||||||
|
|
||||||
|
PDButtons currentButtons;
|
||||||
|
pd->system->getButtonState(¤tButtons, NULL, NULL);
|
||||||
|
int addPDGlyphs = currentButtons & kButtonA && currentButtons & kButtonB;
|
||||||
|
|
||||||
for (int i = 0; i < numCells; i++) {
|
for (int i = 0; i < numCells; i++) {
|
||||||
int mustDraw = 0;
|
int mustDraw = 0;
|
||||||
Cell *cell = &cells[i];
|
Cell *cell = &cells[i];
|
||||||
@@ -171,14 +169,19 @@ static int update(void* ud)
|
|||||||
cell->glyphCycle = cell->glyphCycle + delta * 2;
|
cell->glyphCycle = cell->glyphCycle + delta * 2;
|
||||||
if (cell->glyphCycle > 1) {
|
if (cell->glyphCycle > 1) {
|
||||||
cell->glyphCycle = fmod(cell->glyphCycle, 1);
|
cell->glyphCycle = fmod(cell->glyphCycle, 1);
|
||||||
int glyphIndex = (cell->glyphIndex + (rand() % 20)) % numGlyphs;
|
int lastGlyphIndex = cell->glyphIndex;
|
||||||
if (cell->glyphIndex != glyphIndex) {
|
while (cell->glyphIndex == lastGlyphIndex) {
|
||||||
cell->glyphIndex = glyphIndex;
|
cell->glyphIndex = rand();
|
||||||
|
if (addPDGlyphs && rand() % 4 == 0) {
|
||||||
|
cell->glyphIndex = numStandardGlyphs + cell->glyphIndex % numPDGlyphs;
|
||||||
|
} else {
|
||||||
|
cell->glyphIndex = cell->glyphIndex % numStandardGlyphs;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (fadeIndex < numFades - 1) {
|
if (fadeIndex < numFades - 1) {
|
||||||
mustDraw = 1;
|
mustDraw = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (mustDraw) {
|
if (mustDraw) {
|
||||||
LCDBitmap *glyph = glyphs[cell->glyphIndex * numFades + cell->fadeIndex];
|
LCDBitmap *glyph = glyphs[cell->glyphIndex * numFades + cell->fadeIndex];
|
||||||
|
|||||||
|
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 |
@@ -9,7 +9,9 @@ local numColumns <const> = floor(screenWidth / glyphWidth)
|
|||||||
local numRows <const> = floor(screenHeight / glyphWidth)
|
local numRows <const> = floor(screenHeight / glyphWidth)
|
||||||
local numCells <const> = numColumns * numRows
|
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 numFades <const> = 32
|
||||||
local glyphs = {}
|
local glyphs = {}
|
||||||
|
|
||||||
@@ -20,7 +22,7 @@ do
|
|||||||
local glyph = gfx.image.new(glyphWidth, glyphWidth, gfx.kColorBlack)
|
local glyph = gfx.image.new(glyphWidth, glyphWidth, gfx.kColorBlack)
|
||||||
|
|
||||||
gfx.pushContext(glyph)
|
gfx.pushContext(glyph)
|
||||||
for i = 1, numGlyphs do
|
for i = 1, numTotalGlyphs do
|
||||||
local column = (i - 1) % spritesheetColumns
|
local column = (i - 1) % spritesheetColumns
|
||||||
local row = floor((i - 1) / spritesheetColumns)
|
local row = floor((i - 1) / spritesheetColumns)
|
||||||
glyphSpritesheet:draw(-column * glyphWidth, -row * glyphWidth)
|
glyphSpritesheet:draw(-column * glyphWidth, -row * glyphWidth)
|
||||||
@@ -48,18 +50,6 @@ for i = 1,360 do
|
|||||||
sineTable[i] = math.sin(math.pi / 180 * i)
|
sineTable[i] = math.sin(math.pi / 180 * i)
|
||||||
end
|
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 wobbleA <const> = math.sqrt(2) / 50
|
||||||
local wobbleB <const> = math.sqrt(5) / 50
|
local wobbleB <const> = math.sqrt(5) / 50
|
||||||
|
|
||||||
@@ -74,14 +64,14 @@ for x = 1, numColumns do
|
|||||||
cell.glyphCycle = random()
|
cell.glyphCycle = random()
|
||||||
cell.columnTimeOffset = columnTimeOffset
|
cell.columnTimeOffset = columnTimeOffset
|
||||||
cell.columnSpeedOffset = columnSpeedOffset
|
cell.columnSpeedOffset = columnSpeedOffset
|
||||||
cell.glyphIndex = floor(random() * numGlyphs) + 1
|
cell.glyphIndex = random(numStandardGlyphs)
|
||||||
cell.fadeIndex = -1
|
cell.fadeIndex = -1
|
||||||
|
|
||||||
cells[#cells + 1] = cell
|
cells[#cells + 1] = cell
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
playdate.display.setRefreshRate(0)
|
playdate.display.setRefreshRate(30)
|
||||||
playdate.resetElapsedTime()
|
playdate.resetElapsedTime()
|
||||||
|
|
||||||
function playdate.update()
|
function playdate.update()
|
||||||
@@ -96,6 +86,8 @@ function playdate.update()
|
|||||||
playdate.resetElapsedTime()
|
playdate.resetElapsedTime()
|
||||||
time += delta
|
time += delta
|
||||||
|
|
||||||
|
local addPDGlyphs = playdate.buttonIsPressed(playdate.kButtonA) and playdate.buttonIsPressed(playdate.kButtonB)
|
||||||
|
|
||||||
for i = 1, numCells do
|
for i = 1, numCells do
|
||||||
local mustDraw = false
|
local mustDraw = false
|
||||||
local cell = cells[i]
|
local cell = cells[i]
|
||||||
@@ -119,14 +111,18 @@ function playdate.update()
|
|||||||
cell.glyphCycle = cell.glyphCycle + delta * 2
|
cell.glyphCycle = cell.glyphCycle + delta * 2
|
||||||
if cell.glyphCycle > 1 then
|
if cell.glyphCycle > 1 then
|
||||||
cell.glyphCycle = cell.glyphCycle % 1
|
cell.glyphCycle = cell.glyphCycle % 1
|
||||||
local glyphIndex = (cell.glyphIndex + random(20)) % numGlyphs + 1
|
local lastGlyphIndex = cell.glyphIndex
|
||||||
if cell.glyphIndex ~= glyphIndex then
|
while cell.glyphIndex == lastGlyphIndex do
|
||||||
cell.glyphIndex = glyphIndex
|
if addPDGlyphs and random(4) == 1 then
|
||||||
|
cell.glyphIndex = random(numPDGlyphs) + numStandardGlyphs
|
||||||
|
else
|
||||||
|
cell.glyphIndex = random(numStandardGlyphs)
|
||||||
|
end
|
||||||
|
end
|
||||||
if fadeIndex < numFades then
|
if fadeIndex < numFades then
|
||||||
mustDraw = true
|
mustDraw = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
if mustDraw then
|
if mustDraw then
|
||||||
glyphs[cell.glyphIndex][cell.fadeIndex]:draw((cell.x - 1) * glyphWidth, (cell.y - 1) * glyphWidth)
|
glyphs[cell.glyphIndex][cell.fadeIndex]:draw((cell.x - 1) * glyphWidth, (cell.y - 1) * glyphWidth)
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
name=The Playtrix
|
name=The Playtrix (Lua build)
|
||||||
author=Rezmason
|
author=Rezmason
|
||||||
description=A familiar animation of mysterious raining symbols.
|
description=A familiar animation of mysterious raining symbols.
|
||||||
bundleID=net.rezmason.theplaytrix
|
bundleID=net.rezmason.theplaytrix_lua
|
||||||
version=1.0
|
version=1.0
|
||||||
buildNumber=1
|
buildNumber=1
|
||||||
imagePath=path/to/launcher/assets
|
imagePath=path/to/launcher/assets
|
||||||
Reference in New Issue
Block a user