Embed resource files for native build, break out config.

This commit is contained in:
Mahlon E. Smith 2025-08-21 16:57:23 -07:00
parent 1450302e06
commit e01dc377a7
Signed by: mahlon
SSH key fingerprint: SHA256:dP84sRGKZRpOOiPD/+GuOq+SHSxEw9qi5BWLQobaHm0
7 changed files with 138 additions and 23 deletions

View file

@ -1,19 +1,15 @@
# vim: set et sta sw=4 ts=4 :
import
std/parsecfg,
std/strformat,
std/strutils
std/strformat
import reasings
import raylib
var conf: Config
try:
conf = loadConfig( "resources/config.ini" )
except IOError:
echo "No config file, using defaults."
conf = newConfig()
import
lib/configuration,
lib/embeddedfs
var fps = conf.getSectionValue( "Performance", "fps", defaultVal = "60").parseInt
# Emscripten specific imports
proc emscripten_set_main_loop( f: proc() {.cdecl.}, a: cint, b: bool ) {.importc.}
@ -27,6 +23,14 @@ var camera = Camera(
projection: Perspective # Defines projection type, see CameraProjection
)
var count = 0
let duration = 3000
let startPositionX: float32 = 45.0
let finalPositionX: float32 = 120.0
var currentPositionX = startPositionX
# This only works with:
# --passL:"-s EXPORT_FUNCTIONS=_nativeGreet", but it breaks raylib loading.
# hmmmmm. EXPORT_ALL=1 is also a no go.
@ -41,23 +45,26 @@ proc mainLoop() {.cdecl.} =
defer: closeWindow()
initWindow( 800, 600, "raylib nim playground" )
setTargetFPS( fps.int32 );
var count = 0
setTargetFPS( conf.fps )
while not windowShouldClose():
beginDrawing();
clearBackground( WHITE );
beginMode3D( camera );
drawGrid( 10, 1.0f );
endMode3D();
beginDrawing()
clearBackground( WHITE )
beginMode3D( camera )
if camera.fovy < finalPositionX:
camera.fovy = bounceInOut( count.float32, startPositionX,
finalPositionX - startPositionX, duration.float32 )
drawGrid( 10, 1.0f )
endMode3D()
var col = if isCursorOnScreen(): BLUE else: GRAY
drawText( "OH SNAP IT'S WORKING\n{count}".fmt, 10, 10, 20, col );
endDrawing();
drawText( "OH SNAP IT'S WORKING\n{count}".fmt, 10, 10, 20, col )
endDrawing()
count = count + 1
count.inc
when defined( emscripten ):
@ -65,4 +72,3 @@ when defined( emscripten ):
else:
mainLoop()