-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce resource proximity + rock asset (resource)
- Loading branch information
1 parent
ef18b24
commit 4ce2876
Showing
13 changed files
with
177 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
newmtl lambert2SG | ||
illum 4 | ||
Kd 0.00 0.00 0.00 | ||
Ka 0.00 0.00 0.00 | ||
Tf 1.00 1.00 1.00 | ||
map_Kd base.png | ||
map_Ka height.png | ||
bump normal.png | ||
Ni 1.00 |
Git LFS file not shown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
const config = @import("../../config.zig"); | ||
const rl = @import("raylib"); | ||
const std = @import("std"); | ||
|
||
const ResourceInfo = struct { | ||
key: rl.KeyboardKey, | ||
key_label: [:0]const u8, | ||
action: [:0]const u8, | ||
drawer: *const fn (width: f32, height: f32, font: *rl.Font) void, | ||
}; | ||
|
||
pub const info = std.StaticStringMap(ResourceInfo).initComptime(.{ | ||
.{ @tagName(.rock), .{ | ||
.key = .key_r, | ||
.key_label = "R", | ||
.action = "Mine", | ||
.drawer = rock, | ||
} }, | ||
.{ @tagName(.tree), .{ | ||
.key = .key_r, | ||
.key_label = "R", | ||
.action = "Chop", | ||
.drawer = tree, | ||
} }, | ||
.{ @tagName(.bush), .{ | ||
.key = .key_r, | ||
.key_label = "R", | ||
.action = "Harvest", | ||
.drawer = bush, | ||
} }, | ||
}); | ||
|
||
fn generic(key: [:0]const u8, width: f32, height: f32, font: *rl.Font) void { | ||
const value = info.get(key).?; | ||
const actionLength: rl.Vector2 = rl.measureTextEx(font.*, value.action, config.resourceActionFontSize, config.textSpacing); | ||
|
||
const boundarySize: rl.Vector2 = .{ | ||
.x = 20 + actionLength.x, | ||
.y = actionLength.y + 14, | ||
}; | ||
|
||
const keyLabelLength: f32 = rl.measureTextEx(font.*, value.key_label, config.resourceActionFontSize + 6, config.textSpacing).x; | ||
const labelBoxSize: rl.Vector2 = .{ | ||
.x = keyLabelLength + 10, | ||
.y = actionLength.y + 14, | ||
}; | ||
|
||
const labelBoxPosition: rl.Vector2 = .{ | ||
.x = width / 2 - boundarySize.x / 2 - labelBoxSize.x / 2, | ||
.y = height - 162, | ||
}; | ||
|
||
const labelPosition: rl.Vector2 = .{ | ||
.x = labelBoxPosition.x + 5, | ||
.y = labelBoxPosition.y + 7, | ||
}; | ||
|
||
const boundaryPosition: rl.Vector2 = .{ | ||
.x = labelBoxPosition.x + labelBoxSize.x, | ||
.y = height - 162, | ||
}; | ||
|
||
rl.drawRectangleV(boundaryPosition, boundarySize, config.ColorPalette.primary); | ||
rl.drawRectangleLinesEx(.{ .x = boundaryPosition.x, .y = boundaryPosition.y, .width = boundarySize.x, .height = boundarySize.y }, 2, config.ColorPalette.secondary); | ||
rl.drawRectangleV(labelBoxPosition, labelBoxSize, config.ColorPalette.secondary); | ||
rl.drawTextEx(font.*, value.key_label, labelPosition, config.resourceActionFontSize + 6, config.textSpacing, config.ColorPalette.primary); | ||
|
||
const actionPosition: rl.Vector2 = .{ | ||
.x = boundaryPosition.x + 10, | ||
.y = boundaryPosition.y + 7, | ||
}; | ||
rl.drawTextEx(font.*, value.action, actionPosition, config.resourceActionFontSize, config.textSpacing, config.ColorPalette.secondary); | ||
} | ||
|
||
fn rock(width: f32, height: f32, font: *rl.Font) void { | ||
generic("rock", width, height, font); | ||
} | ||
|
||
fn tree(width: f32, height: f32, font: *rl.Font) void { | ||
generic("tree", width, height, font); | ||
} | ||
|
||
fn bush(width: f32, height: f32, font: *rl.Font) void { | ||
generic("bush", width, height, font); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
|
||
|
||
pub const Kind = enum { | ||
head, | ||
top, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
pub const Kind = enum { | ||
health, | ||
mana, | ||
|