package game import rl "vendor:raylib" Game :: struct { assets: Asset_Manager, camera: rl.Camera2D, world: rl.RenderTexture2D, player: Player } game_init :: proc() -> Game { game := Game{} rl.InitWindow(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_TITLE) rl.SetTargetFPS(60) game.assets = asset_manager_init() game.player = player_init(&game.assets.player) game.camera = camera_init(game.player, 1) game.world = rl.LoadRenderTexture(GAME_WIDTH, GAME_HEIGHT) return game } game_should_run :: proc(game: ^Game) -> bool { return !rl.WindowShouldClose() } game_update :: proc(game: ^Game) { update_player(&game.player, &game.assets.player) update_camera(game.player.pos, &game.camera) } game_draw :: proc(game: ^Game) { rl.BeginTextureMode(game.world) rl.ClearBackground(rl.BLACK) rl.BeginMode2D(game.camera) draw_camera(&game.camera) renderer_draw_player(&game.player) rl.EndMode2D() rl.EndTextureMode() rl.BeginDrawing() rl.ClearBackground(rl.BLACK) rl.DrawTexturePro( game.world.texture, rl.Rectangle{ x = 0, y = 0, width = f32(game.world.texture.width), // raylib opengl negative to flip Y? height = -f32(game.world.texture.height), }, rl.Rectangle{ x = 0, y = 0, width = f32(rl.GetScreenWidth()), height = f32(rl.GetScreenHeight()), }, rl.Vector2{}, 0, rl.WHITE, ) // Debug functions // --------- debug_fps() rl.EndDrawing() } game_close :: proc(game: ^Game) { asset_manager_destroy(&game.assets) rl.UnloadRenderTexture(game.world) rl.CloseWindow() }