changeset 427:b1c9374c7080

add: nicer key-stroke test, cleanup test-resource files
author Sam <sam@basx.dev>
date Sat, 03 Feb 2024 23:03:34 +0700
parents 1e3c242435af
children 545b4c58601f
files tests/resources/default/DejaVuSans.ttf tests/resources/default/default_cube.glb tests/resources/default/donut.glb tests/resources/default/flag.png tests/resources/default/key.ogg tests/test_font.nim
diffstat 6 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
Binary file tests/resources/default/DejaVuSans.ttf has changed
Binary file tests/resources/default/default_cube.glb has changed
Binary file tests/resources/default/donut.glb has changed
Binary file tests/resources/default/flag.png has changed
Binary file tests/resources/default/key.ogg has changed
--- a/tests/test_font.nim	Sat Feb 03 21:40:25 2024 +0700
+++ b/tests/test_font.nim	Sat Feb 03 23:03:34 2024 +0700
@@ -25,6 +25,7 @@
   scene.add main_text
   scene.add help_text
   engine.loadScene(scene)
+  mixer[].loadSound("key", "key.ogg")
 
   while engine.updateInputs() == Running and not engine.keyIsDown(Escape):
     if engine.windowWasResized():
@@ -39,17 +40,21 @@
           Key.J, Key.K, Key.L, Key.M, Key.N, Key.O, Key.P, Key.Q, Key.R, Key.S,
           Key.T, Key.U, Key.V, Key.W, Key.X, Key.Y, Key.Z]:
         if engine.keyWasPressed(c):
+          discard mixer[].play("key")
           if engine.keyIsDown(ShiftL) or engine.keyIsDown(ShiftR):
             main_text.text = main_text.text & ($c).toRunes
           else:
             main_text.text = main_text.text & ($c).toRunes[0].toLower()
       if engine.keyWasPressed(Enter):
+        discard mixer[].play("key")
         main_text.text = main_text.text & Rune('\n')
       if engine.keyWasPressed(Space):
+        discard mixer[].play("key")
         main_text.text = main_text.text & Rune(' ')
 
     # remove character
     if engine.keyWasPressed(Backspace) and main_text.text.len > 0:
+      discard mixer[].play("key")
       main_text.text = main_text.text[0 ..< ^1]
 
     # alignemtn with F-keys