The pro (and con) of doing a bunch of work that's primarily for yourself is that you occassionally end up doing a wee bit more than you originally intended to do in a single pull request. 😊
The changes...extracted from the changelog diff:
GameState::add_actor has been renamed to EngineState::add_sprite
GameState::add_text_actor has been renamed to EngineState::add_text
GameState.screen_dimensions, which was set at startup and never updated, has been replaced by EngineState.window_dimensions, which is updated every frame so resizing the window can be handled in your game logic.
Logic functions now need to fit the signature fn somename(engine_state: &mut EngineState, game_state: &mut GameState) -> bool, where GameState is the user-defined struct passed to rusty_engine::init!(), or () if nothing was passed in.
Actor::build has been replaced by Sprite::new, which must be used to create a Sprite instead of defining a struct literal (enforced via private phantom data). The Default implementation has been removed because of the previous restriction.
Actor.preset has been removed
Actor.filename (a String) has been replaced with Sprite.filepath (a PathBuf)
The builder methods Actor::set_collision and Actor::set_collider have been removed since we never ended up adopting a builder pattern.
Sprite.collider_filepath has been added
Sprite::write_collider has been added (see note below about changes to colliders)
TextActor.text is now Text.value for similar reasons.
Sprites may now be created with either a SpritePreset or the path to an image file via both Sprite::new or EngineState::add_sprite
SpritePreset::build_from_name and SpritePreset::build have been removed (see note above about the new, more flexible way to create sprites)
SpritePreset::collider() has been removed since colliders are no longer hard-coded features of presets (see note below about changes to colliders)
SpritePreset::filename -> String has been replaced by SpritePreset::filepath -> PathBuf, which powers the impl From<SpritePreset> for PathBuf implementation.
Colliders are now loaded from collider files. Collider files use the Rusty Object Notation (RON) format. The easiest way to create a collider is to run the collider_creator example by cloning the rusty_engine repository and running cargo run --release --example collider_creator relative/path/to/my/image.png. The image needs to be somewhere inside the assets/ directory. You could also create the collider programmatically, set it on the Sprite struct, and call the sprite's write_collider() method. Or you could copy an existing collider file, name it the same as your image file (but with the .collider extension) and change it to match your image. Collider coordinates need to define a convex polygon with points going in clockwise order. Coordinates are floating point values relative to the center of the image, with the center of the image being (0.0, 0.0).
All sprites' colliders in the asset pack have been recreated more cleanly using the new collider_creator example
Collider now implements PartialEq, Serialize, and Deserialize
Collider::is_convex was added to make it easier to tell if you have a convex collider.
The collider_creator example was added to make it easy to load a sprite and make a collider file for it. Place your image file (let's call it my_image.png) anywhere inside your local clone of the Rusty Engine assets/ directory and then run the example: cargo run --release --example collider_creator -- assets/my_image.png. Afterwards, copy the image file and the new collider file my_image.collider file over to the assets directory of your own project.
You can now toggle debug rendering of colliders by setting EngineState.debug_sprite_colliders to true. The collision example will now toggle that value when you press the C key.
Circular colliders no longer have duplicate starting and ending coordinates
The pro (and con) of doing a bunch of work that's primarily for yourself is that you occassionally end up doing a wee bit more than you originally intended to do in a single pull request. 😊
The changes...extracted from the changelog diff:
GameState::add_actor
has been renamed toEngineState::add_sprite
GameState::add_text_actor
has been renamed toEngineState::add_text
GameState.screen_dimensions
, which was set at startup and never updated, has been replaced byEngineState.window_dimensions
, which is updated every frame so resizing the window can be handled in your game logic.fn somename(engine_state: &mut EngineState, game_state: &mut GameState) -> bool
, whereGameState
is the user-defined struct passed torusty_engine::init!()
, or()
if nothing was passed in.Actor::build
has been replaced bySprite::new
, which must be used to create aSprite
instead of defining a struct literal (enforced via private phantom data). TheDefault
implementation has been removed because of the previous restriction.Actor.preset
has been removedActor.filename
(aString
) has been replaced withSprite.filepath
(aPathBuf
)Actor::set_collision
andActor::set_collider
have been removed since we never ended up adopting a builder pattern.Sprite.collider_filepath
has been addedSprite::write_collider
has been added (see note below about changes to colliders)TextActor.text
is nowText.value
for similar reasons.Sprite
s may now be created with either aSpritePreset
or the path to an image file via bothSprite::new
orEngineState::add_sprite
SpritePreset::build_from_name
andSpritePreset::build
have been removed (see note above about the new, more flexible way to create sprites)SpritePreset::collider()
has been removed since colliders are no longer hard-coded features of presets (see note below about changes to colliders)SpritePreset::filename -> String
has been replaced bySpritePreset::filepath -> PathBuf
, which powers theimpl From<SpritePreset> for PathBuf
implementation.collider_creator
example by cloning therusty_engine
repository and runningcargo run --release --example collider_creator relative/path/to/my/image.png
. The image needs to be somewhere inside theassets/
directory. You could also create the collider programmatically, set it on theSprite
struct, and call the sprite'swrite_collider()
method. Or you could copy an existing collider file, name it the same as your image file (but with the.collider
extension) and change it to match your image. Collider coordinates need to define a convex polygon with points going in clockwise order. Coordinates are floating point values relative to the center of the image, with the center of the image being (0.0, 0.0).collider_creator
exampleCollider
now implementsPartialEq
,Serialize
, andDeserialize
Collider::is_convex
was added to make it easier to tell if you have a convex collider.collider_creator
example was added to make it easy to load a sprite and make a collider file for it. Place your image file (let's call itmy_image.png
) anywhere inside your local clone of the Rusty Engineassets/
directory and then run the example:cargo run --release --example collider_creator -- assets/my_image.png
. Afterwards, copy the image file and the new collider filemy_image.collider
file over to the assets directory of your own project.EngineState.debug_sprite_colliders
totrue
. Thecollision
example will now toggle that value when you press theC
key.Part of #16