johntao / console-snake

A text-based snake game
2 stars 0 forks source link

Intro

a text-based minimal snake game

Design proposal

1) A config file to control the game parameters as many as possible

  1.1) The config file should be auto-generated if not exist

  1.2) The config file should be in TOML format (cuz why not?!)

2) Game parameters

  2.1) Gameplay

    2.1.1) starting length of the snake

    2.1.2) can go through the wall

    2.1.3) (optional) add temporary objective

    2.1.4) useLevel

  2.2) GameplaySpeed

    2.2.1) Starting Speed

    2.2.2) use levels to boost speed

    2.2.3) motor type (ByKey, ByTimer, ByBoth)

    2.2.4) (optional) speed boost for temporary objective

  2.3) GameplayLevel

    2.3.1) LevelSpeedDefinition

    2.3.2) Threshold

    2.3.3) DefaultLevel

  2.4) Visual

    2.4.1) show/ hide dashboard

    2.4.2) show/ hide border

  2.5) VisualMap

    2.5.1) size of map (must be square)

    2.5.2) map legend (game unit and tile definition)

3) Game rules

  3.1) game start on the first key stroke

  3.2) game level up by eating items

  3.3) snake grows up by eating items

  3.4) the only score is the length of the snake

    3.4.1) NO PLANS to implement complex score

  3.5) dashboard fields: Level, Speed, Length, Time, HighScore

  3.6) definite level and speed booster

  3.7) game end on win/ loss condition

  3.8) user can start a new game after defeated

  3.9) (optional) add win/ loss indicator

4) Code implementation

  4.1) the map should be a simple 2d array

  4.2) code should be as simple as possible

    4.2.1) (optional) split Snake into smaller pieces

  4.3) NO PLANS to run TDD or DDD

  4.4) thread usage as less as possible

    4.4.1) should be easy to extend to multi-thread

  4.5) should use dependency injection

  4.6) configuration should be strongly typed

    4.6.1) should be auto-mapped

    4.6.2) should support hot-reload

  4.7) use latest language features if possible

    4.7.1) (optional) replace 2d array by jagged array to use indices

  4.8) NO PLANS to improve the text rendering experience

    4.8.1) border should be rendered contiguously

    4.8.2) handle half-width, full-width char gracefully

    4.8.3) support colors

    4.8.4) reduce flickers

5) Code deployment

  5.1) no test coverage

  5.2) no CI/ CD

  5.3) no docker

  5.4) no cloud