Added offscreen rendering.

This commit is contained in:
2026-09-09 07:18:31 +02:00
parent a98bbd9c93
commit 324c4240d7
+12 -14
View File
@@ -2,20 +2,17 @@ package game
import rl "vendor:raylib"
WINDOW_TITLE :: "Pong"
// good 16:9 baseline res, scales up to 1080 or 4k clean.
// good 16:9 internal res, window scales up to 1080/4k clean.
VIEWPORT_WIDTH :: 1280
VIEWPORT_HEIGHT :: 720
// Window size is what the viewport scales to
//WINDOW_WIDTH :: 2560
// WINDOW_HEIGHT :: 1440
WINDOW_WIDTH :: 1280
WINDOW_HEIGHT :: 720
WINDOW_WIDTH :: 2560
WINDOW_HEIGHT :: 1440
WINDOW_TITLE :: "Pong"
Game :: struct {
current_scene: Scene,
is_paused: bool,
viewport: rl.RenderTexture2D,
scene: Scene,
paused: bool,
score_player: int,
score_enemy: int,
}
@@ -32,10 +29,11 @@ game_init :: proc(game: ^Game) {
// initial state
game.score_player = 0
game.score_enemy = 0
game.is_paused = false
game.paused = false
game.viewport = rl.LoadRenderTexture(VIEWPORT_WIDTH, VIEWPORT_HEIGHT)
// initial scene (should be menu when setup)
game.current_scene = init_gameplay_scene()
game.scene = init_gameplay_scene()
// init any systems/managers
// game.input_manager = ....
@@ -49,10 +47,10 @@ game_init :: proc(game: ^Game) {
// ------------------------------------------------------------------------------
game_update :: proc(game: ^Game) {
dt := rl.GetFrameTime()
// TODO: Get an input manager here
input := poll_input()
// Update the current scene
scene_update(game, dt)
scene_update(game, input, dt)
}
// ------------------------------------------------------------------------------