tinyfiles.tv
๐Ÿค–
Beep. I am the tinyfiles robot. I have lasers.

Click the robot to talk. Click LASERS to shoot. Click a target to zap it. Score is fake, pride is real.

๐ŸŽฏ Score: 0 โ€ข ๐Ÿ† Best: 0 โ€ข ๐Ÿ”ฅ Combo: โ€” โ€ข ๐Ÿ’ฅ Lasers: 0
โ€” LASER RANGE โ€” click a target to zap it โ€”
What was missing? You had 40+ pages โ€” C-Mail, C-Talk, P-Talk, Strong Feed, TinyMap, Sudoku, Chess, Wiki, Markets, Cosplay, all of it โ€” but no home base. No mascot. No one page that says โ€œstart here.โ€ This is that page. Robot = mascot. Lasers = fun. Everything below = the map.

Robot Lore

The robot is not Roger. Roger is the dumb model. The robot is the mascot. He has lasers. He does not have a name yet. He likes: lasers, pixels, tiny files. He dislikes: big files, spam, when you click him too much (he will still let you).

Next up if you want it: give the robot a name, put him on every page header, and let him shoot a laser when you complete a Sudoku / win Chess / finish a crossword.

Backend  ·  Template · Proposed · Not connected

โฌ‡ Backend — Robot + Lasers Backend — Template

Right now Robot + Lasers is local-only — score is let score = 0 in JS, spawnTarget() just drops 3 static targets, shootLaser() draws a random beam, there was no sound at all, and the Everything list is a hardcoded let everything = [...]. The game now has sound + combo + moving targets + best score in localStorage. This backend is the map to make the score real: a shared leaderboard, server-owned robot lines, and a server-owned Everything index. Proposed, not connected.

01 / Files to create
api/robot-lasers/score.php         GET  /api/robot-lasers/score?limit=10
                                   POST /api/robot-lasers/score
api/robot-lasers/lines.php        GET  /api/robot-lasers/lines
api/robot-lasers/everything.php   GET  /api/robot-lasers/everything?q=
sql/robot_lasers_tables.sql

Keep the tinyfiles PHP pattern: each endpoint loads /api/bootstrap.php, uses json_in() / json_out(), prepared PDO statements.

02 / Database tables
-- sql/robot_lasers_tables.sql
robot_scores
  id BIGINT AUTO_INCREMENT PRIMARY KEY
  user_id INT NULL                     -- NULL = guest, still counts
  name VARCHAR(40) NOT NULL DEFAULT 'anon'  -- shown on leaderboard
  score INT NOT NULL
  lasers INT NOT NULL DEFAULT 0
  best_combo INT NOT NULL DEFAULT 1
  created_at DATETIME NOT NULL
  -- one row per run. Leaderboard = MAX(score) per user, top 10.

robot_lines
  id INT AUTO_INCREMENT PRIMARY KEY
  text VARCHAR(280) NOT NULL
  active TINYINT(1) NOT NULL DEFAULT 1
  sort_order INT NOT NULL DEFAULT 0

robot_pages
  id INT AUTO_INCREMENT PRIMARY KEY
  section VARCHAR(80) NOT NULL         -- "Crypto & Mail", "Games & Toys"
  title VARCHAR(120) NOT NULL
  path VARCHAR(120) NOT NULL           -- "cmail.html"
  blurb VARCHAR(200) NOT NULL
  sort_order INT NOT NULL DEFAULT 0

Best score on this page is localStorage for now. The leaderboard is the shared version of that same number โ€” MAX(score) per user, never trust a score posted without a session.

03 / API endpoints & request flow
GET /api/robot-lasers/score?limit=10
- returns { "ok": true, "scores": [ { name, score, lasers,
  best_combo, created_at }, ... ] } โ€” top 10, highest first

POST /api/robot-lasers/score
{ "score": 120, "lasers": 14, "best_combo": 3 }
- auth optional (guest allowed), validates score 0-100000,
  lasers 0-10000, best_combo 1-100 โ€” all integers, no floats
- rate-limit: max 1 score per user per 10 seconds
- returns { "ok": true, "rank": 4 } โ€” where you placed

GET /api/robot-lasers/lines
- returns { "ok": true, "lines": ["Beep...", "Boop...", ...] }
- active=1 only, same lines the robot says now

GET /api/robot-lasers/everything?q=
- returns { "ok": true, "sections": [ { cat, pages: [
  { title, path, blurb } ] } ] }
- q matches title + blurb, max 100 pages

Gameplay stays client-side โ€” server never decides if a shot hit. Server only stores the result (score + lasers + combo) and serves lines + the Everything index.

04 / Sound, anti-cheat & validation (server owns this)
// Sound โ€” all Web Audio, no MP3 files, no autoplay:
//   AudioContext is created on the FIRST click (browser rule).
//   pew = sawtooth 880 -> 120 Hz, 0.18s
//   zap = square 1200 -> 200 Hz + noise burst, 0.25s
//   talk = two square blips 600 / 900 Hz
//   dance = 4-note arpeggio 440 / 554 / 659 / 880 Hz
//   combo = ascending arpeggio, pitch rises with combo
//   master gain 0.15, Sound toggle saved in localStorage 'robotSound'.

// Anti-cheat for the leaderboard:
//   score must be plausible for lasers fired โ€” score <= lasers*100 + 500
//   if score is impossible, reject with { "ok": false, "error": "invalid" }
//   guest scores are allowed but flagged โ€” no name spoofing:
//   name is 1-40 chars, plain text, escaped on render.

Keep the page’s rule: “Score is fake, pride is real.” The backend makes pride shared โ€” same game, but your best now shows up for everyone.

05 / Frontend wiring
// Sound is already wired in this page:
//   ensureAudio() on first click, sfx('pew'|'zap'|'talk'|'dance'|'combo')
//   toggleSound() flips localStorage 'robotSound' + button label

// Replace the hardcoded let lines = [...] in this page:
async function loadLines(){
  const res = await fetch('/api/robot-lasers/lines');
  const data = await res.json();
  // data.lines -> lines array, same robotTalk() as now
}

// Replace the hardcoded let everything = [...] in this page:
async function loadEverything(){
  const res = await fetch('/api/robot-lasers/everything?q=' + encodeURIComponent(q));
  const data = await res.json();
  // data.sections -> renderEverything(), same .everything-card HTML as now
}

// After a run ends (or on new best):
async function submitScore(){
  const res = await fetch('/api/robot-lasers/score', { method:'POST',
    headers:{'Content-Type':'application/json'},
    body: JSON.stringify({ score, lasers, best_combo: bestCombo }) });
  // show "You ranked #4!" โ€” same toast style as the score line
}

// On load: loadLines() + loadEverything() + show leaderboard
// If API fails, fall back to current hardcoded lines + everything + localStorage best.

Keep the current game + sound playable with no backend — if /api/robot-lasers/lines fails, use the in-page lines as the fallback.

Copy the snippets above into api/robot-lasers/ + sql/robot_lasers_tables.sql — no GitHub needed. The <pre> blocks are the backend spec: server-owned lines + Everything index + shared leaderboard, same layout, game stays client-side.