GithubHelp home page GithubHelp logo

classicvalues / riddle-2 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from riddle-rs/riddle

0.0 0.0 0.0 3.63 MB

Rust native game/media development library

License: Apache License 2.0

Rust 100.00%

riddle-2's Introduction

About Riddle

Build

Riddle is a Rust media library in the vein of SDL, building as far as possible on the most active/standard rust libraries (winit, wgpu, image, etc). Riddle is NOT an engine, or a framework. It is a library devoted to exposing media related features in a unified way while avoiding prescribing program structure [note 1].

The rough feature set is listed here, along with the crates the features are primarily built upen. Riddle is only possible due to the massive efforts of the greater rust community.

  • Windowing and System Event Loops (Docs), exposed through riddle::platform. Uses winit.
  • Input State Management (Docs), exposed through riddle::input. Gamepad, mouse and keyboard support. Built on winit and gilrs
  • Image Loading and Basic Graphics Operations (Docs), exposed through riddle::image. Uses image.
  • Font Loading and Rendering (Docs), exposed through riddle::font. Uses rusttype.
  • Math (Docs), exposed through riddle::math. Uses mint, and glam.
  • Audio Loading and Playing. (Docs), Uses rodio.
  • Basic 2D Renderer (Docs), exposed through riddle::renderer. Uses wgpu.
  • Timers and Framerate Tracking (Docs), exposed throug riddle::time.

This crate depends on an array of crates, each of which implements a specific feature. All sub-crates can be used independently of the top level riddle crate, but are best used by adding a dependency on riddle with appropriate feature flags configured.

Each crate fully wraps the underlying libraries to allow for a consistent API to be preserved between releases. They also contain extension traits, to provide direct access to the underlying types. The few exceptions to this, where types from other crates are exposed through Riddle's public API are where those crates have become defacto standards for cross crate integration, such as mint, and raw-window-handle.

Documentation

Since the crate isn't on crates.io docs are hosted on Github Pages:

Cargo Features

  • riddle-renderer - The riddle-renderer-wgpu renderer will be enabled. default
  • riddle-audio- The riddle-audio subsystem will be enabled. default
  • riddle-font - The riddle-font crate will be included, and reexported through riddle::font. default
  • riddle-mp3 - Enable mp3 support in riddle-audio.

Getting started

Add a git dependency in your cargo.toml to the most recent release [note 2]:

[dependencies.riddle]
version = "0.2"
git = "https://github.com/riddle-rs/riddle/"
tag = "0.2.0"

If you want to use the bleeding edge insert the following in to your cargo.toml:

[dependencies.riddle]
version = "0.3.0-dev"
git = "https://github.com/riddle-rs/riddle/"
branch = "master"

Place the following in main.rs:

use riddle::{*, platform::*, renderer::*, common::Color};

fn main() -> Result<(), RiddleError> {
    // Initialize the library
    let rdl = RiddleLib::new()?;

    // Create a window and renderer
    let window = WindowBuilder::new().build(rdl.context())?;
    let renderer = Renderer::new_from_window(&window)?;

    // Start the main event loop
    rdl.run(move |rdl| {
        match rdl.event() {
            Event::Platform(PlatformEvent::WindowClose(_)) => rdl.quit(),
            Event::ProcessFrame => {
                // Clear the window with black every frame
                renderer.render(|render_ctx| {
                    render_ctx.clear(Color::BLACK);
                }).unwrap();
            }
            _ => (),
         }
    })
}

Examples

The rustdocs for most public APIs contain example code to illustrate how the various riddle systems work, and how they should be used.

More complete examples live in riddle/examples.

The current set of examples is:

  • pong - A simple pong game, using input, basic fill-rect rendering, and audio.
  • wgpu-renderer-overlay - A demo showing how to use riddle to create a window, in which a custom WGPU 3d renderer co-exists with a Riddle 2d renderer.
  • sandbox - This is a scratchpad example which tries to use as much functionality as possible to provide quick manual verification of changes to the library. It is not a learning resource.

Linux build dependencies

To build on Linux the following packages are required (on Ubuntu at least): libasound2-dev libudev-dev. These are required for rodio(audio library), and gilrs(controller support library) respectively.

They can be installed by running:

sudo apt install libasound2-dev libudev-dev

Notes

  1. A necesary exception is the top level RiddleLib::run function which must be used if riddle::platform is to be used.

riddle-2's People

Contributors

rikvdkleij avatar rohannishant avatar vickles avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.