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. --- src/core.c | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 109 insertions(+), 13 deletions(-) (limited to 'src/core.c') diff --git a/src/core.c b/src/core.c index e9c93ba..58316bf 100644 --- a/src/core.c +++ b/src/core.c @@ -1220,6 +1220,32 @@ int lcoreSetTargetFPS( lua_State* L ) { return 0; } +/* +> delta = RL.GetFrameTime() + +Get time in seconds for last frame drawn (Delta time) + +- Success return float +*/ +int lcoreGetFrameTime( lua_State* L ) { + lua_pushnumber( L, GetFrameTime() ); + + return 1; +} + +/* +> time = RL.GetTime() + +Get elapsed time in seconds since InitWindow() + +- Success return float +*/ +int lcoreGetTime( lua_State* L ) { + lua_pushnumber( L, GetTime() ); + + return 1; +} + /* > FPS = RL.GetFPS() @@ -1234,29 +1260,42 @@ int lcoreGetFPS( lua_State* L ) { } /* -> delta = RL.GetFrameTime() +## Core - Custom frame control functions +*/ -Get time in seconds for last frame drawn (Delta time) +/* +> RL.SwapScreenBuffer() -- Success return float +Swap back buffer with front buffer (screen drawing) */ -int lcoreGetFrameTime( lua_State* L ) { - lua_pushnumber( L, GetFrameTime() ); +int lcoreSwapScreenBuffer( lua_State* L ) { + SwapScreenBuffer(); - return 1; + return 0; } /* -> time = RL.GetTime() +> RL.PollInputEvents() -Get elapsed time in seconds since InitWindow() +Register all input events +*/ +int lcorePollInputEvents( lua_State* L ) { + PollInputEvents(); -- Success return float + return 0; +} + +/* +> RL.WaitTime( number seconds ) + +Wait for some time (halt program execution) */ -int lcoreGetTime( lua_State* L ) { - lua_pushnumber( L, GetTime() ); +int lcoreWaitTime( lua_State* L ) { + double seconds = luaL_checknumber( L, 1 ); - return 1; + WaitTime( seconds ); + + return 0; } /* @@ -1907,6 +1946,21 @@ int lcoreIsKeyPressed( lua_State* L ) { return 1; } +/* +> pressed = RL.IsKeyPressedRepeat( int key ) + +Check if a key has been pressed again (Only PLATFORM_DESKTOP) + +- Success return bool +*/ +int lcoreIsKeyPressedRepeat( lua_State* L ) { + int key = luaL_checkinteger( L, 1 ); + + lua_pushboolean( L, IsKeyPressedRepeat( key ) ); + + return 1; +} + /* > pressed = RL.IsKeyDown( int key ) @@ -2073,6 +2127,35 @@ int lcoreIsGamepadButtonReleased( lua_State* L ) { return 1; } +/* +> notPressed = RL.IsGamepadButtonUp( int gamepad, int button ) + +Check if a gamepad button is NOT being pressed + +- Success return bool +*/ +int lcoreIsGamepadButtonUp( lua_State* L ) { + int gamepad = luaL_checkinteger( L, 1 ); + int button = luaL_checkinteger( L, 2 ); + + lua_pushboolean( L, IsGamepadButtonUp( gamepad, button ) ); + + return 1; +} + +/* +> button = RL.GetGamepadButtonPressed() + +Get the last gamepad button pressed + +- Success return int +*/ +int lcoreGetGamepadButtonPressed( lua_State* L ) { + lua_pushinteger( L, GetGamepadButtonPressed() ); + + return 1; +} + /* > count = RL.GetGamepadAxisCount( int gamepad ) @@ -2251,7 +2334,7 @@ int lcoreSetMouseScale( lua_State* L ) { /* > movement = RL.GetMouseWheelMove() -Returns mouse wheel movement Y +Get mouse wheel movement for X or Y, whichever is larger - Success return float */ @@ -2261,6 +2344,19 @@ int lcoreGetMouseWheelMove( lua_State* L ) { return 1; } +/* +> movement = RL.GetMouseWheelMoveV() + +Get mouse wheel movement for both X and Y + +- Success return Vector2 +*/ +int lcoreGetMouseWheelMoveV( lua_State* L ) { + uluaPushVector2( L, GetMouseWheelMoveV() ); + + return 1; +} + /* > RL.SetMouseCursor( int cursor ) -- cgit v1.2.3