Process renamed to update to be more inline with naming of raylib and common convention.

This commit is contained in:
jussi
2024-02-18 15:26:21 +02:00
parent 9de10be468
commit 9b27daefc2
35 changed files with 99 additions and 98 deletions

6
API.md
View File

@@ -2,7 +2,7 @@
## Functions ## Functions
Application needs 'main.lua' or 'main' file as entry point. ReiLua executable will first look it from same directory. Alternatively, path to the folder where "main.lua" is located can be given as argument. There are five Lua functions that the framework will call, 'RL.init', 'RL.process', 'RL.draw', 'RL.event', 'RL.log', and 'RL.exit'. Application needs 'main.lua' or 'main' file as entry point. ReiLua executable will first look it from same directory. Alternatively, path to the folder where "main.lua" is located can be given as argument. There are five Lua functions that the framework will call, 'RL.init', 'RL.update', 'RL.draw', 'RL.event', 'RL.log', and 'RL.exit'.
--- ---
> function RL.init() > function RL.init()
@@ -11,7 +11,7 @@ This function will be called first when 'main.lua' is found
--- ---
> function RL.process( delta ) > function RL.update( delta )
This function will be called every frame during execution. It will get time duration from last frame on argument 'delta' This function will be called every frame during execution. It will get time duration from last frame on argument 'delta'
@@ -19,7 +19,7 @@ This function will be called every frame during execution. It will get time dura
> function RL.draw() > function RL.draw()
This function will be called every frame after process and it should have all rendering related functions. Note: Engine will call Raylib functions 'BeginDrawing()' before this function call and 'EndDrawing()' after it. You can still use RL.BeginDrawing() and RL.EndDrawing() manually from anywhere. This function will be called every frame after update and it should have all rendering related functions. Note: Engine will call Raylib functions 'BeginDrawing()' before this function call and 'EndDrawing()' after it. You can still use RL.BeginDrawing() and RL.EndDrawing() manually from anywhere.
--- ---

View File

@@ -2,7 +2,7 @@
## About ## About
Idea of this project was to bring the power and simplicity of Raylib to easy beginner friendly language like Lua in a very straight forward manner. It is loose binding to Raylib, some functions will not be included and some are added. The idea of pointing "main.lua" file and access functions "init", "process" and "draw" are borrowed from Löve game framework. Idea of this project was to bring the power and simplicity of Raylib to easy beginner friendly language like Lua in a very straight forward manner. It is loose binding to Raylib, some functions will not be included and some are added. The idea of pointing "main.lua" file and access functions "init", "update" and "draw" are borrowed from Löve game framework.
ReiLua is not planned to be a one-to-one binding to raylib. If you want more direct bindings, there are other projects like https://github.com/TSnake41/raylib-lua. ReiLua is not planned to be a one-to-one binding to raylib. If you want more direct bindings, there are other projects like https://github.com/TSnake41/raylib-lua.
@@ -34,7 +34,7 @@ List of some MISSING features that are planned to be included. For specific func
## Usage ## Usage
Application needs 'main.lua' or 'main' file as entry point. ReiLua executable will first look it from same directory. Alternatively, path to the folder where "main.lua" is located can be given as argument. There are five Lua functions that the framework will call, 'RL.init', 'RL.process', 'RL.draw', 'RL.log' and 'RL.exit'. Application needs 'main.lua' or 'main' file as entry point. ReiLua executable will first look it from same directory. Alternatively, path to the folder where "main.lua" is located can be given as argument. There are five Lua functions that the framework will call, 'RL.init', 'RL.update', 'RL.draw', 'RL.log' and 'RL.exit'.
Example of basic "main.lua" file that will show basic windows with text. Example of basic "main.lua" file that will show basic windows with text.
@@ -46,7 +46,7 @@ function RL.init()
RL.SetWindowTitle( "First window" ) RL.SetWindowTitle( "First window" )
end end
function RL.process( delta ) function RL.update( delta )
if RL.IsKeyPressed( RL.KEY_ENTER ) then if RL.IsKeyPressed( RL.KEY_ENTER ) then
textColor = BLUE textColor = BLUE
textPos = { 230, 230 } textPos = { 230, 230 }

View File

@@ -8,8 +8,8 @@ RL={}
function RL.init() end function RL.init() end
---This function will be called every frame during execution. It will get time duration from last frame on argument 'delta' ---This function will be called every frame during execution. It will get time duration from last frame on argument 'delta'
---@param delta number ---@param delta number
function RL.process( delta ) end function RL.update( delta ) end
---This function will be called every frame after process and it should have all rendering related functions. Note: Engine will call Raylib functions 'BeginDrawing()' before this function call and 'EndDrawing()' after it. You can still use RL.BeginDrawing() and RL.EndDrawing() manually from anywhere. ---This function will be called every frame after update and it should have all rendering related functions. Note: Engine will call Raylib functions 'BeginDrawing()' before this function call and 'EndDrawing()' after it. You can still use RL.BeginDrawing() and RL.EndDrawing() manually from anywhere.
function RL.draw() end function RL.draw() end
---This function will be called on events input. Content of event table is determined by event type. ---This function will be called on events input. Content of event table is determined by event type.
---@param event table ---@param event table

