Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

"Survival Elements" #10

Open
Tracked by #1
Dinhero21 opened this issue Oct 24, 2023 · 4 comments
Open
Tracked by #1

"Survival Elements" #10

Dinhero21 opened this issue Oct 24, 2023 · 4 comments

Comments

@Dinhero21
Copy link
Owner

Dinhero21 commented Oct 24, 2023

TODO: Find a better name for this.

"Survival Elements", basically health, hunger, mana, limited (non-instant, ranged) world manipulation

@Dinhero21 Dinhero21 mentioned this issue Oct 24, 2023
83 tasks
@Dinhero21 Dinhero21 changed the title "Survival Mode" "Survival Elements" Oct 24, 2023
@Dinhero21
Copy link
Owner Author

Dinhero21 commented Oct 24, 2023

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)).
Terraria Screenshot
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.
-1 range +3 range +4 range
The range gets linearly shifted by the value present in the modifier.

@Dinhero21
Copy link
Owner Author

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

@Dinhero21
Copy link
Owner Author

(me when accidentally closed issue)

@Dinhero21 Dinhero21 reopened this Oct 25, 2023
@Dinhero21
Copy link
Owner Author

Dinhero21 commented Oct 25, 2023

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
  )
}
----------------------------------------------

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant