https://github.com/josepedrodias/stdb-tetris
WIP!
https://github.com/josepedrodias/stdb-tetris
multiplayer-browser-game multiplayer-game multiplayer-game-server spacetimedb
Last synced: 28 days ago
JSON representation
WIP!
- Host: GitHub
- URL: https://github.com/josepedrodias/stdb-tetris
- Owner: JosePedroDias
- Created: 2025-04-27T01:39:17.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2025-05-01T02:52:37.000Z (about 1 month ago)
- Last Synced: 2025-05-05T05:08:25.520Z (28 days ago)
- Topics: multiplayer-browser-game, multiplayer-game, multiplayer-game-server, spacetimedb
- Language: TypeScript
- Homepage:
- Size: 46.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Tetris STDB
## setup / cheat sheet
```
spacetime start --listen-addr='0.0.0.0:3000'
clear && spacetime publish --project-path server-rs tetris-game --delete-data -y
spacetime generate --lang typescript --out-dir client-ts/src/module_bindings --project-path server-rsspacetime logs tetris-game
spacetime sql tetris-game "SELECT * FROM cell"
spacetime sql tetris-game "SELECT COUNT(*) as count FROM cell"
spacetime sql tetris-game "SELECT COUNT(*) AS count FROM cell WHERE value != 0"spacetime sql tetris-game "SELECT * FROM board_data"
spacetime call tetris-game move_down
cd client-ts
clear && npm run build && npm run preview
(or) npm run dev
```## TODO
- game actions/intents should be ignored while a game is not in place for the sender
- client can only see cell and board_data rows where board_id is the player with id = ctx.sender
- S send garbage line(s) to random opponent when player breaks above n lines (3 -> 1, 4 -> 2)
- S/C? game table (links all the players in the same game together)
- lobby state -> ready -> start shared game
- expose methods to get client internal state to bots
- add board_filled bool column to board_data to enforce game_over- create keys for game_id, group players in sessions of N (2, ...)
- if more than X lines (2?), send garbage to another random player
- drop should trigger another piece to be added right away, not on next tick## Model data
```
Cell
id: u32
board_id: u32
x: u8
y: u8
value: u8BoardData
id: u32
owner: Identity
selected_piece: u8
selected_piece_variant: u8
next_piece: u8
next_piece_variant: u8
pos_x: u8
pos_y: u8
pub ghost_y: u8
pub score: u32
pub lines: u32ScheduleMoveDown ~> move_down_from_timer
id: u32
scheduled_at: ScheduleAt
board_id: u32Game
id: u64Player
id: Identity
game_id: u32
```## client-exposed reducers
- move_left()
- move_right()
- move_down()
- drop()
- rotate_left()
- rotate_right()