[][src]Crate amethyst

Amethyst is a free and open source game engine written in idiomatic Rust for building video games and interactive multimedia applications. The source code is available for download on GitHub. See the online book for a complete guide to using Amethyst.

This project is a work in progress and is very incomplete. Pardon the dust!

Example

extern crate amethyst;

use amethyst::prelude::*;
use amethyst::renderer::{Event, KeyboardInput, VirtualKeyCode, WindowEvent};

struct GameState;

impl EmptyState for GameState {
    fn on_start(&mut self, _: StateData<()>) {
        println!("Starting game!");
    }

    fn handle_event(&mut self, _: StateData<()>, event: StateEvent) -> EmptyTrans {
        if let StateEvent::Window(event) = &event {
            match event {
                 Event::WindowEvent { event, .. } => match event {
                    WindowEvent::KeyboardInput {
                        input: KeyboardInput { virtual_keycode: Some(VirtualKeyCode::Escape), .. }, ..
                    } |
                    WindowEvent::CloseRequested => Trans::Quit,
                    _ => Trans::None,
                },
                _ => Trans::None,
            }
        } else {
            Trans::None
        }
    }

    fn update(&mut self, _: StateData<()>) -> EmptyTrans {
        println!("Computing some more whoop-ass...");
        Trans::Quit
    }
}

fn main() {
    let mut game = Application::new("assets/", GameState, ()).expect("Fatal error");
    game.run();
}

Re-exports

pub extern crate amethyst_animation as animation;
pub extern crate amethyst_assets as assets;
pub extern crate amethyst_audio as audio;
pub extern crate amethyst_config as config;
pub extern crate amethyst_controls as controls;
pub extern crate amethyst_core as core;
pub extern crate amethyst_derive as derive;
pub extern crate amethyst_input as input;
pub extern crate amethyst_locale as locale;
pub extern crate amethyst_network as network;
pub extern crate amethyst_renderer as renderer;
pub extern crate amethyst_ui as ui;
pub extern crate amethyst_utils as utils;
pub extern crate winit;

Modules

ecs

SPECS Parallel ECS

prelude

Contains common types that can be glob-imported (*) for convenience.

shred

Shared resource dispatcher

shrev

Event channel, pull based, that use a ringbuffer for internal storage, to make it possible to do immutable reads.

Structs

ApplicationBuilder

ApplicationBuilder is an interface that allows for creation of an Application using a custom set of configuration. This is the normal way an Application object is created.

CoreApplication

CoreApplication is the application implementation for the game engine. This is fully generic over the state type and event type.

GameData

Default game data

GameDataBuilder

Builder for default game data

LoggerConfig

Logger configuration object.

StateData

State data encapsulates the data sent to all state functions from the application main loop.

StateEventReader
StateMachine

A simple stack-based state machine (pushdown automaton).

Enums

Error

Common error type.

LogLevelFilter

An enum representing the available verbosity level filters of the logger.

StateEvent

The enum holding the different types of event that can be received in a State in the handle_event method.

StdoutLog

An enum that contains options for logging to the terminal.

Trans

Types of state transitions. T is the type of shared data between states. E is the type of events

Traits

DataInit

Initialise trait for game data

EmptyState

An empty State trait. It contains no StateData or custom StateEvent.

SimpleState

A simple State trait. It contains GameData as its StateData and no custom StateEvent.

State

A trait which defines game states that can be used by the state machine.

Functions

start_logger

Starts a basic logger outputting to stdout with color on supported platforms, and/or to file.

Type Definitions

Application

An Application is the root object of the game engine. It binds the OS event loop, state machines, timers and other core components in a central place.

EmptyTrans

An empty Trans. Made to be used with EmptyState.

Result

Engine result type.

SimpleTrans

A simple default Trans. Made to be used with SimpleState. By default it contains a GameData as its StateData and doesn't have a custom event type.