Start atlas

This commit is contained in:
2025-06-01 22:13:02 +02:00
parent 96a9a45c20
commit 84805b92cb
64 changed files with 954 additions and 243 deletions

View File

@@ -5,15 +5,15 @@
#ifndef FACTORYGAME_TILE_H
#define FACTORYGAME_TILE_H
#include "belt.h"
#include "../util/util.h"
#include "../items/item.h"
//#include "../items/item.h"
#define MAP_WIDTH 600
#define MAP_HEIGHT 340
#define MAP_WIDTH 100
#define MAP_HEIGHT 100
#define DISPLAY_MAP_WIDTH 44
#define DISPLAY_MAP_HEIGHT 22
#define DISPLAY_MAP_WIDTH 60
#define DISPLAY_MAP_HEIGHT 31
#define TILE_SIZE 32
@@ -22,42 +22,108 @@
extern SDL_Texture *tilesTexture;
extern SDL_Texture *itemsTexture;
extern SDL_Texture *backgroundTexture;
extern int scrollFrame;
extern unsigned long beltFrames;
typedef struct {
uint16_t type;
#define ItemSlotCount 4
typedef enum BackgroundType {
BGType_WATER0,
BGType_WATER1,
BGType_GRASS0,
BGType_GRASS1,
BGType_GRASS2,
BGType_GRASS3,
BGType_GRASS4,
BGType_GRASS5,
BGType_GRASS6,
BGType_GRASS7,
BGType_GRASS_FLOWER0,
BGType_GRASS_FLOWER1,
BGType_GRASS_FLOWER2,
BGType_GRASS_FLOWER3,
BGType_SAND0,
BGType_SAND1,
BGType_SAND2,
BGType_SAND3,
BGType_SAND4,
BGType_SAND5,
BGType_SAND6,
BGType_SAND7,
BGType_TILES0,
BGType_TILES1,
BGType_TILES2,
BGType_TILES3,
BGType_COBBLE0,
BGType_COBBLE1,
BGType_COBBLE2,
BGType_COBBLE3,
BGType_PLATINUM_ORE,
BGType_GOLD_ORE,
BGType_SILVER_ORE,
BGType_IRON_ORE,
BGType_END
} BackgroundType;
typedef struct TileTypeReg {
ItemType type;
char name[20];
SDL_Texture *textures[ORIENT_DIRECTION_COUNT];
SDL_Rect atlasRects[ORIENT_DIRECTION_COUNT];
uint16_t breakTime;
} TileType;
bool itemMoves;
bool allowedInItems[ItemSlotCount][ITEMREGISTRY_SIZE];
bool outputLane[ItemSlotCount];
} TileTypeReg;
#define TILEREGISTRY_SIZE 512
typedef struct BackgroundTileType {
ItemType type;
char name[20];
SDL_Texture *texture;
SDL_Rect atlasRect;
} BackgroundTileType;
extern TileType TileRegistry[TILEREGISTRY_SIZE];
typedef struct BackgroundTile {
BackgroundType type;
} BackgroundTile;
#define TYPE_AIR 0
#define TYPE_BELT 2
#define TILEREGISTRY_SIZE 64
extern BackgroundTileType BackgroundTileRegistry[TILEREGISTRY_SIZE];
extern TileTypeReg TileRegistry[TILEREGISTRY_SIZE];
void renderAllTiles(SDL_Renderer *renderer, SDL_Rect playerRect);
typedef struct {
void updateTiles();
typedef struct Tile {
OrientDirection direction;
uint16_t type;
int frameOffset;
ItemOnBelt items[2];
ItemType type;
int miscVal;
ItemOnBelt items[ItemSlotCount];
uint16_t audioCh;
int x;
int y;
} Tile;
extern Tile tileMap[MAP_HEIGHT][MAP_WIDTH];
extern BackgroundTile backgroundMap[MAP_HEIGHT][MAP_WIDTH];
void setupTiles();
void generateTestMap();
void loadTiles(SDL_Renderer *renderer);
extern uint16_t tileTypeIndex;
extern uint16_t backgroundTileTypeIndex;
uint16_t getBreakTime(int type);