Crates.io | pistoncore-current |
lib.rs | pistoncore-current |
version | 0.0.3 |
source | src |
created_at | 2014-12-11 12:17:19.100418 |
updated_at | 2015-12-12 23:55:19.918092 |
description | DEPRECATED. Use `current`. |
homepage | https://github.com/pistondevelopers/current |
repository | https://github.com/pistondevelopers/current.git |
max_upload_size | |
id | 512 |
size | 7,562 |
A library for setting current values for stack scope, such as application structure
Example project: Sea Birds' Breakfast
See Best coding practices with current objects
This also posts safety guidelines for the library.
In game programming, there are many kinds of "current" values:
There are two ways to use this library:
By setting these up as "current" values, you don't have to pass them around to each method. For example, you can write code like this (demonstrating the unsafe version):
e.press(|button| {
let gun = unsafe { &mut *current_gun() };
let player = unsafe { &mut *current_player() };
if button == SHOOT {
gun.shoot(player.aim);
}
});