StructOp Handbook
Contents Examples Commands

Flappy states

Terminal game169 lines of .st334 lines of generated Rust
Last screen
                                  You are dead!


                                 (P) Play Again
                                  (Q) Quit Game
On this page

The .st files#

intent.st
structop {
    type_app {
        exec = {
            lang = "Rust"
        }
    }

    lib_provider {
        core = {
            source  = "StructOp/core"
            version = "@latest"
        }
        Screen = {
            source  = "StructOp/game"
            version = "@latest"
        }
    }
}

Input, plan and generated Rust#

input.txt · key script, one line per frame (5 lines)
input.txt · key script, one line per frame (5 lines)

p


q
structop plan
structop plan
  # program.app will be created
  + program.app (.structop/build/app)
      + ability.enum.GameMode
      + ability.game.Flappy
      + ability.switch.Tick
      + ability.call.MainMenu
      + ability.call.Dead
      + ability.call.Play
      + ability.function.play
      + ability.set.ToEnd
      + ability.function.restart
      + ability.set.ToPlaying
      + ability.function.main_menu
      + ability.clear.Menu
      + ability.text.Welcome
      + ability.text.Play
      + ability.text.Quit
      + ability.switch.MenuKey
      + ability.call.Restart
      + ability.quit.MenuQuit
      + ability.function.dead
      + ability.clear.Dead
      + ability.text.Dead
      + ability.text.Again
      + ability.text.DeadQuit
      + ability.switch.DeadKey
      + ability.call.RestartAgain
      + ability.quit.DeadQuit
      + ability.value.mode
      + ability.value.key

Plan: 1 to add, 0 to change, 0 to destroy.
Generated main.rs

To inspect this generated file, select Rust in intent.st, initialize the project and export its source.

Export locally
structop init
structop apply -source -no-run
Try it
cd rust-flappy-states    # a folder holding the .st files above
structop init
structop plan
structop apply