Files
factorygame/player/player.h

81 lines
1.6 KiB
C

//
// Created by bruno on 4/24/25.
//
#ifndef FACTORYGAME_PLAYER_H
#define FACTORYGAME_PLAYER_H
#include "../tiles/tile.h"
#include "../items/item.h"
extern int playerReach;
#define playerTileX (mainPlayer.rect.x / TILE_SIZE)
#define playerTileY (mainPlayer.rect.y / TILE_SIZE)
extern int playerSpeed;
extern SDL_Texture *entityTexture;
extern SDL_Texture *hudTexture;
//bool isInbounds(int x, int y);
//
//bool isInboundsRect(SDL_Rect tileRect);
//
//bool isInboundsTile(int x, int y);
void adjustRect(SDL_Rect *rect, SDL_Rect playerRect);
#define neededHealthIdle 120
#define playerMaxHealth 255
typedef struct PlayerInventory {
uint16_t slotCounts[ITEMREGISTRY_SIZE];
ItemType activeSlotIndex;
ItemType hotKeySlots[13];
} PlayerInventory;
typedef struct PlayerCursor {
int windowX;
int windowY;
int tileX;
int tileY;
int tileDiffX;
int tileDiffY;
int tileDiff;
bool canReach;
OrientDirection direction;
SDL_Rect targetTileRect;
Tile *targetTile;
Tile *prevTargetTile;
SDL_Rect heldItemRect;
int breakingProgress;
} PlayerCursor;
typedef struct Player{
PlayerCursor cursor;
PlayerInventory inventory;
uint8_t health;
uint8_t prevHealth;
uint8_t healthIdle;
SDL_Rect rect;
MiniRect tileRect;
uint32_t mouseButtons;
MiniRect coreTileRect;
} Player;
extern SDL_Rect PlayerRect;
void setActivePlayerSlot(Player *plr, ItemType activeSlotIndex);
void moveActivePlayerSlot(Player *plr, bool up, bool seek);
void renderPlayer(Player *plr);
void initPlayer(Player *plr);
void updatePlayer(Player *plr);
extern Player mainPlayer;
#endif //FACTORYGAME_PLAYER_H