View File

@@ -4,6 +4,7 @@ Release: ReiLua version 0.8.0 Using Raylib 5.0 and Forked Raygui 4.0
KEY CHANGES: KEY CHANGES:
- CHANGE: GetBufferData takes also position and length arguments. - CHANGE: GetBufferData takes also position and length arguments.
- ADDED: LoadImageFromData. - ADDED: LoadImageFromData.
- CHANGE: Process renamed to update to be more inline with naming of raylib and common convention.
DETAILED CHANGES: DETAILED CHANGES:
- ADDED: GetBufferElementSize and GetBufferLength. - ADDED: GetBufferElementSize and GetBufferLength.

View File

@@ -20,7 +20,7 @@ Backlog {
* Examples * Examples
* Improve Dungeon crawler example by generating custom mesh instead of drawing 3D quads. * Improve Dungeon crawler example by generating custom mesh instead of drawing 3D quads.
* Platformer example physics process for true framerate independence. * Platformer example physics update for true framerate independence.
* Android support * Android support
* Git submodules for raylib and lua. Should maybe find windows compatible lua repo for this. * Git submodules for raylib and lua. Should maybe find windows compatible lua repo for this.
} }

View File

@@ -89,19 +89,19 @@ apiFile:write( "# ReiLua API\n" )
-- Usage. -- Usage.
apiFile:write( "\n## Functions\n" ) apiFile:write( "\n## Functions\n" )
apiFile:write( "\nApplication needs 'main.lua' or 'main' file as entry point. ReiLua executable will first look it from same directory. Alternatively, path to the folder where \"main.lua\" is located can be given as argument. There are five Lua functions that the framework will call, 'RL.init', 'RL.process', 'RL.draw', 'RL.event', 'RL.log', and 'RL.exit'.\n" ) apiFile:write( "\nApplication needs 'main.lua' or 'main' file as entry point. ReiLua executable will first look it from same directory. Alternatively, path to the folder where \"main.lua\" is located can be given as argument. There are five Lua functions that the framework will call, 'RL.init', 'RL.update', 'RL.draw', 'RL.event', 'RL.log', and 'RL.exit'.\n" )
local FUNC_DESC = { local FUNC_DESC = {
init = "This function will be called first when 'main.lua' is found", init = "This function will be called first when 'main.lua' is found",
process = "This function will be called every frame during execution. It will get time duration from last frame on argument 'delta'", update = "This function will be called every frame during execution. It will get time duration from last frame on argument 'delta'",
draw = "This function will be called every frame after process and it should have all rendering related functions. Note: Engine will call Raylib functions 'BeginDrawing()' before this function call and 'EndDrawing()' after it. You can still use RL.BeginDrawing() and RL.EndDrawing() manually from anywhere.", draw = "This function will be called every frame after update and it should have all rendering related functions. Note: Engine will call Raylib functions 'BeginDrawing()' before this function call and 'EndDrawing()' after it. You can still use RL.BeginDrawing() and RL.EndDrawing() manually from anywhere.",
event = "This function will be called on events input. Content of event table is determined by event type.", event = "This function will be called on events input. Content of event table is determined by event type.",
log = "This function can be used for custom log message handling.", log = "This function can be used for custom log message handling.",
exit = "This function will be called on program close. Cleanup could be done here.", exit = "This function will be called on program close. Cleanup could be done here.",
} }
apiFile:write( "\n---\n> function RL.init()\n\n"..FUNC_DESC.init.."\n\n---\n" ) apiFile:write( "\n---\n> function RL.init()\n\n"..FUNC_DESC.init.."\n\n---\n" )
apiFile:write( "\n> function RL.process( delta )\n\n"..FUNC_DESC.process.."\n\n---\n" ) apiFile:write( "\n> function RL.update( delta )\n\n"..FUNC_DESC.update.."\n\n---\n" )
apiFile:write( "\n> function RL.draw()\n\n"..FUNC_DESC.draw.."\n\n---\n" ) apiFile:write( "\n> function RL.draw()\n\n"..FUNC_DESC.draw.."\n\n---\n" )
apiFile:write( "\n> function RL.event( event )\n\n"..FUNC_DESC.event.."\n\n---\n" ) apiFile:write( "\n> function RL.event( event )\n\n"..FUNC_DESC.event.."\n\n---\n" )
apiFile:write( "\n> function RL.log( logLevel, message )\n\n"..FUNC_DESC.log.."\n\n---\n" ) apiFile:write( "\n> function RL.log( logLevel, message )\n\n"..FUNC_DESC.log.."\n\n---\n" )
@@ -114,7 +114,7 @@ luaApiFile:write( "-- Functions.\n\n" )
luaApiFile:write( luaApiFile:write(
"---"..FUNC_DESC.init.."\nfunction RL.init() end\n" ) "---"..FUNC_DESC.init.."\nfunction RL.init() end\n" )
luaApiFile:write( luaApiFile:write(
"---"..FUNC_DESC.process.."\n---@param delta number\nfunction RL.process( delta ) end\n" ) "---"..FUNC_DESC.update.."\n---@param delta number\nfunction RL.update( delta ) end\n" )
luaApiFile:write( luaApiFile:write(
"---"..FUNC_DESC.draw.."\nfunction RL.draw() end\n" ) "---"..FUNC_DESC.draw.."\nfunction RL.draw() end\n" )
luaApiFile:write( luaApiFile:write(

View File

@@ -5,7 +5,7 @@ local cameraRot = 0.0
local cameraZoom = 1.0 local cameraZoom = 1.0
local cameraSpeed = 100.0 local cameraSpeed = 100.0
local cameraRotSpeed = 100.0 local cameraRotSpeed = 100.0
local cameraZoomSpeed = 10.0 local cameraZoomSpeed = 2.0
function RL.init() function RL.init()
local monitor = 0 local monitor = 0
@@ -23,7 +23,7 @@ function RL.init()
RL.SetCamera2DOffset( camera, { winSize[1] / 2, winSize[2] / 2 } ) RL.SetCamera2DOffset( camera, { winSize[1] / 2, winSize[2] / 2 } )
end end
function RL.process( delta ) function RL.update( delta )
-- Move. -- Move.
if RL.IsKeyDown( RL.KEY_RIGHT ) then if RL.IsKeyDown( RL.KEY_RIGHT ) then
cameraPos[1] = cameraPos[1] + cameraSpeed * delta cameraPos[1] = cameraPos[1] + cameraSpeed * delta
@@ -36,16 +36,16 @@ function RL.process( delta )
cameraPos[2] = cameraPos[2] - cameraSpeed * delta cameraPos[2] = cameraPos[2] - cameraSpeed * delta
end end
-- Rotate. -- Rotate.
if RL.IsKeyDown( RL.KEY_E ) then -- Or RL.IsKeyDown( KEY_E ) if RL.IsKeyDown( RL.KEY_E ) then
cameraRot = cameraRot + cameraRotSpeed * delta cameraRot = cameraRot + cameraRotSpeed * delta
elseif RL.IsKeyDown( RL.KEY_Q ) then elseif RL.IsKeyDown( RL.KEY_Q ) then
cameraRot = cameraRot - cameraRotSpeed * delta cameraRot = cameraRot - cameraRotSpeed * delta
end end
-- Zoom. -- Zoom.
if RL.IsKeyDown( RL.KEY_R ) then if RL.IsKeyDown( RL.KEY_R ) then
cameraZoom = cameraZoom + cameraZoomSpeed * delta cameraZoom = cameraZoom + cameraZoom * cameraZoomSpeed * delta
elseif RL.IsKeyDown( RL.KEY_F ) then elseif RL.IsKeyDown( RL.KEY_F ) then
cameraZoom = cameraZoom - cameraZoomSpeed * delta cameraZoom = cameraZoom - cameraZoom * cameraZoomSpeed * delta
end end
end end

View File

@@ -133,7 +133,7 @@ end
-- Process. -- Process.
function RL.process( delta ) function RL.update( delta )
lights[1].pos = Vector2:new( RL.GetMousePosition() ) lights[1].pos = Vector2:new( RL.GetMousePosition() )
end end

View File

@@ -76,12 +76,12 @@ function RL.init()
initGui() initGui()
end end
function RL.process( delta ) function RL.update( delta )
Gui.process( Vec2:new( RL.GetMousePosition() ) ) Gui.update( Vec2:new( RL.GetMousePosition() ) )
end end
function RL.draw() function RL.draw()
RL.ClearBackground( RL.RAYWHITE ) RL.ClearBackground( RL.RAYWHITE )
Gui.draw() Gui.draw()
end end

View File

@@ -91,8 +91,8 @@ function RL.init()
table.insert( lights, RL.CreateLight( RL.LIGHT_POINT, { 2, 1, -2 }, RL.Vector3Zero(), RL.BLUE, shader ) ) table.insert( lights, RL.CreateLight( RL.LIGHT_POINT, { 2, 1, -2 }, RL.Vector3Zero(), RL.BLUE, shader ) )
end end
function RL.process( delta ) function RL.update( delta )
camera:process( delta ) camera:update( delta )
-- Check key inputs to enable/disable lights. -- Check key inputs to enable/disable lights.
if RL.IsKeyPressed( RL.KEY_Y ) then if RL.IsKeyPressed( RL.KEY_Y ) then

View File

@@ -51,7 +51,7 @@ function RL.init()
texSize = RL.GetTextureSize( texBunny ) texSize = RL.GetTextureSize( texBunny )
end end
function RL.process( delta ) function RL.update( delta )
if RL.IsMouseButtonDown( 0 ) then if RL.IsMouseButtonDown( 0 ) then
-- Create more bunnies -- Create more bunnies
for i = 1, 100 do for i = 1, 100 do

View File

@@ -50,7 +50,7 @@ function RL.init()
end end
end end
function RL.process( delta ) function RL.update( delta )
polygon.angle = polygon.angle + delta polygon.angle = polygon.angle + delta
-- Update points rotation with an angle transform -- Update points rotation with an angle transform

View File

@@ -30,8 +30,8 @@ function RL.init()
camera.mode = camera.MODES.FREE camera.mode = camera.MODES.FREE
end end
function RL.process( delta ) function RL.update( delta )
camera:process( delta ) camera:update( delta )
if RL.IsKeyPressed( RL.KEY_SPACE ) then if RL.IsKeyPressed( RL.KEY_SPACE ) then
if camera.mode == camera.MODES.FREE then if camera.mode == camera.MODES.FREE then

View File

@@ -81,8 +81,8 @@ function RL.init()
matrix = RL.MatrixMultiply( RL.MatrixIdentity(), RL.MatrixTranslate( { -4, 0, -4 } ) ) matrix = RL.MatrixMultiply( RL.MatrixIdentity(), RL.MatrixTranslate( { -4, 0, -4 } ) )
end end
function RL.process( delta ) function RL.update( delta )
camera:process( delta ) camera:update( delta )
if RL.IsKeyPressed( RL.KEY_SPACE ) then if RL.IsKeyPressed( RL.KEY_SPACE ) then
if camera.mode == camera.MODES.FREE then if camera.mode == camera.MODES.FREE then

View File

@@ -82,7 +82,7 @@ function RL.init()
RL.SetMaterialColor( matDefault, RL.MATERIAL_MAP_DIFFUSE, RL.BLUE ) RL.SetMaterialColor( matDefault, RL.MATERIAL_MAP_DIFFUSE, RL.BLUE )
end end
function RL.process( delta ) function RL.update( delta )
RL.UpdateCamera3D( camera, RL.CAMERA_ORBITAL ) RL.UpdateCamera3D( camera, RL.CAMERA_ORBITAL )
-- Update the light shader with the camera view position -- Update the light shader with the camera view position

View File

@@ -49,7 +49,7 @@ function RL.init()
animations = RL.LoadModelAnimations( RL.GetBasePath().."../resources/iqm/monkey.iqm" ) animations = RL.LoadModelAnimations( RL.GetBasePath().."../resources/iqm/monkey.iqm" )
end end
function RL.process( delta ) function RL.update( delta )
if RL.IsKeyPressed( RL.KEY_ENTER ) then if RL.IsKeyPressed( RL.KEY_ENTER ) then
curAnim = curAnim + 1 curAnim = curAnim + 1

View File

@@ -83,8 +83,8 @@ function RL.init()
matrix = RL.MatrixMultiply( RL.MatrixIdentity(), RL.MatrixTranslate( { -4, 0, -4 } ) ) matrix = RL.MatrixMultiply( RL.MatrixIdentity(), RL.MatrixTranslate( { -4, 0, -4 } ) )
end end
function RL.process( delta ) function RL.update( delta )
camera:process( delta ) camera:update( delta )
if RL.IsKeyPressed( RL.KEY_SPACE ) then if RL.IsKeyPressed( RL.KEY_SPACE ) then
if camera.mode == camera.MODES.FREE then if camera.mode == camera.MODES.FREE then

View File

@@ -20,7 +20,7 @@ function RL.init()
RL.SetWindowState( RL.FLAG_VSYNC_HINT ) RL.SetWindowState( RL.FLAG_VSYNC_HINT )
end end
function RL.process( delta ) function RL.update( delta )
local mousePosition = Vec2:new( RL.GetMousePosition() ) local mousePosition = Vec2:new( RL.GetMousePosition() )
-- Resize the n-patch based on mouse position -- Resize the n-patch based on mouse position

View File

@@ -221,7 +221,7 @@ local function playerMovement( delta )
player.colRect.y = player.pos.y - player.colRect.height player.colRect.y = player.pos.y - player.colRect.height
end end
function RL.process( delta ) function RL.update( delta )
if RL.IsWindowResized() then if RL.IsWindowResized() then
winSize:set( RL.GetScreenSize() ) winSize:set( RL.GetScreenSize() )
end end

View File

@@ -69,7 +69,7 @@ function RL.init()
reset() reset()
end end
function RL.process( delta ) function RL.update( delta )
-- Left player controls. -- Left player controls.
if RL.IsKeyDown( RL.KEY_W ) and 0 < playerLeft.pos.y then if RL.IsKeyDown( RL.KEY_W ) and 0 < playerLeft.pos.y then
playerLeft.pos.y = playerLeft.pos.y - PLAYER_SPEED * delta playerLeft.pos.y = playerLeft.pos.y - PLAYER_SPEED * delta

View File

@@ -38,7 +38,7 @@ function RL.init()
ray_collision() ray_collision()
end end
function RL.process( delta ) function RL.update( delta )
if RL.IsMouseButtonPressed( 0 ) then if RL.IsMouseButtonPressed( 0 ) then
ray = RL.GetMouseRay( RL.GetMousePosition(), camera ) ray = RL.GetMouseRay( RL.GetMousePosition(), camera )
ray_collision() ray_collision()

View File

@@ -33,8 +33,8 @@ function RL.init()
calculator2 = Calculator:new( Vec2:new( 64, 65 ) ) calculator2 = Calculator:new( Vec2:new( 64, 65 ) )
end end
function RL.process( delta ) function RL.update( delta )
Gui:process() Gui:update()
end end
function RL.draw() function RL.draw()

View File

@@ -237,8 +237,8 @@ function RL.init()
addPropertyList() addPropertyList()
end end
function RL.process( delta ) function RL.update( delta )
Gui:process() Gui:update()
end end
function RL.draw() function RL.draw()

View File

@@ -158,14 +158,14 @@ function PropertyList:addGroup( name, active, group )
return control return control
end end
function PropertyList:process() function PropertyList:update()
if not RL.CheckCollisionRecs( self.view, RL.GetMousePosition() ) then if not RL.CheckCollisionRecs( self.view, RL.GetMousePosition() ) then
self.gui.locked = true self.gui.locked = true
else else
self.gui.locked = false self.gui.locked = false
end end
self.gui:process() self.gui:update()
RL.BeginTextureMode( self.framebuffer ) RL.BeginTextureMode( self.framebuffer )
RL.ClearBackground( RL.BLANK ) RL.ClearBackground( RL.BLANK )

View File

@@ -19,12 +19,12 @@ function SpriteButton:new( bounds, text, texture, nPatchNormal, nPatchPressed, c
return object return object
end end
function SpriteButton:process() function SpriteButton:update()
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
end end
function SpriteButton:draw() function SpriteButton:draw()
if RL.IsMouseButtonDown( RL.MOUSE_BUTTON_LEFT ) and self:process() and not RL.GuiIsLocked() and not self._parent.scrolling then if RL.IsMouseButtonDown( RL.MOUSE_BUTTON_LEFT ) and self:update() and not RL.GuiIsLocked() and not self._parent.scrolling then
RL.DrawTextureNPatchRepeat( self.buttonTexture, self.nPatchPressed, self.bounds, { 0, 0 }, 0.0, RL.WHITE ) RL.DrawTextureNPatchRepeat( self.buttonTexture, self.nPatchPressed, self.bounds, { 0, 0 }, 0.0, RL.WHITE )
else else
RL.DrawTextureNPatchRepeat( self.buttonTexture, self.nPatchNormal, self.bounds, { 0, 0 }, 0.0, RL.WHITE ) RL.DrawTextureNPatchRepeat( self.buttonTexture, self.nPatchNormal, self.bounds, { 0, 0 }, 0.0, RL.WHITE )

View File

@@ -318,8 +318,8 @@ function RL.init()
) )
end end
function RL.process( delta ) function RL.update( delta )
Gui:process() Gui:update()
end end
function RL.draw() function RL.draw()

View File

@@ -17,7 +17,7 @@ function bitlib.getBit( v, i )
return false return false
end end
return v & ( 1 << i ) > 0 return 0 < v & ( 1 << i )
end end
return bitlib return bitlib

View File

@@ -90,7 +90,7 @@ function Camera3D:getUpward()
return Vec3:new( RL.GetCamera3DUpNormalized( self.camera ) ) return Vec3:new( RL.GetCamera3DUpNormalized( self.camera ) )
end end
function Camera3D:process( delta ) function Camera3D:update( delta )
if self.mode == self.MODES.FREE then if self.mode == self.MODES.FREE then
if RL.IsMouseButtonDown( RL.MOUSE_BUTTON_MIDDLE ) then if RL.IsMouseButtonDown( RL.MOUSE_BUTTON_MIDDLE ) then
local mouseDelta = Vec2:new( RL.GetMouseDelta() ) local mouseDelta = Vec2:new( RL.GetMouseDelta() )

View File

@@ -40,7 +40,7 @@ local Gui = {
heldCallback = nil, heldCallback = nil,
_cells = {}, _cells = {},
_mousePos = Vec2:new( 0, 0 ), -- Last mouse position that was passed to Gui.process. _mousePos = Vec2:new( 0, 0 ), -- Last mouse position that was passed to Gui.Update.
_inputElement = nil, -- Element that has the input text item. _inputElement = nil, -- Element that has the input text item.
_inputItem = nil, -- Must be type Text. _inputItem = nil, -- Must be type Text.
} }
@@ -103,7 +103,7 @@ function Gui.set2Back( cell )
Util.tableMove( Gui._cells, Gui.getId( cell ), 1, 1 ) Util.tableMove( Gui._cells, Gui.getId( cell ), 1, 1 )
end end
function Gui.process( mousePosition ) function Gui.update( mousePosition )
local mouseWheel = RL.GetMouseWheelMove() local mouseWheel = RL.GetMouseWheelMove()
Gui._mousePos = mousePosition Gui._mousePos = mousePosition
@@ -120,7 +120,7 @@ function Gui.process( mousePosition )
local foundFirst = false local foundFirst = false
-- Go backwards on process check so we trigger the top most ui first and stop there. -- Go backwards on update check so we trigger the top most ui first and stop there.
for i = #Gui._cells, 1, -1 do for i = #Gui._cells, 1, -1 do
local cell = Gui._cells[i] local cell = Gui._cells[i]
@@ -875,4 +875,4 @@ Gui.shape = Shape
Gui.element = Element Gui.element = Element
Gui.container = Container Gui.container = Container
return Gui return Gui

