Skip to content

Commit

Permalink
MineFx 1.1
Browse files Browse the repository at this point in the history
MineFx but better ~ destroy blocks, load/save worlds and have much more fun!
  • Loading branch information
theaddonn authored Oct 3, 2023
1 parent ea7d815 commit b26d78b
Show file tree
Hide file tree
Showing 12 changed files with 426 additions and 445 deletions.
2 changes: 2 additions & 0 deletions src/include/blocks/baseBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
class BaseBlockType
{
public:
virtual uint8_t id(){ return 0x00; }

virtual TemplatePatternMap getTextureTemplatePattern()
{
static char textureTemplatePattern[17][16] = {
Expand Down
2 changes: 2 additions & 0 deletions src/include/blocks/instances/airBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
class AirBlockType : public BaseBlockType
{
public:
virtual uint8_t id(){ return 0x01; }

virtual TemplatePatternMap getTextureTemplatePattern()
{
static char textureTemplatePattern[17][16] = {
Expand Down
47 changes: 47 additions & 0 deletions src/include/blocks/instances/cursorBlock.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include "../baseBlock.cpp"

class CursorBlockType : public BaseBlockType
{
public:
virtual uint8_t id(){ return 0xFF; }

virtual TemplatePatternMap getTextureTemplatePattern()
{
static char textureTemplatePattern[17][16] = {
{'#', '#', '#', '#', '#', '#', '#', 'A', 'A', '#', '#', '#', '#', '#', '#', '#'},
{'#', '#', '#', '#', '#', 'A', 'A', '#', '#', 'A', 'A', '#', '#', '#', '#', '#'},
{'#', '#', '#', 'A', 'A', '#', '#', '#', '#', '#', '#', 'A', 'A', '#', '#', '#'},
{'#', 'A', 'A', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', 'A', 'A', '#'},
{'A', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', 'A'},
{'A', 'A', 'A', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', 'A', 'A', 'A'},
{'A', 'A', 'A', 'A', 'A', '#', '#', '#', '#', '#', '#', 'A', 'A', 'A', 'A', 'A'},
{'A', '#', '#', 'A', 'A', 'A', 'A', '#', '#', 'A', 'A', 'A', 'A', '#', '#', 'A'},
{'A', '#', '#', '#', '#', 'A', 'A', 'A', 'A', 'A', 'A', '#', '#', '#', '#', 'A'},
{'A', '#', '#', '#', '#', '#', '#', 'A', 'A', '#', '#', '#', '#', '#', '#', 'A'},
{'A', '#', '#', '#', '#', '#', '#', 'A', 'A', '#', '#', '#', '#', '#', '#', 'A'},
{'A', '#', '#', '#', '#', '#', '#', 'A', 'A', '#', '#', '#', '#', '#', '#', 'A'},
{'A', '#', '#', '#', '#', '#', '#', 'A', 'A', '#', '#', '#', '#', '#', '#', 'A'},
{'#', 'A', 'A', '#', '#', '#', '#', 'A', 'A', '#', '#', '#', '#', 'A', 'A', '#'},
{'#', '#', '#', 'A', 'A', '#', '#', 'A', 'A', '#', '#', 'A', 'A', '#', '#', '#'},
{'#', '#', '#', '#', '#', 'A', 'A', 'A', 'A', 'A', 'A', '#', '#', '#', '#', '#'},
{'#', '#', '#', '#', '#', '#', '#', 'A', 'A', '#', '#', '#', '#', '#', '#', '#'},
};

TemplatePatternMap pattern = TemplatePatternMap(textureTemplatePattern);

return pattern;
}
virtual KeyColorPairMap getTextureTemplateKeys()
{
KeyColorPairMap keyColorMap = KeyColorPairMap(1);
keyColorMap.add(KeyColorPair('A', color(66, 123, 128)));

return keyColorMap;
}
};

class CursorBlock : public BaseBlock
{
public:
CursorBlock() : BaseBlock(new CursorBlockType()) {}
};
2 changes: 2 additions & 0 deletions src/include/blocks/instances/dirtBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
class DirtBlockType : public BaseBlockType
{
public:
virtual uint8_t id(){ return 0x02; }

virtual KeyColorPairMap getTextureTemplateKeys()
{
KeyColorPairMap keyColorMap = KeyColorPairMap(2);
Expand Down
2 changes: 2 additions & 0 deletions src/include/blocks/instances/grassBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
class GrassBlockType : public BaseBlockType
{
public:
virtual uint8_t id(){ return 0x03; }

virtual TemplatePatternMap getTextureTemplatePattern()
{
static char textureTemplatePattern[17][16] = {
Expand Down
2 changes: 2 additions & 0 deletions src/include/blocks/instances/leaveBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
class LeaveBlockType : public BaseBlockType
{
public:
virtual uint8_t id(){ return 0x04; }

virtual KeyColorPairMap getTextureTemplateKeys()
{
KeyColorPairMap keyColorMap = KeyColorPairMap(2);
Expand Down
2 changes: 2 additions & 0 deletions src/include/blocks/instances/logBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
class LogBlockType : public BaseBlockType
{
public:
virtual uint8_t id(){ return 0x05; }

virtual TemplatePatternMap getTextureTemplatePattern()
{
static char textureTemplatePattern[17][16] = {
Expand Down
2 changes: 2 additions & 0 deletions src/include/blocks/instances/pathBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
class PathBlockType : public BaseBlockType
{
public:
virtual uint8_t id(){ return 0x06; }

virtual TemplatePatternMap getTextureTemplatePattern()
{
static char textureTemplatePattern[17][16] = {
Expand Down
2 changes: 2 additions & 0 deletions src/include/blocks/instances/stoneBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
class StoneBlockType : public BaseBlockType
{
public:
virtual uint8_t id(){ return 0x07; }

virtual KeyColorPairMap getTextureTemplateKeys()
{
KeyColorPairMap keyColorMap = KeyColorPairMap(2);
Expand Down
38 changes: 29 additions & 9 deletions src/include/constants.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#include <sdk/os/lcd.hpp>

static int MAP_SIZE_X = 10; // Map size in x coord
static int MAP_SIZE_Y = 32; // Map size in y coord
static int MAP_SIZE_Z = 10; // Map size in z coord
int MAP_SIZE_X = 10; // Map size in x coord
int MAP_SIZE_Y = 10; // Map size in y coord
int MAP_SIZE_Z = 10; // Map size in z coord

int BLOCK_WIDTH = 80; // Block width in pixel
int BLOCK_HEIGHT = 85; // Block height in pixel
const int BLOCK_TILES_X = 16; // Block Tiles in the x coord
const int BLOCK_TILES_Y = 17; // Block Tiles in the y coord

static int BLOCK_TILES_X = 16; // Block Tiles in the x coord
static int BLOCK_TILES_Y = 17; // Block Tiles in the y coord
const int CAMERA_OFFSET_CHANGE = 20; // Amount off pixel the camera should be able to move

static int CAMERA_OFFSET_CHANGE = 20; // Amount off pixel the camera should be able to move
int BLOCK_WIDTH = 80; // Block width in pixel
int BLOCK_HEIGHT = 85; // Block height in pixel

int BLOCK_TILES_AVR_WIDTH; // Pixel size of block in width
int BLOCK_TILES_AVR_HEIGHT; // Pixel size of block in height
Expand All @@ -19,6 +19,11 @@ int DISPLAY_WIDTH, DISPLAY_HEIGT;

int x_offset, y_offset;

int x, y, z;
int cursor_x, cursor_y, cursor_z = 0;
int cal_x, cal_y;
bool running = true;

void calcScaleConstants()
{
BLOCK_TILES_AVR_WIDTH = BLOCK_WIDTH / BLOCK_TILES_X;
Expand All @@ -33,4 +38,19 @@ void initConstants()
LCD_GetSize(&DISPLAY_WIDTH, &DISPLAY_HEIGT);

calcScaleConstants();
}
}

const uint8_t WORLD_FORMAT_HEADER[] = {0x4D, 0x49, 0x4E, 0x45, 0x46, 0x58, 0x57, 0x4F, 0x52, 0x4C, 0x44};
const uint8_t WORLD_FORMAT_VERSION[] = {0x31, 0x30, 0x30};
const uint8_t WORLD_FORMAT_WORLD_SIZE_X = 0x0a;
const uint8_t WORLD_FORMAT_WORLD_SIZE_Y = 0x0a;
const uint8_t WORLD_FORMAT_WORLD_SIZE_Z = 0x0a;


const uint8_t WORLD_FORMAT[] = {0x4D, 0x49, 0x4E, 0x45, 0x46, 0x58, 0x57, 0x4F, 0x52, 0x4C, 0x44, 0x31, 0x30, 0x30, 0x0a, 0x0a, 0x0a, 0x00, 0x00, 0x00};

const int WORLD_FORMAT_SIZE = 20;

const int WORLD_FORMAT_WORLD_SIZE_X_INDEX = 14;
const int WORLD_FORMAT_WORLD_SIZE_Y_INDEX = 15;
const int WORLD_FORMAT_WORLD_SIZE_Z_INDEX = 16;
5 changes: 2 additions & 3 deletions src/include/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct KeyColorPairMap
KeyColorPairMap(int conSize)
{
size = conSize;
data = new KeyColorPair[conSize]; // Allocate memory for 'data' based on 'conSize'
data = new KeyColorPair[conSize];
}

~KeyColorPairMap()
Expand All @@ -46,7 +46,7 @@ struct KeyColorPairMap

uint16_t get(char key)
{
for (int i = 0; i < currentSize; i++) // Loop through 'currentSize' elements, not 'size'
for (int i = 0; i < currentSize; i++)
{
if (data[i].keyVal == key)
{
Expand All @@ -62,7 +62,6 @@ struct TemplatePatternMap
{
char textureTemplatePattern[17][16];

// Constructor that accepts a dynamically-sized 2D array
TemplatePatternMap(char c[][16])
{
for (int i = 0; i < 17; ++i)
Expand Down
Loading

0 comments on commit b26d78b

Please sign in to comment.