Open Dinhero21 opened 11 months ago
I feel like the simplest one to implement is range.
Terraria has an INSANE range with 18 tiles horizontally, 17 up, and 14 down (with the character's feet as the center (1 tile above red)).
The distance function seems to be a maximum absolute axial difference. (max(|a.x - b.x|, |a.y - b.y|)
)
When outside the range, any attempt at breaking a tile will fail with the animation still playing. The tooltip will disappear (if the current tile is outside the range), this will not however happen with other "illegal" states (such as placing a tile inside a furniture).
Some items have range modifiers which, as the name implies, modifies the range. The range gets linearly shifted by the value present in the modifier.
The way block placement works currently is kind of awkward since you can place infinitely far floating blocks, might want to work on this first
(me when accidentally closed issue)
Terraria, and many other games (such as Minecraft), use a "selected slot"-like system which is what I've been thinking about implementing.
You can use the Number Keys (except the Numeric Keypad (even with NumLock) (for whatever reason)) or the mouse scroll wheel to change which item is selected.
The set of selectable slots, usually a row of the grid inventory, is called the Hotbar. Terraria has a grid inventory with a size of 10 (x) by 5 (y) (overkill imo) with the first row being the Hotbar.
This is much better than what is currently in the game which is an awkward cursor-slot system requiring a complicated set of actions to do anything. Pseudo-code below.
--- on Slot.ClickHandler@Event<left.down> ---
// Clicked -> Clicked Slot
// Cursor -> Cursor Slot
// Type -> Stack Type
// Amount -> Stack Amount
// Swap(A, B) -> Sets A to B and B to A
if (Type<Clicked> === Type<Cursor>)
{
Amount<Clicked> += Amount<Cursor>
Amount<Cursor> = 0
}
Swap(Clicked, Cursor)
---------------------------------------------
--- on World.ClickHandler@Event<left.down> ---
// Cursor -> Cursor Slot
// World -> World Helper
// Inventory -> Inventory Helper
// Position -> Clicked Tile Position
// Tile -> Clicked Tile Instance
// Type -> [Tile|Stack] Type
// Amount -> Stack Amount
// A is B -> Type<A> === B
if (Tile is air)
{
World.setTile(
Type<Cursor>,
Position
)
Amount<Cursor> -= 1
}
else
{
Inventory.add(
Type<Cursor>,
1
)
World.setTile(
air,
Position
)
}
----------------------------------------------
TODO: Find a better name for this.
"Survival Elements", basically health, hunger, mana, limited (non-instant, ranged) world manipulation