diff options
| author | Arslaan Pathan <[email protected]> | 2025-06-15 20:27:31 +1200 |
|---|---|---|
| committer | Arslaan Pathan <[email protected]> | 2025-06-15 20:27:31 +1200 |
| commit | 3c399d6ea4ad3528f1845944bb6d5b00697d2c0b (patch) | |
| tree | 9f136c5e040a2d853d24fd6974233cc01d6e8ceb /src/main.cpp | |
| parent | 5348dbdef1c55c076c8603bad98d20c73085d12b (diff) | |
| download | showdownofthesticks-3c399d6ea4ad3528f1845944bb6d5b00697d2c0b.tar.xz showdownofthesticks-3c399d6ea4ad3528f1845944bb6d5b00697d2c0b.zip | |
Add punch feature + knockback etc, lots of cool shit
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/main.cpp b/src/main.cpp index b2a48d9..24a3147 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -357,7 +357,7 @@ int main() lua_setglobal(L, "HEIGHT"); SDL_Init(SDL_INIT_EVERYTHING); - SDL_CreateWindowAndRenderer(WIDTH, HEIGHT, 0, &window, &renderer); + SDL_CreateWindowAndRenderer(WIDTH, HEIGHT, SDL_RENDERER_PRESENTVSYNC, &window, &renderer); SDL_SetWindowTitle(window, "Showdown of the Sticks"); SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND); SDL_RenderSetLogicalSize(renderer, WIDTH, HEIGHT); @@ -388,6 +388,9 @@ int main() call_lua_function(L, "Setup"); + Uint32 lastFrameTime = SDL_GetTicks(); + float deltaTime = 0.0f; + while (running) { push_keys_to_lua(L, keys); @@ -395,6 +398,13 @@ int main() call_lua_function(L, "Update"); + Uint32 currentFrameTime = SDL_GetTicks(); + deltaTime = (currentFrameTime - lastFrameTime) / 1000.0f; + lastFrameTime = currentFrameTime; + + lua_pushnumber(L, deltaTime); + lua_setglobal(L, "deltaTime"); + while (SDL_PollEvent(&event)) { if (event.type == SDL_QUIT) @@ -538,7 +548,7 @@ int main() textList.clear(); SDL_RenderPresent(renderer); - SDL_Delay(10); + SDL_Delay(1); } lua_close(L); |
