summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorjussi2022-03-10 17:53:43 +0200
committerjussi2022-03-10 17:53:43 +0200
commit26a11a4b7f32a6fc2d131e4c78fe1ca40cc6ac8a (patch)
treeb6fc68889bf5df58ba3455e6d64da6b2f78d38de /examples
parentdebe4baa8c208458f847dd4c89c17f7cc39be559 (diff)
downloadreilua-enhanced-26a11a4b7f32a6fc2d131e4c78fe1ca40cc6ac8a.tar.gz
reilua-enhanced-26a11a4b7f32a6fc2d131e4c78fe1ca40cc6ac8a.tar.bz2
reilua-enhanced-26a11a4b7f32a6fc2d131e4c78fe1ca40cc6ac8a.zip
Measure text.
Diffstat (limited to 'examples')
-rw-r--r--examples/bunnymark/main.lua6
-rw-r--r--examples/gui/main.lua1
-rw-r--r--examples/window/main.lua9
3 files changed, 11 insertions, 5 deletions
diff --git a/examples/bunnymark/main.lua b/examples/bunnymark/main.lua
index 50b8f11..8672887 100644
--- a/examples/bunnymark/main.lua
+++ b/examples/bunnymark/main.lua
@@ -10,7 +10,7 @@ Bunny.__index = Bunny
function Bunny:new( pos, spd, col )
local bunny = {}
- setmetatable( bunny,Bunny )
+ setmetatable( bunny, Bunny )
bunny.position = pos
bunny.speed = spd
bunny.color = col
@@ -24,7 +24,7 @@ local texSize = { 0, 0 }
local texBunny = -1
local bunnies = {}
-function Bunny:update( texture )
+function Bunny:update()
self.position[1] = self.position[1] + self.speed[1]
self.position[2] = self.position[2] + self.speed[2]
@@ -65,7 +65,7 @@ function process( delta )
end
-- Update bunnies
for i = 1, #bunnies do
- bunnies[i]:update( texBunny )
+ bunnies[i]:update()
end
end
diff --git a/examples/gui/main.lua b/examples/gui/main.lua
index 079bd95..c799cdb 100644
--- a/examples/gui/main.lua
+++ b/examples/gui/main.lua
@@ -31,6 +31,7 @@ function draw()
if RL_GuiButton( { 112, 16, 96, 32 }, "Button" ) then
print( "Button pressed!" )
+ RL_CloseWindow()
end
if windowOpen and RL_GuiWindowBox( { 300, 16, 200, 320 }, "Window" ) then
diff --git a/examples/window/main.lua b/examples/window/main.lua
index ec25dd3..44d9fa7 100644
--- a/examples/window/main.lua
+++ b/examples/window/main.lua
@@ -1,5 +1,7 @@
local textColor = BLACK
local textPos = { 192, 200 }
+local imageFont = -1
+local text = "Congrats! You created your first window!"
function init()
RL_SetWindowTitle( "First window" )
@@ -7,8 +9,11 @@ end
function process( delta )
if RL_IsKeyPressed( KEY_ENTER ) then
+ local textSize = RL_MeasureText( 0, text, 20, 2 )
+ local winSize = RL_GetWindowSize()
+
textColor = BLUE
- textPos = { 230, 230 }
+ textPos = { winSize[1] / 2 - textSize[1] / 2, winSize[2] / 2 - textSize[2] / 2 }
end
if RL_IsKeyPressed( KEY_SPACE ) then
@@ -19,5 +24,5 @@ end
function draw()
RL_ClearBackground( RAYWHITE )
- RL_DrawText( 0, "Congrats! You created your first window!", textPos, 20, 2, textColor )
+ RL_DrawText( 0, text, textPos, 20, 2, textColor )
end