# Look and feel
How games are judged (first person): info on objects, colors, flat text on blocks, particles, sounds, HUD, info channels, controls (WASD, camera), multiplayer plots, displays, measuring the world. Open before any game people will look at.

Before writing, picture what the player sees from where they stand. Rejected as lazy: a side legend explaining what
each block means, colored blocks instead of numbers, particles at a fixed point above an object (invisible from
above/first person), a board whose far cells are out of reach or unreadable at a grazing angle.
- Show information ON the object: flat text on top of blocks, the digits/icons themselves colored, state shown by
  shape (closed cell = bottom slab, opened = full block).
- Icons: server symbols. Verified on text displays: ⚑ ☠. Take others from `/symbols 1..8` in game (or a
  `jmvcc client shot` of that list); do not type emoji from memory — they may render as boxes.
- Colors: write the color FIRST, then `&l`: `"&#42A5F5&l1"` (a color code after `&l` resets bold — verified on item
  names). Hex `&#RRGGBB` is verified on item names and text displays; in chat the author says it works, in action bar
  and titles it is not checked. Pick colors against the block under them: a light floor (white_concrete) with
  saturated or dark digits, no gray on gray (minesweeper darkened 8 from #9E9E9E to #757575).
- Flat text on a block top (verified, server-check-17): yaw 0 + pitch -90 lies flat and reads upright for a player
  standing SOUTH of it facing north (yaw 180 is upside down/sideways; other directions not checked); the text anchors
  at the bottom edge of the line, so shift z by +0.125·S to center it. S = 4.5 makes a digit nearly fill a cell.
  ```
  save var marks                // and in top-level code: marks ??= []  (an unset list swallows appends — verified)
  function mark(loc, txt) {     // loc = variable::set_all_coordinates(x + 0.5, top + 0.01, z + 0.5 + 0.125 * 4.5, 0, -90)
    world::spawn_text_display(loc, "mark", displayed_text = [txt])
    marks.append(value::uuid<last_entity>)              // store the uuid FIRST: an error later leaks it
    entity::set_display_scale<last_entity>(vector(4.5, 4.5, 4.5), "SET")
    entity::set_text_display_background<last_entity>("#000000", 0) // transparent background
  }
  ```
  `top` = 4.0 on a full block whose top face is y=4, +0.5 on a bottom slab. Displays SURVIVE /play like mobs: remove
  them on restart and world_start (`select::entity_by_name([u])`, `entity::remove()`, then `select::reset()`).
  Removal from a player event is verified; in a NO_TARGET process it is verified on mobs only, so check
  `world::has_entity([u])` afterwards and keep the survivors in the list (minesweeper `sweep`).
- `location(x, y, z)` / `vector(x, y, z)` with variables compile to one action (`set_all_coordinates` with yaw 90,
  pitch 0 like `location()` / `variable::vector`). Fields: `loc.x .y .z .yaw .pitch`, `v.x .y .z` (read = get_coordinate;
  `loc.y = 70` = set_coordinate, `loc.y += 1` = shift_coordinate, `v.x = 2` = set_vector_component).
  Same as `variable::set_all_coordinates(x, y, z, yaw, pitch)`. Always pass yaw AND pitch (`location()` defaults yaw to 90);
  pitch is positive = looking down.
- Feedback where the player looks: particles on the clicked face (seen live in the clicker, the author liked it):
  ```
  line var face = variable::get_vector_from_block_face(value::event_block_face)
  line var at = variable::align_location(value::event_block, "KEEP", "ALL", "BLOCK_CENTER")
  at = variable::shift_location_on_vector(at, face, 0.6)
  player::display_particle(particle("crit", 6, 0.25, 0.25), at)
  ```
- Sounds: a distinct one per outcome (click, success, refusal, lose, win), frequent ones quieter and higher:
  `sound("entity.experience_orb.pickup", 0.3, 1.8)`; refusal `entity.villager.no`, level-up
  `entity.player.levelup` are used in the games; find others with `jmvcc search` (the compiler checks names).
- HUD: timer/score in the action bar from ONE world loop once a second, not per tick. Hints also go to the action
  bar, so pause the HUD ~2 s after a hint (`hint_until` in minesweeper). Records: sidebar scoreboard (verified);
  progress: boss bar 0..100 (verified). On join: 2–3 chat lines with goal, controls, record.
- Info channels — chat is the WORST one; agents tend to dump everything there. Use instead:
  - leaderboards/tops: a text display board in the world over the play area (billboard toward the viewer, dark
    semi-transparent background, updated only when the data changes — `entity::set_text_display_text` works, seen
    live in snake), or player heads with name + lore in a chest menu for big maps;
  - notifications (bought, not enough coins, your turn, new record): `player::action_bar` + a sound, DIFFERENT for
    positive (`entity.experience_orb.pickup`, `entity.player.levelup`) and negative (`entity.villager.no`) events;
    big moments (win, death): `player::title`; "X started a game" for everyone: the board/action bar, not chat;
  - a real batch of info for one player (rules on join, round summary): a framed, colored block, so it reads as UI:
    ```
    game var LINE = "&8&m                                                  "   // strikethrough spaces = a seamless line (verified; ━ ─ ▬ show seams)
    player::message([LINE, "  &#FFB300&lЗМЕЙКА", "  &7Ешь &6яблоки&7, не врежься в бортик", "  &e1-4 &7— повороты, &aизумруд &7— старт", LINE], merging = "SEPARATE_LINES")
    ```
    Hex `&#RRGGBB` works in chat and titles (verified, server-check-18). ~50 strikethrough spaces fit the default chat.
- Controls: squeeze the mechanics, do not hand out hotbar items as buttons. Movement keys (verified, server-check-19/19b):
  ```
  event<player_input_event> {            // fires on every change of held movement keys
    if (world::event_has_input("FORWARD")) { turn(0) }      // also BACKWARDS, LEFT, RIGHT, JUMP, SNEAK
  }                                      // value::event_input_list = "[forward, right]" (empty on release)
  ```
  Keep the player still: `player::set_attribute(0, "GENERIC_MOVEMENT_SPEED")` and `(0, "GENERIC_JUMP_STRENGTH")`
  (restore 0.1 / 0.42 after) — keys still arrive. Fixed top-down camera: spawn a text display at
  `location(x, h, z, 180, 90)`, then `player::set_gamemode("SPECTATOR")`, wait 5 ticks, `player::spectate_target(uuid)` —
  the view looks straight down and cannot turn, WASD still arrives; Shift leaves the camera
  (`event<player_stop_spectating_entity>`) — re-attach after 2 ticks or treat Shift as "exit/pause". Before choosing a
  scheme, search (`jmvcc search input|camera|spectate|steer`) and weigh 2–3 options.
- Multiplayer: one shared board ("one plays, the rest watch") is the fallback. For solo games prefer per-player
  plots (the author's idea, no recipe yet): a plot slot per player on join (grid offsets, free slots in a save list), built
  from a template, everything cleaned on quit (blocks, entities by uuid); deny rejoin/restart abuse that farms plot
  reloads (cooldown). A world (Star: 768×768) is larger than the author's 32×32 test floor, so plots can float on their own pads.
- From the author's working billiard (seen in a working game, not re-verified; full notes
  dev/research/billiard-facts.md):
  - Smooth motion of a display: once after spawning `entity::set_display_teleport_duration<last_entity>(STEP)`; then
    every STEP ticks just `entity::teleport` — the client interpolates. Rotation/translation changes need
    `entity::set_display_interpolation(STEP, 0)` right before them (delay 0), or they jump.
  - A rolling ball: `entity::set_display_rotation_from_axis_angle(axis, angle, "ADD", "LEFT_ROTATION")` with axis
    `(vz, 0, -vx)` and angle `distance / radius * 57.3` degrees; a head rotates around its origin, so compensate with
    `set_display_translation` (rotate the center vector the same way via `variable::rotate_vector_around_vector`).
  - Several entities with the same custom name: `select::entity_by_name("ball1")` selects all of them;
    `value::selection_target_uuids` gives their uuids. Entity custom tags: `entity::set_custom_tag(name, value)`,
    `entity::get_custom_tag`, `entity::has_custom_tag` (+ `select::entity_by_conditional` on a tag).
  - A number slot accepts `%math(...)` text (`number_raw("%math(%var(speed)*7)")` in decompiled code).
  - Menus: `player::show_menu(..., inventory_type = "HOPPER")` = 5 slots; `player::expand_menu(items, size = 3)` adds
    rows; `player::remove_menu_row(size, position = "BUTTON")` (the server enum is spelled BUTTON, not BOTTOM).
  - Text input through chat: set a per-player flag from the menu, read `value::event_chat_message` in
    `event<player_chat>` + `world::cancel_event()`, clear the flag after a timeout (`wait` + compare a token).
  - `value::cpu_usage` = the world's CPU %, handy for measuring (not in an every-tick loop).
  - Heavy patterns to avoid (found there): a process per moving object each tick with `select` by name inside the
    loop (O(N²) entity searches) — keep positions in a map and use one loop per table; `entity::remove<all_entities>`
    on start also removes foreign entities — keep uuids.

- CPU budget, measured costs of code, display entities and building / switching maps → topic costs.

## More look-and-feel facts
- Beauty must not cost CPU (the author's rule): particles/sounds only on events with small counts; no per-tick particle or
  display loops; spawn displays only when the state changes, spread big batches over ticks (minesweeper flood: 16
  cells, then `code::wait(1)`).
- Reach and view: a board bigger than ~4 blocks needs a viewing platform SOUTH of it (larger z, about 4–5 blocks up,
  30–45° down: `player::teleport(location(x, y, z, 180, 40), keep_rotation = false)`) and
  `player::set_attribute(16, "PLAYER_BLOCK_INTERACTION_RANGE")` (seen live: from the minesweeper tower clicks reached
  the far corner ~14 blocks away). Bring players back there with `code::wait(1)` +
  teleport in `player_respawn` (set_spawn_point did not work).
- Protect the build: cancel `player_break_block`, `player_place_block`, `block_damage`, drop/swap of the menu item
  (as in minesweeper; seen live there, not in the facts table).
- Blocks set from a NO_TARGET world loop (snake steps) did not show up on the client until `update_blocks = true` was
  passed to `world::set_block` (seen live: the server had them, screenshots did not). Pass it for anything that moves.
- `set_text_display_background` opacity 110 errored and cut the code line; 55 works (keep it ≤ 100, not checked
  further). `player::set_spawn_point` did not change `value::spawn_location` — teleport in `player_respawn` instead.
- In `player_change_slot`, `value::event_hotbar_slot` is the NEW slot (0..8) at once; `value::slot` is still the old one.
- Measure the world before building — never assume the floor height. The author's test world (yours differs — `jmvcc client world-profile`): a 32×32 superflat floor,
  x and z from -16 to 15, top block y=3, players at y=4, void beyond the edge (falling = death; never teleport a player
  over air). Recipes tie every location to `FLOOR_Y` (set it to the measured top floor block; players at FLOOR_Y + 1).
  Probe once, then delete the probe: `log("under feet: ${value::block_beneath}")` while standing on the floor
  (verified: block coordinates) gives the floor y; then scan (verified, server-check-17b):
  ```
  var hi = 0
  var i = 0
  repeat::while(i < 300) {
    i = i + 1
    line var p = variable::set_all_coordinates(i, 3, 0, 0, 0)    // 3 = the floor y you measured
    if (!world::block_equals(p, [item("air")])) { hi = i }
  }
  log("floor x up to $hi")
  ```
  Keep the game area 2 blocks inside the edge; where players run (arena, snake, parkour) put a wall/barrier on the edge.
