I'm struggling to make a working switch statement for Color type, I've tried this:
game_state.color = switch (game_state.color.toInt()) {
rl.Color.lime.toInt() => rl.Color.purple,
rl.Color.purple.toInt() => rl.Color.magenta,
rl.Color.magenta.toInt() => rl.Color.black,
rl.Color.black.toInt() => rl.Color.lime,
else => unreachable,
};
It fails because .toInt() tries to call external C function, and can't do so at compile time.
I also tried like this:
game_state.color = switch (game_state.color) {
rl.Color.lime => rl.Color.purple,
rl.Color.purple => rl.Color.magenta,
rl.Color.magenta => rl.Color.black,
rl.Color.black => rl.Color.lime,
else => unreachable,
};
But zig can't switch on extern types, here's error for that one:
src/game.zig:99:46: error: switch on type 'raylib.Color'
game_state.color = switch (game_state.color) {
~~~~~~~~~~^~~~~~
/home/bleb1k/.cache/zig/p/122058d3ea6318efb819d0bffba630afd1a459fa3a99b4bfe4b680a937d5de04d2fc/lib/raylib.zig:719:26: note: struct declared here
pub const Color = extern struct {
~~~~~~~^~~~~~
I'm struggling to make a working switch statement for Color type, I've tried this:
It fails because
.toInt()tries to call external C function, and can't do so at compile time.I also tried like this:
But zig can't switch on extern types, here's error for that one: