~ntgg/snake-zig

ebb4eb39beb70492ebb0a788c0d3a504f365978c — Noah Graff 11 months ago a5d2874 pre-0.5
free memory in pause state
1 files changed, 5 insertions(+), 2 deletions(-)

M src/game_state.zig
M src/game_state.zig => src/game_state.zig +5 -2
@@ 73,9 73,8 @@ pub const State = union(enum) {
    fn deinit(state: *State) void {
        switch (state.*) {
            .Playing => |*s| s.deinit(),
            .Paused => |*s| s.deinit(),
            else => {},
            // .Paused => |*s| s.deinit(),
            // .GameOver => |*s| s.deinit(),
        }
    }
};


@@ 195,6 194,10 @@ pub const PausedState = struct {
        graphics.drawCenteredText(&ctx.gfx, "Press escape to resume", 1, 4.0);
        graphics.drawCenteredText(&ctx.gfx, "Press space to go to the main menu", 2, 4.0);
    }

    pub fn deinit(state: *PausedState) void {
        state.playing_state.deinit();
    }
};

pub const SpriteIdx = enum(u4) {