const std = @import("std"); const SDL = @import("sdl2"); const Game = @import("Game.zig"); pub fn main() !void { const stderr = std.io.getStdErr(); defer stderr.close(); // var gpa = std.heap.GeneralPurposeAllocator(.{}){}; // defer _ = gpa.deinit(); // const allocator = gpa.allocator(); _ = SDL.SDL_Init(SDL.SDL_INIT_VIDEO | SDL.SDL_INIT_EVENTS | SDL.SDL_INIT_AUDIO); defer SDL.SDL_Quit(); var window = SDL.SDL_CreateWindow( "USG", SDL.SDL_WINDOWPOS_CENTERED, SDL.SDL_WINDOWPOS_CENTERED, 1280, 720, SDL.SDL_WINDOW_SHOWN, ) orelse return; defer _ = SDL.SDL_DestroyWindow(window); var renderer = SDL.SDL_CreateRenderer(window, -1, SDL.SDL_RENDERER_PRESENTVSYNC | SDL.SDL_RENDERER_ACCELERATED) orelse return; defer _ = SDL.SDL_DestroyRenderer(renderer); var game = Game.init(renderer); _ = SDL.SDL_SetRenderDrawBlendMode(renderer, SDL.SDL_BLENDMODE_BLEND); mainLoop: while (true) { var ev: SDL.SDL_Event = undefined; while (SDL.SDL_PollEvent(&ev) != 0) { if (ev.type == SDL.SDL_QUIT) break :mainLoop; } _ = SDL.SDL_SetRenderDrawColor(renderer, 231, 247, 255, 0xFF); _ = SDL.SDL_RenderClear(renderer); game.tick(); SDL.SDL_RenderPresent(renderer); } }