StructOp Handbook
Contents Examples Commands

Flappy player

Terminal game347 lines of .st411 lines of generated Rust
Last screen
Press SPACE to flap.






















@
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 (21 lines)
input.txt · key script, one line per frame (21 lines)

p












space
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.struct.Player
      + ability.function.gravity_and_move
      + ability.if.Terminal
      + ability.set.Gravity
      + ability.set.Fall
      + ability.set.Forward
      + ability.if.Ceiling
      + ability.set.Top
      + ability.function.flap
      + ability.set.Up
      + ability.function.render
      + ability.draw.Dragon
      + ability.function.play
      + ability.clear.Sky
      + ability.set.Elapsed
      + ability.if.Physics
      + ability.set.ResetTime
      + ability.call.Move
      + ability.switch.PlayKey
      + ability.call.Flap
      + ability.call.Render
      + ability.text.Help
      + ability.if.Fallen
      + ability.set.ToEnd
      + ability.function.restart
      + ability.set.NewPlayer
      + ability.set.NoTime
      + 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.player
      + ability.value.frame_time
      + ability.value.mode
      + ability.value.key
      + ability.value.frame_ms

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-player    # a folder holding the .st files above
structop init
structop plan
structop apply