Skip to content

Instantly share code, notes, and snippets.

View azriel91's full-sized avatar
🤍
instilling peace

Azriel Hoh azriel91

🤍
instilling peace
View GitHub Profile
@azriel91
azriel91 / how_to_write_a_good_cli_application.md
Last active January 8, 2020 11:08
Notes on how to write a good CLI application

How To Write A Good CLI Application

Modes

  • Interactive: For humans.
  • Non-interactive: For computers.

Interactive Mode

  • Print informatives to stderr.

Keybase proof

I hereby claim:

  • I am azriel91 on github.
  • I am azriel91 (https://keybase.io/azriel91) on keybase.
  • I have a public key ASDjThflIFQ4rkXraacbtts1GCRtfiTc1eEcd75gOPK6BAo

To claim this, I am signing this object:

@azriel91
azriel91 / colour_sprite_sheet_gen.rs
Created August 29, 2019 21:02
Colour sprite sheet generator
use std::ptr;
use amethyst::renderer::{
loaders::load_from_srgba,
palette::Srgba,
rendy::{
hal::image::{Filter, Kind, SamplerInfo, ViewKind, WrapMode},
texture::{pixel::Rgba8Srgb, TextureBuilder},
},
types::TextureData,
// Put this somewhere
#[derive(Debug)]
struct WaitForLoad;
impl<T, E> State<T, E> for WaitForLoad
where
T: GameUpdate,
E: Send + Sync + 'static,
{
fn update(&mut self, data: StateData<'_, T>) -> Trans<T, E> {
data.data.update(&data.world);

Scenario

There are many different game object types: Character, Energy, Weapon. Each of these have different sequence IDs -- essentially named states in a finite state machine (FSM).

To a game modder, it would be simpler to define these like the following:

sequences:
 stand: # sequence 0
@azriel91
azriel91 / ecs_object_states_and_animations.md
Last active December 2, 2019 21:32
ECS: Object States and Animations

ECS: Object States and Animations

This post covers how game object behaviour and animations are done in [Will].

Disclaimer:

My professional experience has been in enterprise software, system administration, and automation. Anything in this blog post is largely personal development experience, and may differ from recommendations from game development studios.

Will is built on the [Amethyst] game engine, which uses the [specs] ECS library. This post assumes existing understanding of the difference between an object-oriented data layout (hierarchical), and the ECS data layout (relational).

@azriel91
azriel91 / logic_clock.rs
Created June 29, 2019 04:17
Logical clock that has a value and limit.
use amethyst::ecs::{storage::DenseVecStorage, Component};
use derive_new::new;
use serde::{Deserialize, Serialize};
use specs_derive::Component;
/// Logical clock that has a value and limit.
#[derive(
Clone, Component, Copy, Debug, Default, Deserialize, Hash, PartialEq, Eq, Serialize, new,
)]
pub struct LogicClock {

Atelier Assets Example Feedback

  • Need to install capnproto: https://capnproto.org/install.html

    1. Download the Zip file from the page.

    2. Extract to somewhere such as D:\apps.

    3. Add D:\apps\capnproto-tools-win32-0.7.0 to your PATH.

      I added it to the system PATH because it's used by my CI.

@azriel91
azriel91 / object_asset_loading_system.rs
Created June 6, 2019 05:01
Loads game object assets.
use std::{collections::HashMap, fmt::Debug, mem, path::PathBuf};
use amethyst::{
assets::{AssetStorage, Handle, Loader, Prefab, PrefabLoader, ProgressCounter},
ecs::{Read, ReadExpect, System, Write},
renderer::{SpriteSheet, Texture},
};
use asset_loading::{AssetDiscovery, TomlFormat};
use asset_model::config::{AssetIndex, AssetRecord};
use derivative::Derivative;
@azriel91
azriel91 / object_definition_to_wrapper_processor.rs
Created June 4, 2019 07:17
Loads `XObjectWrapper` from `XObjectDefinition`.
use std::{marker::PhantomData, ops::Deref, sync::Arc};
use amethyst::{
assets::{AssetStorage, HotReloadStrategy, Loader, ProcessingState},
core::Time,
ecs::{Read, ReadExpect, System, Write},
};
use collision_model::config::{Body, Interactions};
use derivative::Derivative;
use derive_new::new;