From 7e78a0e2191cc1934bb5e66ac1a4ff22c592c5dd Mon Sep 17 00:00:00 2001 From: Jason Hilder Date: Mon, 28 Sep 2026 08:03:31 +0200 Subject: [PATCH] Changing to a pixel art style with crt bg. --- src/game.odin | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/src/game.odin b/src/game.odin index 59c7471..c5b0bc0 100644 --- a/src/game.odin +++ b/src/game.odin @@ -3,8 +3,10 @@ package game import "core:strings" import rl "vendor:raylib" -VIEWPORT_W :: 1280 -VIEWPORT_H :: 720 +// VIEWPORT_W :: 1280 +// VIEWPORT_H :: 720 +VIEWPORT_W :: 640 +VIEWPORT_H :: 360 WINDOW_TITLE :: "Pong" Resolution :: struct { @@ -22,10 +24,11 @@ RESOLUTIONS := [?]Resolution{ } Game :: struct { - viewport: rl.RenderTexture2D, - scene_stack: [dynamic]Scene, - should_close: bool, - audio: Audio_Manager, + viewport: rl.RenderTexture2D, + bg_texture: rl.Texture2D, + scene_stack: [dynamic]Scene, + should_close: bool, + audio: Audio_Manager, // resolution state window_w: i32, @@ -61,6 +64,18 @@ game_init :: proc(game: ^Game) { game.scene_stack = make([dynamic]Scene, 0, 8) game.viewport = rl.LoadRenderTexture(VIEWPORT_W, VIEWPORT_H) + + // Force nearest neighbor point filtering on the viewport texture + rl.SetTextureFilter(game.viewport.texture, .POINT) + + // Generate soft CRT background radial texture once on startup + bg_center := rl.Color{22, 28, 36, 255} + bg_corner := rl.Color{6, 8, 12, 255} + bg_img := rl.GenImageGradientRadial(VIEWPORT_W, VIEWPORT_H, 0.3, bg_center, bg_corner) + game.bg_texture = rl.LoadTextureFromImage(bg_img) + rl.UnloadImage(bg_img) // Free CPU memory + // rl.SetTextureFilter(game.bg_texture, .BILINEAR) + game.should_close = false set_root_scene(game, make_main_menu()) } @@ -86,8 +101,8 @@ game_render :: proc(game: ^Game) { rl.ClearBackground(rl.BLACK) rl.BeginTextureMode(game.viewport) - rl.ClearBackground(rl.BLACK) - + rl.DrawTexture(game.bg_texture, 0, 0, rl.WHITE) + // @note: fine for now but probably not a good idea... // Render all scenes in the stack from bottom to top for i in 0 ..< len(game.scene_stack) { @@ -98,6 +113,7 @@ game_render :: proc(game: ^Game) { render_game_to_window(game) + rl.DrawFPS(10, game.window_h - 20) rl.EndDrawing() } @@ -105,6 +121,7 @@ game_render :: proc(game: ^Game) { game_quit :: proc(game: ^Game) { audio_manager_quit(&game.audio) + rl.UnloadTexture(game.bg_texture) rl.UnloadRenderTexture(game.viewport) delete(GLOBAL_EVENTS) delete(game.scene_stack) @@ -149,4 +166,5 @@ render_game_to_window :: proc(game: ^Game) { 0, rl.WHITE, ) + } \ No newline at end of file