Skip to main content

Game

Trait Game 

Source
pub trait Game {
    // Required methods
    fn step(&mut self, arguments: &StepArguments);
    fn draw(&self, arguments: &DrawArguments) -> Image;
    fn render_audio(&self, arguments: &RenderAudioArguments) -> Sound;
}
Expand description

The core trait used by Romy, games need to implement this. Romy will use these methods to run the game.

Required Methods§

Source

fn step(&mut self, arguments: &StepArguments)

Simulates the game by one step

§Arguments
  • arguments - Info, such as inputs, to be used in this step
Source

fn draw(&self, arguments: &DrawArguments) -> Image

Renders an image for Romy to display, can be called many times per step.

This function can return any image.

§Arguments
  • arguments - Info, such as the width of the frame Romy is rendering too, to be used in this step
Source

fn render_audio(&self, arguments: &RenderAudioArguments) -> Sound

Renders some audio for Romy to play, called once per step.

The sound returned currently needs to be at a sample rate of 44100hz, and have enough samples to cover the amount of time between calls to step.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§