summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjussi2022-06-21 12:36:22 +0300
committerjussi2022-06-21 12:36:22 +0300
commit36baf4c1222aee409bb62be9770798bfa7fdd302 (patch)
tree0b2722bf160178db06bb94df68fd5244affc8986
parent6bac1a2c6364886a482530a0ef4cf849ae468806 (diff)
downloadreilua-enhanced-36baf4c1222aee409bb62be9770798bfa7fdd302.tar.gz
reilua-enhanced-36baf4c1222aee409bb62be9770798bfa7fdd302.tar.bz2
reilua-enhanced-36baf4c1222aee409bb62be9770798bfa7fdd302.zip
Removed autoset fps.
-rw-r--r--examples/pong_vec/main.lua1
-rw-r--r--examples/snake/main.lua10
-rw-r--r--include/state.h1
-rw-r--r--src/state.c9
4 files changed, 9 insertions, 12 deletions
diff --git a/examples/pong_vec/main.lua b/examples/pong_vec/main.lua
index 705e68f..4bf3d35 100644
--- a/examples/pong_vec/main.lua
+++ b/examples/pong_vec/main.lua
@@ -59,6 +59,7 @@ function init()
local mPos = Vec2:new( RL_GetMonitorPosition( monitor ) )
local mSize = Vec2:new( RL_GetMonitorSize( monitor ) )
+ RL_SetConfigFlags( FLAG_VSYNC_HINT )
RL_SetWindowSize( winSize )
RL_SetWindowPosition( { mPos.x + mSize.x / 2 - winSize.x / 2, mPos.y + mSize.y / 2 - winSize.y / 2 } )
RL_SetWindowTitle( "Pong" )
diff --git a/examples/snake/main.lua b/examples/snake/main.lua
index 1fe6ae7..d6e4fa5 100644
--- a/examples/snake/main.lua
+++ b/examples/snake/main.lua
@@ -158,11 +158,11 @@ end
--[[ Check if next segment is on left side. There are more mathematically elegant solution to this, but there is
only four possibilities so we can just check them all. ]]--
-local function onLeft( this, next )
- return ( vector2IsEqual( this, { 0, -1 } ) and vector2IsEqual( next, { -1, 0 } ) )
- or ( vector2IsEqual( this, { -1, 0 } ) and vector2IsEqual( next, { 0, 1 } ) )
- or ( vector2IsEqual( this, { 0, 1 } ) and vector2IsEqual( next, { 1, 0 } ) )
- or ( vector2IsEqual( this, { 1, 0 } ) and vector2IsEqual( next, { 0, -1 } ) )
+local function onLeft( this, nextSeg )
+ return ( vector2IsEqual( this, { 0, -1 } ) and vector2IsEqual( nextSeg, { -1, 0 } ) )
+ or ( vector2IsEqual( this, { -1, 0 } ) and vector2IsEqual( nextSeg, { 0, 1 } ) )
+ or ( vector2IsEqual( this, { 0, 1 } ) and vector2IsEqual( nextSeg, { 1, 0 } ) )
+ or ( vector2IsEqual( this, { 1, 0 } ) and vector2IsEqual( nextSeg, { 0, -1 } ) )
end
local function drawSnake()
diff --git a/include/state.h b/include/state.h
index 0cdbcda..7599052 100644
--- a/include/state.h
+++ b/include/state.h
@@ -13,7 +13,6 @@ typedef struct {
bool run;
lua_State *luaState;
Vector2 resolution;
- int targetFPS;
int textureSource;
/* Resources. */
/* Images. */
diff --git a/src/state.c b/src/state.c
index 5129748..c87d064 100644
--- a/src/state.c
+++ b/src/state.c
@@ -15,7 +15,6 @@ bool stateInit( const char *exePath ) {
state->run = true;
state->resolution = (Vector2){ 1024, 720 };
state->luaState = NULL;
- state->targetFPS = 60;
state->textureSource = TEXTURE_SOURCE_TEXTURE;
/* Images. */
state->imageAlloc = ALLOC_PAGE_SIZE;
@@ -106,13 +105,11 @@ bool stateInit( const char *exePath ) {
state->hasWindow = false;
state->run = false;
}
- else {
- SetTargetFPS( state->targetFPS );
+ if ( state->run ) {
+ InitAudioDevice();
+ state->run = luaInit();
}
- InitAudioDevice();
- state->run = luaInit();
-
return state->run;
}