Ayin 👁️‍🗨️ ------- Programming language and games in 1 week inspired by Langjam Gamejam. This is hackaton code. Don't expect much. ## Main ideas - Tiny procedural language specifically for gamedev - Wrapped by a game framework - Only user input is controller input (or specific keyboard keys) - Basic types: int, float, string, bool, objects, arrays, first-class functions - if, loop, break, return - ✨Live code reload✨ ## Basic example ```rs let migrate = fn(state) { state } let setup = fn() { return { .color: { .r: 0, .g: 0, .b: 100, }, } } let update = fn(state, input) { let x = if input.gamepad1.dpad.up { 1 } else { 0 } + if input.gamepad1.dpad.down { -1 } else { 0 } let new_blue = state.color.b + x state.color.b = min(255, max(0, new_blue)) } let draw = fn(state) { frame_clear(state.color.r, state.color.g, state.color.b) } let min = fn(a,b) { if a < b { a } else { b } } let max = fn(a,b) { if a < b { b } else { a } } ``` ## Program interface A program is consists of 4 functions. - `let setup = fn() -> state` - create a state object for your program. Runs at the start of the program. - `let update = fn(state, input)` - update the state using user inputs at each game loop cycle. - `let draw = fn(state)` - draw the state to the screen at the end of each game loop cycle. - `let migrate = fn(state) -> state'` - update the game state to a new start, runs on live reloading. ### Live reloading - Live code reloading watches the file for changes and updates the code between game loop cycles while keeping the state. - The `migrate` function is used to migrate the state value for when the structure of the state changes. ## Build instructions ### Non-web To run There-she-is: ``` make run ``` On Fedora, required for hot code reloading: ``` sudo dnf install systemd-devel ``` ### WASM Requires to build for wasm: ``` rustup target add wasm32-unknown-unknown ``` ``` make wasm ``` Go to `html/` and start a web server.