74 lines
1.5 KiB
C
74 lines
1.5 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 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;
|
|
} Player;
|
|
|
|
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);
|
|
|
|
#endif //FACTORYGAME_PLAYER_H
|