Crate care_game

Crate care_game 

Source
Expand description

§Care

Care is a very simple game framework focused solely on ease of use. The api is heavilty inspired by Löve 2D.

§Hello World

Here’s the source code for hello world with care, making a window appear that displays “hello world” (using the love2d-inspired interface).

#[care::draw]
fn draw() {
    care::graphics::text("Hello, World!", (20, 20));
}

care::main!();

You can also use the async interface (inspired by macroquad) if you want:

#[care::async_main]
async fn main() {
    loop {
        care::graphics::text("Hello, World!", (20, 20));

        care::event::next_frame().await;
    }
}

care::main!();

See examples in the examples directory or the rust doc for more information.

§Comparison with love2d

§Graphics

The namespace love.graphics and care::graphics.

  • Drawing
    • love.graphics.arc
    • love.graphics.circle
    • love.graphics.clear
    • love.graphics.discard
    • love.graphics.draw -> partial: texture, texture_scale, texture_source, texture_rot & texture_rounded
    • love.graphics.drawInstanced
    • love.graphics.drawLayer
    • love.graphics.ellipse
    • love.graphics.flushBatch
    • love.graphics.line -> line_segment, line & line_varying_styles
    • love.graphics.points
    • love.graphics.polygon -> partial: line & line_varying_styles
    • love.graphics.present
    • love.graphics.print -> partial: text
    • love.graphics.printf
    • love.graphics.rectangle -> rectangle, rectangle_rot & rectangle_rounded
    • love.graphics.stencil
  • Object Creation
    • love.graphics.newImage -> Texture::new, new_from_file_format, new_fill, new_from_image & new_from_data
    • love.graphics.newFont -> Font::new, Font::new_from_vec & Font::new_from_bytes
    • Many more…
  • Graphics State
    • love.graphics.setColor -> set_colour
    • love.graphics.setLineJoin -> set_line
    • love.graphics.setLineWidth -> Not needed
    • love.graphics.setLineStyle
    • Many more…
  • Coordinate System
  • Window
  • System Information

§Keyboard

The namespace love.keyboard and care::keyboard.

  • love.keyboard.isDown -> is_down
  • love.keyboard.getKeyFromScancode
  • love.keyboard.getScancodeFromKey
  • love.keyboard.hasKeyRepeat
  • love.keyboard.hasScreenKeyboard
  • love.keyboard.hasTextInput
  • love.keyboard.isScancodeDown
  • love.keyboard.setKeyRepeat
  • love.keyboard.setTextInput
  • Additionally, is_pressed & is_released are available

Re-exports§

pub use config::Conf;
pub use image;
pub use nalgebra;
pub use rand;
pub use rusttype;

Modules§

compute
Contains functions for using GPU Compute (GPGPU)
config
Global care configuration parameters
event
Low-level event handling
graphics
Contains functions for rendering graphics Graphics functions, all of which will panic if called from a thread that is not the main thread, or if any function is called before calling init from the main thread.
keyboard
Stuff for working with a keyboard.
math
Contains functions for doing various math tasks, including working with vectors
mouse
Stuff for working with a mouse
prelude
Useful structs to have imported
window
Contains functions for working with window(s)

Macros§

main
Inserts a default main function that automatically initializes the framework, opens a window, and calls the functions marked by init, update and draw at appropriate times

Attribute Macros§

async_main
Mark a function as the care draw function.
draw
Mark a function as the care draw function.
init
Mark a function as the care initialization function.
state
Make some state for the game
update
Mark a function as the care update function.