Files
factorygame/items/item.h
2025-06-11 15:42:06 +02:00

74 lines
1.3 KiB
C

//
// Created by bruno on 4/24/25.
//
#include <SDL2/SDL.h>
#include "../util/util.h"
#include "../tiles/belt.h"
#include "../tiles/tile.h"
#ifndef FACTORYGAME_ITEM_H
#define FACTORYGAME_ITEM_H
#define ITEMREGISTRY_SIZE 128
typedef enum ItemType {
TYPE_AIR = 0,
TYPE_BLOCK,
TYPE_BELT,
TYPE_FURNACE,
TYPE_MINER,
TYPE_TURRET,
TYPE_SPLITTER,
TYPE_CORE,
IRON_ORE = ITEMREGISTRY_SIZE / 2,
SILVER_ORE,
GOLD_ORE,
PLATINUM_ORE,
IRON_INGOT,
SILVER_INGOT,
GOLD_INGOT,
PLATINUM_INGOT,
LOG,
IRON_BULLET,
SILVER_BULLET,
GOLD_BULLET,
PLATINUM_BULLET,
} ItemType;
typedef struct ItemOnBelt {
float offset;
MiniRect tile;
MiniRect prevTile;
ItemType type;
} ItemOnBelt;
typedef struct Item {
bool isTile;
ItemType type;
char name[20];
uint16_t miscVal;
OrientedAnimation animation;
OrientedAnimation beltAnimation;
} Item;
extern Item ItemRegistry[ITEMREGISTRY_SIZE];
void updateItems();
void loadItems(SDL_Renderer *mainRenderer);
void renderItem(ItemOnBelt item, SDL_Renderer *mainRenderer, int lane, SDL_Rect playerRect);
extern uint16_t itemRegistryIndex;
extern uint8_t laneTarget;
extern double speed;
void putItem(int x, int y, ItemType itemType, uint8_t lane);
#endif //FACTORYGAME_ITEM_H