Mercurial > games > semicongine
comparison tests/test_font.nim @ 344:b83b3a1ccb05
fix: all tests
| author | Sam <sam@basx.dev> |
|---|---|
| date | Mon, 11 Sep 2023 21:31:22 +0700 |
| parents | 6cc16b62e497 |
| children | f054b8bacab8 |
comparison
equal
deleted
inserted
replaced
| 343:c9b34b41a5a2 | 344:b83b3a1ccb05 |
|---|---|
| 1 import std/unicode | 1 import std/unicode |
| 2 import std/tables | |
| 3 | 2 |
| 4 import semicongine | 3 import semicongine |
| 5 | 4 |
| 6 proc main() = | 5 proc main() = |
| 7 var font = loadFont("DejaVuSans.ttf", color=newVec4f(1, 0.5, 0.5, 1), resolution=20) | 6 var font = loadFont("DejaVuSans.ttf", color=newVec4f(1, 0.5, 0.5, 1), resolution=20) |
| 9 var textbox = initTextbox(32, font, "") | 8 var textbox = initTextbox(32, font, "") |
| 10 var scene = Scene(name: "main") | 9 var scene = Scene(name: "main") |
| 11 scene.add textbox | 10 scene.add textbox |
| 12 textbox.mesh.transform = scale(0.01, 0.01) | 11 textbox.mesh.transform = scale(0.01, 0.01) |
| 13 var engine = initEngine("Test fonts") | 12 var engine = initEngine("Test fonts") |
| 14 engine.initRenderer() | 13 engine.initRenderer([]) |
| 15 scene.addShaderGlobal("perspective", Unit4F32) | |
| 16 engine.addScene(scene) | 14 engine.addScene(scene) |
| 17 | 15 |
| 18 while engine.updateInputs() == Running and not engine.keyIsDown(Escape): | 16 while engine.updateInputs() == Running and not engine.keyIsDown(Escape): |
| 19 if engine.windowWasResized(): | 17 if engine.windowWasResized(): |
| 20 var winSize = engine.getWindow().size | 18 var winSize = engine.getWindow().size |
| 21 scene.setShaderGlobal("perspective", orthoWindowAspect(winSize[1] / winSize[0])) | |
| 22 textbox.mesh.transform = scale(0.01 * (winSize[1] / winSize[0]), 0.01) | 19 textbox.mesh.transform = scale(0.01 * (winSize[1] / winSize[0]), 0.01) |
| 23 for c in [Key.A, Key.B, Key.C, Key.D, Key.E, Key.F, Key.G, Key.H, Key.I, 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]: | 20 for c in [Key.A, Key.B, Key.C, Key.D, Key.E, Key.F, Key.G, Key.H, Key.I, 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]: |
| 24 if engine.keyWasPressed(c): | 21 if engine.keyWasPressed(c): |
| 25 if engine.keyIsDown(ShiftL) or engine.keyIsDown(ShiftR): | 22 if engine.keyIsDown(ShiftL) or engine.keyIsDown(ShiftR): |
| 26 textbox.text = textbox.text & ($c).toRunes | 23 textbox.text = textbox.text & ($c).toRunes |
