add map files and json support

This commit is contained in:
2025-03-03 14:44:47 -05:00
parent 97e6006143
commit 9079b9a56b
5 changed files with 24783 additions and 19 deletions
BIN
View File
Binary file not shown.
+24765
View File
File diff suppressed because it is too large Load Diff
+17 -19
View File
@@ -1,46 +1,44 @@
#include <BearLibTerminal.h> #include <BearLibTerminal.h>
#include <cstdlib> #include <cstdlib>
#include <fstream>
#include "json.hpp"
using json = nlohmann::json;
using namespace std; using namespace std;
int main() { int main() {
int windowX = 128; int windowX = 136;
int windowY = 64; int windowY = 68;
int cellPixelsX = 8; int cellPixelsX = 8;
int cellPixelsY = 4; int cellPixelsY = 4;
int windowRenderX = windowX + cellPixelsX; int windowXCenter = (windowX / 2) - (cellPixelsX / 2);
int windowRenderY = windowY + cellPixelsY; int windowYCenter = (windowY / 2) - (cellPixelsY / 2);
int baseBackground = 0xE000;
int grassTile = baseBackground + 45;
int oneRedFlower = baseBackground + 7;
terminal_open(); terminal_open();
terminal_set("window.size=128x64"); terminal_set("window.size=136x68");
int x = 32;
int y = 32;
int baseBackground = 0xF000;
int grassTile = baseBackground + 45;
int oneRedFlower = baseBackground + 7;
bool running = true; bool running = true;
while (running) { while (running) {
terminal_set("0xF000: ./tiles/background.png, size=64x64, align=top-left"); terminal_set("0xE000: ./tiles/background.png, size=64x64, align=top-left");
for(int i = 0; i <= windowY; i+=4){
for(int j = 0; j <= windowX; j+=8){
int randNum = (rand() % 10) + 1;
for(int i = 0; i <= windowY; i+=cellPixelsY){
for(int j = 0; j <= windowX; j+=cellPixelsX){
int tileCode = grassTile; int tileCode = grassTile;
if(randNum == 10) tileCode = oneRedFlower;
terminal_put_ext(j, i, 0, 0, tileCode); terminal_put_ext(j, i, 0, 0, tileCode);
} }
} }
terminal_put_ext(windowXCenter, windowYCenter, 0, 0, oneRedFlower);
terminal_refresh(); terminal_refresh();
int key = terminal_read(); int key = terminal_read();
+1
View File
File diff suppressed because one or more lines are too long
Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB