From 47ed28b006db71d823cfaa24fa143ab5cfcf279b Mon Sep 17 00:00:00 2001 From: jussi Date: Sun, 25 Feb 2024 14:06:59 +0200 Subject: Added various missing functions. --- README.md | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 1d4bdb4..27da716 100644 --- a/README.md +++ b/README.md @@ -41,27 +41,34 @@ Example of basic "main.lua" file that will show basic windows with text. ```Lua local textColor = RL.BLACK local textPos = { 192, 200 } +local textSize = 20 +local text = "Congrats! You created your first window!" function RL.init() RL.SetWindowTitle( "First window" ) + RL.SetWindowState( RL.FLAG_VSYNC_HINT ) end function RL.update( delta ) if RL.IsKeyPressed( RL.KEY_ENTER ) then - textColor = BLUE - textPos = { 230, 230 } + local winSize = RL.GetScreenSize() + + textSize = RL.MeasureText( text, textSize ) + textColor = RL.BLUE + textPos = { winSize[1] / 2 - textSize[1] / 2, winSize[2] / 2 - textSize[2] / 2 } end if RL.IsKeyPressed( RL.KEY_SPACE ) then - textColor = RL.BLACK + textColor = RL.RED textPos = { 192, 200 } end end function RL.draw() RL.ClearBackground( RL.RAYWHITE ) - RL.DrawText( RL.GetFontDefault(), "Congrats! You created your first window!", textPos, 20, 2, textColor ) + RL.DrawText( text, textPos, textSize, textColor ) end + ``` Application folder structure should be... -- cgit v1.2.3