Add cursors
This commit is contained in:
@@ -37,6 +37,8 @@ static OwnerType getOwnerType(BzTileID tile) {
|
||||
typedef enum TerrainType {
|
||||
TERRAIN_NONE = -1,
|
||||
TERRAIN_GOLD_ORE,
|
||||
TERRAIN_WHEAT_0,
|
||||
TERRAIN_WHEAT_1,
|
||||
TERRAIN_COUNT,
|
||||
} TerrainType;
|
||||
|
||||
@@ -792,25 +794,22 @@ static AnimationFrame entityGetAnimationFrame(EntityType entity, AnimType type,
|
||||
|
||||
typedef enum ItemType {
|
||||
ITEM_NONE = -1,
|
||||
ITEM_ARROW,
|
||||
ITEM_AXE,
|
||||
ITEM_BATTLEAXE,
|
||||
ITEM_BATTLEHAMMER,
|
||||
ITEM_BOW,
|
||||
ITEM_CUTLASS,
|
||||
ITEM_DAGGER,
|
||||
ITEM_FORK,
|
||||
ITEM_GREATEAXE,
|
||||
ITEM_GREATSWORD,
|
||||
ITEM_HAMMER,
|
||||
ITEM_IRON_SHIELD,
|
||||
ITEM_JAVLIN,
|
||||
ITEM_MACE,
|
||||
ITEM_PICKAXE,
|
||||
ITEM_SHIELD,
|
||||
ITEM_SPEAR,
|
||||
ITEM_STAFF,
|
||||
ITEM_SWORD,
|
||||
ITEM_SYTHE,
|
||||
ITEM_TRIDENT,
|
||||
ITEM_WOOD_SHIELD,
|
||||
ITEM_COUNT,
|
||||
} ItemType;
|
||||
@@ -825,18 +824,15 @@ static BzTileID getItemTile(ItemType type) {
|
||||
case ITEM_SHIELD: return 7937;
|
||||
case ITEM_IRON_SHIELD: return 7938;
|
||||
case ITEM_BOW: return 7939;
|
||||
case ITEM_JAVLIN: return 7942;
|
||||
case ITEM_ARROW: return 7943;
|
||||
case ITEM_SWORD: return 8192;
|
||||
case ITEM_GREATSWORD: return 8193;
|
||||
case ITEM_CUTLASS: return 8194;
|
||||
case ITEM_BATTLEAXE: return 8195;
|
||||
case ITEM_GREATEAXE: return 8196;
|
||||
case ITEM_SYTHE: return 8197;
|
||||
case ITEM_MACE: return 8198;
|
||||
case ITEM_BATTLEHAMMER: return 8199;
|
||||
case ITEM_SPEAR: return 8200;
|
||||
case ITEM_TRIDENT: return 8201;
|
||||
case ITEM_SYTHE: return 8448;
|
||||
case ITEM_HAMMER: return 8450;
|
||||
case ITEM_SPEAR: return 8451;
|
||||
case ITEM_FORK: return 8452;
|
||||
default: return -1;
|
||||
}
|
||||
}
|
||||
@@ -1661,6 +1657,10 @@ static bool hasItemHandlePoint(BzTile tile) {
|
||||
case 8199:
|
||||
case 8200:
|
||||
case 8201:
|
||||
case 8448:
|
||||
case 8450:
|
||||
case 8451:
|
||||
case 8452:
|
||||
return true;
|
||||
default: return false;
|
||||
}
|
||||
@@ -1686,6 +1686,10 @@ static Vector2 getItemHandlePoint(BzTile tile) {
|
||||
case 8199: return (Vector2) {5, 11};
|
||||
case 8200: return (Vector2) {4, 12};
|
||||
case 8201: return (Vector2) {4, 12};
|
||||
case 8448: return (Vector2) {6, 9};
|
||||
case 8450: return (Vector2) {5, 11};
|
||||
case 8451: return (Vector2) {4, 12};
|
||||
case 8452: return (Vector2) {4, 12};
|
||||
default: return (Vector2) {0.0f, 0.0f};
|
||||
}
|
||||
}
|
||||
@@ -1703,6 +1707,8 @@ static bool hasEntityHitBoxRec(BzTile tile) {
|
||||
case 5891:
|
||||
case 6146:
|
||||
case 6147:
|
||||
case 6400:
|
||||
case 6401:
|
||||
case 6402:
|
||||
case 6403:
|
||||
case 6656:
|
||||
@@ -1728,6 +1734,8 @@ static Rectangle getEntityHitBoxRec(BzTile tile) {
|
||||
case 5891: return (Rectangle) {6, 2, 4, 10};
|
||||
case 6146: return (Rectangle) {6, 2, 4, 10};
|
||||
case 6147: return (Rectangle) {6, 2, 4, 10};
|
||||
case 6400: return (Rectangle) {4, 2, 8, 10};
|
||||
case 6401: return (Rectangle) {4, 2, 8, 10};
|
||||
case 6402: return (Rectangle) {6, 2, 4, 10};
|
||||
case 6403: return (Rectangle) {6, 2, 4, 10};
|
||||
case 6656: return (Rectangle) {6, 2, 4, 10};
|
||||
|
||||
@@ -46,6 +46,8 @@ typedef struct InputState {
|
||||
CURSOR_NONE,
|
||||
CURSOR_COLLECT_WOOD,
|
||||
CURSOR_COLLECT_GOLD,
|
||||
CURSOR_FARM,
|
||||
CURSOR_ATTACK
|
||||
} cursor;
|
||||
|
||||
// INPUT_BUILDING
|
||||
|
||||
@@ -94,7 +94,7 @@ void inputUnitAction(Game *game, InputState *input) {
|
||||
input->cursor = CURSOR_COLLECT_GOLD;
|
||||
break;
|
||||
case RES_FOOD:
|
||||
//input->cursor = CURSOR_COLLECT_FOOD;
|
||||
input->cursor = CURSOR_FARM;
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
@@ -343,22 +343,37 @@ void drawPlayerInputUI() {
|
||||
DrawRectangleLines(area.x, area.y, area.width, area.height, RED);
|
||||
}
|
||||
|
||||
Vector2 point = input->mouseWorld;
|
||||
Rectangle texRect = {0, 0, 0, 0};
|
||||
switch (input->cursor) {
|
||||
case CURSOR_COLLECT_WOOD: {
|
||||
const Vector2 point = input->mouseWorld;
|
||||
DrawCircle(point.x, point.y, 2.0f, RED);
|
||||
DrawText("Collect wood", point.x, point.y, 10.0f, RED);
|
||||
case CURSOR_COLLECT_WOOD:
|
||||
texRect = getTextureRect(getItemTile(ITEM_AXE));
|
||||
break;
|
||||
}
|
||||
case CURSOR_COLLECT_GOLD: {
|
||||
const Vector2 point = input->mouseWorld;
|
||||
DrawCircle(point.x, point.y, 2.0f, RED);
|
||||
DrawText("Collect gold", point.x, point.y, 10.0f, RED);
|
||||
case CURSOR_COLLECT_GOLD:
|
||||
texRect = getTextureRect(getItemTile(ITEM_PICKAXE));
|
||||
break;
|
||||
case CURSOR_FARM:
|
||||
texRect = getTextureRect(getItemTile(ITEM_SYTHE));
|
||||
break;
|
||||
case CURSOR_ATTACK:
|
||||
texRect = getTextureRect(getItemTile(ITEM_CUTLASS));
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
|
||||
if (texRect.width != 0 && texRect.height != 0) {
|
||||
Texture tiles = game->tileset.tiles;
|
||||
f32 size = 35.0 / game->camera.zoom;
|
||||
Rectangle dst = {
|
||||
point.x - size * 0.5f,
|
||||
point.y - size * 0.5f,
|
||||
size, size
|
||||
};
|
||||
point.y -= texRect.height;
|
||||
|
||||
DrawTexturePro(tiles, texRect, dst, Vector2Zero(), 0.0f, WHITE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ecs_entity_t queryEntity(BzSpatialGrid *entityGrid, Vector2 point, ecs_entity_t tag) {
|
||||
|
||||
Reference in New Issue
Block a user