diff options
| author | Nguyễn Gia Phong <mcsinyx@disroot.org> | 2021-10-20 23:19:17 +0700 |
|---|---|---|
| committer | Nguyễn Gia Phong <mcsinyx@disroot.org> | 2021-10-20 23:19:17 +0700 |
| commit | bd321d051ca8c827a5c8a490afc33812e76abba7 (patch) | |
| tree | de88e5b28345672d952c5cf988dd05b4339aaa74 /src/main.zig | |
| parent | 446f5c5fd7cd977f096cd2d6256d829a765467c9 (diff) | |
| download | blackshades-bd321d051ca8c827a5c8a490afc33812e76abba7.tar.gz | |
Move scores tracking to user data
Diffstat (limited to 'src/main.zig')
| -rw-r--r-- | src/main.zig | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/main.zig b/src/main.zig index 57ac609..4e93a8a 100644 --- a/src/main.zig +++ b/src/main.zig @@ -23,6 +23,7 @@ pub const c = @cImport({ const Loca = @import("loca").Loca; const Window = gf.Window; +const Scores = misc.Scores; const al = @import("zeal"); const allocator = std.heap.c_allocator; const configuration = @import("config.zig"); @@ -30,6 +31,8 @@ const free = std.c.free; const gf = @import("gfz"); const gl = @import("zgl"); const misc = @import("misc.zig"); +const loadScores = misc.loadScores; +const saveScores = misc.saveScores; const std = @import("std"); var game: *c.Game = undefined; @@ -63,7 +66,11 @@ pub fn main() !void { "Black Shades", .{}, .{}); try window.makeCurrent(); - game = c.makeGame(@bitCast(c.Config, config)).?; + game = c.makeGame(@bitCast(c.Config, config), + @bitCast(c.Scores, try loadScores(loca.user_data))).?; + defer saveScores(loca.user_data, @bitCast(Scores, c.getScores(game))) + catch unreachable; + try window.setSizeCallback(resizeWindow); try gf.swapInterval(@boolToInt(config.vsync)); c.initGl(game); |
