Last active
September 19, 2021 11:17
-
-
Save Timofffee/cea40e795408d9a0b66446ba6c42d2ef to your computer and use it in GitHub Desktop.
nimraylib_now basic game loop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Basic Game Loop | |
# Engine/Framework: Raylib (https://www.raylib.com) | |
# based on https://gist.github.com/SemanticDevice/6f57b69c50c292d87c626e15de504e6b#file-raylib_basic_game_loop-c | |
import nimraylib_now | |
const WIN_WIDTH_PX = 800 # Main window width in pixels | |
const WIN_HEIGHT_PX = 640 # Main window height in pixels | |
proc gameInitialize() | |
proc gameTerminate() | |
proc gameDraw() | |
proc gameProcessInput() | |
proc gameUpdate() | |
proc isGameRunning(): bool | |
when isMainModule: | |
gameInitialize() | |
while isGameRunning(): | |
gameProcessInput() | |
gameUpdate() | |
gameDraw() | |
gameTerminate() | |
proc gameInitialize() = | |
setTargetFPS 60 | |
initWindow(WIN_WIDTH_PX, WIN_HEIGHT_PX, "Basic Game Loop: Raylib") | |
proc gameTerminate() = | |
closeWindow() | |
proc gameDraw() = | |
beginDrawing: | |
clearBackground(Raywhite) | |
proc gameProcessInput() = discard | |
proc gameUpdate() = discard | |
proc isGameRunning(): bool = not windowShouldClose() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment