From c9ebe23d6282e96b410dc7687e0be1c4f3ba1b4d Mon Sep 17 00:00:00 2001 From: jussi Date: Thu, 21 Nov 2024 23:25:28 +0200 Subject: RL.config and InitWindow. --- examples/snake/main.lua | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'examples/snake/main.lua') diff --git a/examples/snake/main.lua b/examples/snake/main.lua index fe30403..f88794f 100644 --- a/examples/snake/main.lua +++ b/examples/snake/main.lua @@ -13,8 +13,6 @@ local STATE = { TITLE = 0, GAME = 1, OVER = 2 } -- Enum. -- Resources local framebuffer = nil local monitor = 0 -local monitorPos = Vector2:newT( RL.GetMonitorPosition( monitor ) ) -local monitorSize = Vector2:newT( RL.GetMonitorSize( monitor ) ) local winScale = 6 local winSize = Vector2:new( RESOLUTION.x * winScale, RESOLUTION.y * winScale ) local gameState = STATE.GAME @@ -69,16 +67,22 @@ local function setApplePos() end end --- Init. +-- Config. -function RL.init() - RL.SetWindowState( RL.FLAG_WINDOW_RESIZABLE ) - RL.SetWindowState( RL.FLAG_VSYNC_HINT ) - RL.SetWindowSize( winSize ) - RL.SetWindowPosition( { monitorPos.x + monitorSize.x / 2 - winSize.x / 2, monitorPos.y + monitorSize.y / 2 - winSize.y / 2 } ) - RL.SetWindowTitle( "Snake" ) +function RL.config() + RL.SetConfigFlags( RL.FLAG_WINDOW_RESIZABLE ) + RL.SetConfigFlags( RL.FLAG_VSYNC_HINT ) + RL.InitWindow( winSize, "Snake" ) RL.SetWindowIcon( RL.LoadImage( RL.GetBasePath().."../resources/images/apple.png" ) ) + local monitorPos = Vector2:newT( RL.GetMonitorPosition( monitor ) ) + local monitorSize = Vector2:newT( RL.GetMonitorSize( monitor ) ) + RL.SetWindowPosition( { monitorPos.x + monitorSize.x / 2 - winSize.x / 2, monitorPos.y + monitorSize.y / 2 - winSize.y / 2 } ) +end + +-- Init. + +function RL.init() framebuffer = RL.LoadRenderTexture( RESOLUTION ) grassTexture = RL.LoadTexture( RL.GetBasePath().."../resources/images/grass.png" ) snakeTexture = RL.LoadTexture( RL.GetBasePath().."../resources/images/snake.png" ) -- cgit v1.2.3