summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorjussi2023-11-03 23:12:55 +0200
committerjussi2023-11-03 23:12:55 +0200
commitd74a505d406faf276a265beaf8925d6e8ff9cec0 (patch)
tree72de6e187e0e745f21a9190f5d02895fcecaf83c /examples
parente61823b8bb69e258370503df7969e4e3c2089e2d (diff)
downloadreilua-enhanced-d74a505d406faf276a265beaf8925d6e8ff9cec0.tar.gz
reilua-enhanced-d74a505d406faf276a265beaf8925d6e8ff9cec0.tar.bz2
reilua-enhanced-d74a505d406faf276a265beaf8925d6e8ff9cec0.zip
Compress/decompress and Encode/Decode DataBase64.
Diffstat (limited to 'examples')
-rw-r--r--examples/compress_data/main.lua43
-rw-r--r--examples/heightmap/main.lua16
-rw-r--r--examples/resources/lib/gui.lua8
-rw-r--r--examples/resources/lib/utillib.lua7
4 files changed, 64 insertions, 10 deletions
diff --git a/examples/compress_data/main.lua b/examples/compress_data/main.lua
new file mode 100644
index 0000000..bf6c162
--- /dev/null
+++ b/examples/compress_data/main.lua
@@ -0,0 +1,43 @@
+local textColor = RL.BLACK
+local text = "Put data here"
+local deCompressedText = ""
+local editMode = false
+
+function RL.init()
+ RL.SetWindowTitle( "Buffer" )
+ RL.SetWindowState( RL.FLAG_VSYNC_HINT )
+end
+
+local function compressDecompressData()
+ local strT = {}
+
+ for i = 1, #text do
+ table.insert( strT, string.byte( text:sub( i, i ) ) )
+ end
+
+ local strBuffer = RL.LoadBuffer( strT, RL.BUFFER_UNSIGNED_CHAR )
+ local compBuffer = RL.CompressData( strBuffer )
+ local deCompBuffer = RL.DecompressData( compBuffer )
+
+ deCompressedText = ""
+
+ for _, c in ipairs( RL.GetBufferData( deCompBuffer ) ) do
+ deCompressedText = deCompressedText..string.char( c )
+ end
+end
+
+function RL.draw()
+ RL.ClearBackground( RL.RAYWHITE )
+ RL.DrawText( "Decompressed text: "..deCompressedText, { 20, 200 }, 20, textColor )
+
+ if RL.GuiButton( { 20, 20, 168, 32 }, "Compress/Decompress Data" ) then
+ compressDecompressData()
+ end
+
+ local pressed = false
+ pressed, text = RL.GuiTextBox( { 220, 20, 400, 32 }, text, 64, editMode )
+
+ if pressed then
+ editMode = not editMode
+ end
+end
diff --git a/examples/heightmap/main.lua b/examples/heightmap/main.lua
index aa693fb..51bb153 100644
--- a/examples/heightmap/main.lua
+++ b/examples/heightmap/main.lua
@@ -9,13 +9,12 @@ local TILE_SIZE = 32
local monitor = 0
local camera = {}
-local groundRenderTexture = -1
-local groundTexture = -1
-local tilesetTex = -1
-local heigthImage = -1
-local mesh = -1
-local material = -1
-local lightmap = -1
+local groundRenderTexture = nil
+local groundTexture = nil
+local tilesetTex = nil
+local heigthImage = nil
+local mesh = nil
+local material = nil
local grassRec = { 6 * TILE_SIZE, 0 * TILE_SIZE, TILE_SIZE, TILE_SIZE }
local dirtRec = { 4 * TILE_SIZE, 0 * TILE_SIZE, TILE_SIZE, TILE_SIZE }
@@ -77,8 +76,6 @@ function RL.init()
RL.EndTextureMode()
material = RL.LoadMaterialDefault()
- -- RL.GenTextureMipmaps( groundTexture )
- -- RL.SetTextureFilter( groundTexture, RL.TEXTURE_FILTER_TRILINEAR )
RL.SetMaterialTexture( material, RL.MATERIAL_MAP_ALBEDO, groundTexture )
matrix = RL.MatrixMultiply( RL.MatrixIdentity(), RL.MatrixTranslate( { -4, 0, -4 } ) )
@@ -101,6 +98,5 @@ function RL.draw()
camera:beginMode3D()
RL.DrawMesh( mesh, material, matrix )
- -- camera:draw()
camera:endMode3D()
end
diff --git a/examples/resources/lib/gui.lua b/examples/resources/lib/gui.lua
index 996001c..4e3b744 100644
--- a/examples/resources/lib/gui.lua
+++ b/examples/resources/lib/gui.lua
@@ -822,6 +822,14 @@ function Container:delete()
Gui.delete( self )
end
+function Container:clear()
+ for _, cell in ipairs( self.cells ) do
+ cell:delete()
+ end
+
+ self.cells = {}
+end
+
function Container:set2Top()
Gui.set2Top( self )
diff --git a/examples/resources/lib/utillib.lua b/examples/resources/lib/utillib.lua
index 94e33f9..899f899 100644
--- a/examples/resources/lib/utillib.lua
+++ b/examples/resources/lib/utillib.lua
@@ -146,6 +146,13 @@ function utillib.printt( t )
print( "}" )
end
+function utillib.colorLerp( a, b, f )
+ return {
+ utillib.round( utillib.lerp( a[1], b[1], f ) ),
+ utillib.round( utillib.lerp( a[2], b[2], f ) ),
+ utillib.round( utillib.lerp( a[3], b[3], f ) ) }
+end
+
-- Move secuence of elements inside table.
function utillib.tableMove( t, src, len, dest )
local copy = table.move( t, src, src + len - 1, 1, {} )