note: This is not a syntax proposal, the colour of the shed can be decided later if this is actually accepted.
Where I want to use this my game stuff/ecs.
Given two separate types,
const Player = struct { x: u16, y: u16, z: u16, hp: u16 };note: This is not a syntax proposal, the colour of the shed can be decided later if this is actually accepted.
Where I want to use this my game stuff/ecs.
Given two separate types,
const Player = struct { x: u16, y: u16, z: u16, hp: u16 };| package main | |
| import ( | |
| "os" | |
| "os/exec" | |
| "reflect" | |
| "runtime" | |
| ) | |
| func main() { |
| data: Data = undefined, | |
| len: Length, | |
| systems: Systems = .{}, | |
| /// Run all systems for a single logical game update. | |
| pub fn update(ecs: *EntityComponentSystem, dt: f64) void { | |
| inline for (@typeInfo(Systems).Struct.fields) |field| { | |
| @field(ecs.systems, field.name).run(&ecs.data, &ecs.len, dt); | |
| } | |
| } |
| import math | |
| import random | |
| from typing import List, Any, Dict, Union | |
| random.seed(0xcafebabedeadbeef) # ensure reproducible results | |
| # ---- infinite axis utility system ----- | |
| # The framework which you'll only need to write once |
| // How to write your very own MMO --- an introduction to multiplayer game design | |
| // Copyright © 2023 Simon A. Nielsen Knights <[email protected]> | |
| // SPDX-License-Identifier: AGPL-3.0-only | |
| // | |
| // This program is free software: you can redistribute it and/or modify | |
| // it under the terms of the GNU Affero General Public License as | |
| // published by the Free Software Foundation, either version 3 of the | |
| // License, or (at your option) any later version. | |
| // | |
| // This program is distributed in the hope that it will be useful, |
| Awesome stuff I cannot look at due to clean room design. | |
| # Colour spaces | |
| - https://github.com/nitrogenez/prism |
| const std = @import("std"); | |
| const mem = std.mem; | |
| const testing = std.testing; | |
| const assert = std.debug.assert; | |
| const Allocator = std.mem.Allocator; | |
| const Table = struct { | |
| /// Each row consists of `stride` number of columns of string indices. | |
| rows: std.ArrayListUnmanaged(String) = .{}, |
| // stack over time | |
| // ,-------------, | |
| var outputTable = Table.init(4, allocator); // ,-> | outputTable | | |
| // | |-------------|---, | |
| for (alerts.value.data.alerts) |a| { // | | outputTable | a | stack location of `r` | |
| // | |-------------|---|---, | |
| var r = [_][]u8{ // | | outputTable | a | r | stack location of the fields of `a` when placed in the array of slices passed to `r` -------, | |
| // | |-------------|---|---|-------------------, | | |
| a.labels.instance, // f | | outputTable | a | r | a.labels.instance | | | |
| // |
| const std = @import("std"); | |
| pub fn build(b: *std.Build) void { | |
| const target = b.standardTargetOptions(.{}); | |
| const optimize = b.standardOptimizeOption(.{}); | |
| const exe = b.addExecutable(.{ | |
| .name = "hook", |
| pub fn dispatch(arena: Allocator, cwd: Dir, context: Context, argv: []const [*:0]const u8, comptime hooks: Self) !void { | |
| const basename = fs.path.basename(mem.span(argv[0])); | |
| const command = Self.map.get(basename) orelse return error.UnknownCommand; | |
| switch (command) { | |
| inline else => |tag| { | |
| const com = @field(hooks, @tagName(tag)); | |
| const Fn = @TypeOf(com); | |
| const info = @typeInfo(Fn).Fn; | |
| var tuple: meta.ArgsTuple(Fn) = undefined; |