定制 candycore/candy-tetris 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

candycore/candy-tetris

最新稳定版本:v0.2.0

Composer 安装命令:

composer create-project candycore/candy-tetris

包简介

Tetris clone built on the SugarCraft stack — SugarCraft runtime, CandySprinkles styling, HoneyBounce-driven smooth piece previews. Standard SRS rules (7-bag RNG, ghost piece, hard drop, hold, level/speed curve, line-clear scoring). A real demo of the runtime, not a toy.

README 文档

README

candy-tetris

CandyTetris

CI codecov Packagist Version License PHP

demo

Tetris built on the SugarCraft stack. SugarCraft runtime, CandySprinkles for the rounded borders and per-piece colours, deterministic 7-bag RNG, ghost piece, hard drop, hold, level-driven gravity ramp, line-clear scoring.

Run it

composer install
./bin/tetris

Controls

Key Action
← / → Move left / right
↑ / x Rotate clockwise
z Rotate counter-cw
Soft drop
Space Hard drop
p Pause / resume
q Quit

Scoring (NES-classic)

Lines cleared Base points × (level + 1)
1 40
2 100
3 300
4 (Tetris) 1200

Level rises every 10 lines. Gravity speeds up at every level — by level 9 pieces fall every 6 frames, by level 29+ they fall every frame. The frame-rate-agnostic Score::framesPerRow() is what the gravity tick consults.

Architecture

Six pure-state classes, each individually testable without booting the runtime:

Tetromino  enum  ─►  shape data + colour for each of the 7 pieces
Piece      VO    ─►  Tetromino + rotation + (x, y), with immutable transforms
Board      VO    ─►  10×24 grid (4 hidden rows above), fits/place/clearLines/dropPiece
Bag        ──►  7-bag RNG with peek(); injectable RNG closure for deterministic tests
Score      VO    ─►  points / lines / level + level-driven gravity interval
Game       Model ─►  SugarCraft Model orchestrating the above + key handling

Renderer   ──►  pure view function from Game to frame string

Why so split? Because each piece is testable in isolation — line-clear correctness has nothing to do with rotation correctness has nothing to do with score arithmetic. The full test suite is 41 tests, 1535 assertions and runs in 30 ms; the deterministic RNG injection means even the Game integration tests are reproducible across runs.

Status

Phase 9+ entry #19 — first cut. All standard SRS rules, ghost piece, level/gravity, scoring. Wall-kicks are a tiny ±2 horizontal nudge rather than full SRS-spec; OK for v0.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 10
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固