Files
factorygame/player/player.h

73 lines
1.4 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 (player.rect.x / TILE_SIZE)
#define playerTileY (player.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 rect);
//
//bool isInboundsTile(int x, int y);
void adjustRect(SDL_Rect *rect, SDL_Rect playerRect);
#define neededHealthIdle 120
#define playerMaxHealth 255
typedef struct {
uint16_t slotCounts[ITEMREGISTRY_SIZE];
uint16_t activeSlotIndex;
} PlayerInventory;
typedef struct {
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 {
PlayerCursor cursor;
PlayerInventory inventory;
uint8_t health;
uint8_t prevHealth;
uint8_t healthIdle;
SDL_Rect rect;
} Player;
void setActivePlayerSlot(Player *plr, uint16_t activeSlotIndex);
void moveActivePlayerSlot(Player *plr, bool up, bool seek);
void renderPlayer(Player *plr);
void initPlayer(Player *plr);
void updatePlayer(Player *plr);
#endif //FACTORYGAME_PLAYER_H