View File

@@ -70,7 +70,7 @@ function WindowBox:new( bounds, text, callback, grabCallback, dragCallback, styl
return object return object
end end
function WindowBox:process() function WindowBox:update()
return self._parent:drag( self ) return self._parent:drag( self )
end end
@@ -109,7 +109,7 @@ function GroupBox:new( bounds, text, styles )
return object return object
end end
function GroupBox:process() function GroupBox:update()
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
end end
@@ -142,7 +142,7 @@ function Line:new( bounds, text, styles )
return object return object
end end
function Line:process() function Line:update()
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
end end
@@ -178,7 +178,7 @@ function Panel:new( bounds, text, grabCallback, dragCallback, styles )
return object return object
end end
function Panel:process() function Panel:update()
return self._parent:drag( self ) return self._parent:drag( self )
end end
@@ -214,7 +214,7 @@ function GuiTabBar:new( bounds, text, active, callback, closeCallback, styles )
return object return object
end end
function GuiTabBar:process() function GuiTabBar:update()
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
end end
@@ -271,7 +271,7 @@ function ScrollPanel:new( bounds, text, content, scroll, callback, grabCallback,
return object return object
end end
function ScrollPanel:process() function ScrollPanel:update()
return self._parent:drag( self ) return self._parent:drag( self )
end end
@@ -318,7 +318,7 @@ function Label:new( bounds, text, styles )
return object return object
end end
function Label:process() function Label:update()
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
end end
@@ -352,7 +352,7 @@ function Button:new( bounds, text, callback, styles )
return object return object
end end
function Button:process() function Button:update()
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
end end
@@ -390,7 +390,7 @@ function LabelButton:new( bounds, text, callback, styles )
return object return object
end end
function LabelButton:process() function LabelButton:update()
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
end end
@@ -429,7 +429,7 @@ function Toggle:new( bounds, text, active, callback, styles )
return object return object
end end
function Toggle:process() function Toggle:update()
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
end end
@@ -516,7 +516,7 @@ function ToggleGroup:updateFocusBounds()
end end
end end
function ToggleGroup:process() function ToggleGroup:update()
for _, bounds in ipairs( self.focusBounds ) do for _, bounds in ipairs( self.focusBounds ) do
if RL.CheckCollisionPointRec( RL.GetMousePosition(), bounds ) then if RL.CheckCollisionPointRec( RL.GetMousePosition(), bounds ) then
return true return true
@@ -585,7 +585,7 @@ function CheckBox:new( bounds, text, checked, callback, styles )
return object return object
end end
function CheckBox:process() function CheckBox:update()
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.focusBounds ) return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.focusBounds )
end end
@@ -638,7 +638,7 @@ function ComboBox:new( bounds, text, active, callback, styles )
return object return object
end end
function ComboBox:process() function ComboBox:update()
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
end end
@@ -702,7 +702,7 @@ function DropdownBox:updateEditModeBounds()
self.editModeBounds.height = ( 1 + count ) * ( self.bounds.height + RL.GuiGetStyle( RL.DROPDOWNBOX, RL.DROPDOWN_ITEMS_SPACING ) ) self.editModeBounds.height = ( 1 + count ) * ( self.bounds.height + RL.GuiGetStyle( RL.DROPDOWNBOX, RL.DROPDOWN_ITEMS_SPACING ) )
end end
function DropdownBox:process() function DropdownBox:update()
if self.editMode then if self.editMode then
self:updateEditModeBounds() self:updateEditModeBounds()
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.editModeBounds ) return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.editModeBounds )
@@ -763,7 +763,7 @@ function Spinner:setText( text )
self.text = text self.text = text
end end
function Spinner:process() function Spinner:update()
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
end end
@@ -833,7 +833,7 @@ function ValueBox:setText( text )
self.text = text self.text = text
end end
function ValueBox:process() function ValueBox:update()
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
end end
@@ -887,7 +887,7 @@ function TextBox:new( bounds, text, textSize, editMode, callback, styles )
return object return object
end end
function TextBox:process() function TextBox:update()
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
end end
@@ -948,7 +948,7 @@ function Slider:new( bounds, textLeft, textRight, value, minValue, maxValue, cal
return object return object
end end
function Slider:process() function Slider:update()
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
end end
@@ -1011,7 +1011,7 @@ function SliderBar:new( bounds, textLeft, textRight, value, minValue, maxValue,
return object return object
end end
function SliderBar:process() function SliderBar:update()
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
end end
@@ -1074,7 +1074,7 @@ function ProgressBar:new( bounds, textLeft, textRight, value, minValue, maxValue
return object return object
end end
function ProgressBar:process() function ProgressBar:update()
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
end end
@@ -1126,7 +1126,7 @@ function StatusBar:new( bounds, text, styles )
return object return object
end end
function StatusBar:process() function StatusBar:update()
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
end end
@@ -1159,7 +1159,7 @@ function DummyRec:new( bounds, text, styles )
return object return object
end end
function DummyRec:process() function DummyRec:update()
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
end end
@@ -1196,7 +1196,7 @@ function Grid:new( bounds, text, spacing, subdivs, callback, styles )
return object return object
end end
function Grid:process() function Grid:update()
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
end end
@@ -1248,7 +1248,7 @@ function ListView:getItem( id )
return getItems( self.text )[ id + 1 ] return getItems( self.text )[ id + 1 ]
end end
function ListView:process() function ListView:update()
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
end end
@@ -1299,7 +1299,7 @@ function ListViewEx:getItem( id )
return getItems( self.text )[ id + 1 ] return getItems( self.text )[ id + 1 ]
end end
function ListViewEx:process() function ListViewEx:update()
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
end end
@@ -1353,7 +1353,7 @@ function MessageBox:getItem( id )
return getItems( self.buttons )[ id ] return getItems( self.buttons )[ id ]
end end
function MessageBox:process() function MessageBox:update()
return self._parent:drag( self ) return self._parent:drag( self )
end end
@@ -1404,7 +1404,7 @@ function TextInputBox:getItem( id )
return getItems( self.buttons )[ id ] return getItems( self.buttons )[ id ]
end end
function TextInputBox:process() function TextInputBox:update()
return self._parent:drag( self ) return self._parent:drag( self )
end end
@@ -1446,7 +1446,7 @@ function ColorPicker:new( bounds, text, color, callback, styles )
return object return object
end end
function ColorPicker:process() function ColorPicker:update()
-- self:updateFocusBounds() -- self:updateFocusBounds()
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.focusBounds ) return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.focusBounds )
end end
@@ -1508,7 +1508,7 @@ function ColorPanel:new( bounds, text, color, callback, styles )
return object return object
end end
function ColorPanel:process() function ColorPanel:update()
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
end end
@@ -1557,7 +1557,7 @@ function ColorBarAlpha:new( bounds, text, alpha, callback, styles )
return object return object
end end
function ColorBarAlpha:process() function ColorBarAlpha:update()
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
end end
@@ -1605,7 +1605,7 @@ function ColorBarHue:new( bounds, text, value, callback, styles )
return object return object
end end
function ColorBarHue:process() function ColorBarHue:update()
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
end end
@@ -1654,7 +1654,7 @@ function GuiScrollBar:new( bounds, value, minValue, maxValue, callback, styles )
return object return object
end end
function GuiScrollBar:process() function GuiScrollBar:update()
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
end end
@@ -1703,7 +1703,7 @@ function Raygui:new()
object.defaultRect = Rect:new( 0, 0, 1, 1 ) -- For texture. object.defaultRect = Rect:new( 0, 0, 1, 1 ) -- For texture.
object.defaultFont = RL.GetFontDefault() object.defaultFont = RL.GetFontDefault()
object.mouseOffset = Vec2:new() object.mouseOffset = Vec2:new()
object.view = Rect:new() -- Active if larger than 0. Then only controls in view will be processed and drawn. object.view = Rect:new() -- Active if larger than 0. Then only controls in view will be updated and drawn.
object._lastProperties = {} object._lastProperties = {}
object._mousePressPos = Vec2:new( -1, -1 ) -- Use to check if release and check are inside bounds. object._mousePressPos = Vec2:new( -1, -1 ) -- Use to check if release and check are inside bounds.
@@ -1716,11 +1716,11 @@ function Raygui:inView( control )
return self.view.width == 0 or self.view.height == 0 or self.view:checkCollisionRec( control.viewBounds or control.focusBounds or control.bounds ) return self.view.width == 0 or self.view.height == 0 or self.view:checkCollisionRec( control.viewBounds or control.focusBounds or control.bounds )
end end
function Raygui:process() function Raygui:update()
if self.disabled or self.locked then if self.disabled or self.locked then
return return
end end
-- If dragging, don't process control masking. -- If dragging, don't update control masking.
if self.dragging ~= nil then if self.dragging ~= nil then
self:drag( self.dragging ) self:drag( self.dragging )
return return
@@ -1737,8 +1737,8 @@ function Raygui:process()
for i = #self.controls, 1, -1 do for i = #self.controls, 1, -1 do
local control = self.controls[i] local control = self.controls[i]
if control.visible and control.process ~= nil and self:inView( control ) then if control.visible and control.update ~= nil and self:inView( control ) then
if control:process() then if control:update() then
self.focused = i self.focused = i
return return
end end

View File

@@ -129,7 +129,7 @@ local function moveSnake()
moveTimer = moveTimer + 1.0 moveTimer = moveTimer + 1.0
end end
function RL.process( delta ) function RL.update( delta )
if gameState == STATE.GAME then -- Run game. if gameState == STATE.GAME then -- Run game.
-- Controls. -- Controls.
if RL.IsKeyPressed( RL.KEY_RIGHT ) and 0 <= snake.heading.x then if RL.IsKeyPressed( RL.KEY_RIGHT ) and 0 <= snake.heading.x then

View File

@@ -7,7 +7,7 @@ function RL.init()
RL.SetWindowState( RL.FLAG_VSYNC_HINT ) RL.SetWindowState( RL.FLAG_VSYNC_HINT )
end end
function RL.process( delta ) function RL.update( delta )
if RL.IsKeyPressed( RL.KEY_ENTER ) then if RL.IsKeyPressed( RL.KEY_ENTER ) then
local textSize = RL.MeasureText( RL.GetFontDefault(), text, 20, 2 ) local textSize = RL.MeasureText( RL.GetFontDefault(), text, 20, 2 )
local winSize = RL.GetScreenSize() local winSize = RL.GetScreenSize()

View File

@@ -27,7 +27,7 @@ void assingGlobalFunction( const char *name, int ( *functionPtr )( lua_State* )
bool luaInit( int argn, const char **argc ); bool luaInit( int argn, const char **argc );
int luaTraceback( lua_State *L ); int luaTraceback( lua_State *L );
bool luaCallMain(); bool luaCallMain();
void luaCallProcess(); void luaCallUpdate();
void luaCallDraw(); void luaCallDraw();
void luaCallExit(); void luaCallExit();
void luaRegister(); void luaRegister();

View File

@@ -1127,7 +1127,7 @@ bool luaCallMain() {
return state->run; return state->run;
} }
void luaCallProcess() { void luaCallUpdate() {
#if defined PLATFORM_DESKTOP_SDL && defined LUA_EVENTS #if defined PLATFORM_DESKTOP_SDL && defined LUA_EVENTS
platformSendEvents(); platformSendEvents();
@@ -1138,7 +1138,7 @@ void luaCallProcess() {
int tracebackidx = lua_gettop(L); int tracebackidx = lua_gettop(L);
lua_getglobal( L, "RL" ); lua_getglobal( L, "RL" );
lua_getfield( L, -1, "process" ); lua_getfield( L, -1, "update" );
if ( lua_isfunction( L, -1 ) ) { if ( lua_isfunction( L, -1 ) ) {
lua_pushnumber( L, GetFrameTime() ); lua_pushnumber( L, GetFrameTime() );

View File

@@ -70,7 +70,7 @@ int main( int argn, const char **argc ) {
if ( WindowShouldClose() ) { if ( WindowShouldClose() ) {
state->run = false; state->run = false;
} }
luaCallProcess(); luaCallUpdate();
luaCallDraw(); luaCallDraw();
} }
luaCallExit(); luaCallExit();