Mercurial > games > semicongine
comparison tests/test_font.nim @ 1135:74957cbf589b
fix: update tests according to some API renaming
author | sam <sam@basx.dev> |
---|---|
date | Mon, 03 Jun 2024 16:05:17 +0700 |
parents | 73b572f82a1f |
children | 71315636ba82 |
comparison
equal
deleted
inserted
replaced
1134:055eb17ce31e | 1135:74957cbf589b |
---|---|
26 F6: Bottom""".toRunes, horizontalAlignment = Left, verticalAlignment = Top, transform = translate(-0.9, -0.9) * scale(0.0002, 0.0002)) | 26 F6: Bottom""".toRunes, horizontalAlignment = Left, verticalAlignment = Top, transform = translate(-0.9, -0.9) * scale(0.0002, 0.0002)) |
27 scene.add origin | 27 scene.add origin |
28 scene.add main_text | 28 scene.add main_text |
29 scene.add help_text | 29 scene.add help_text |
30 engine.loadScene(scene) | 30 engine.loadScene(scene) |
31 mixer[].loadSound("key", "key.ogg") | 31 mixer[].LoadSound("key", "key.ogg") |
32 mixer[].setLevel(0.5) | 32 mixer[].SetLevel(0.5) |
33 | 33 |
34 while engine.updateInputs() and not keyIsDown(Escape): | 34 while engine.UpdateInputs() and not KeyIsDown(Escape): |
35 var t = cpuTime() | 35 var t = cpuTime() |
36 main_text.color = newVec4f(sin(t) * 0.5 + 0.5, 0.15, 0.15, 1) | 36 main_text.color = newVec4f(sin(t) * 0.5 + 0.5, 0.15, 0.15, 1) |
37 if windowWasResized(): | 37 if WindowWasResized(): |
38 var winSize = engine.getWindow().size | 38 var winSize = engine.GetWindow().size |
39 | 39 |
40 # add character | 40 # add character |
41 if main_text.text.len < main_text.maxLen - 1: | 41 if main_text.text.len < main_text.maxLen - 1: |
42 for c in [Key.A, Key.B, Key.C, Key.D, Key.E, Key.F, Key.G, Key.H, Key.I, | 42 for c in [Key.A, Key.B, Key.C, Key.D, Key.E, Key.F, Key.G, Key.H, Key.I, |
43 Key.J, Key.K, Key.L, Key.M, Key.N, Key.O, Key.P, Key.Q, Key.R, Key.S, | 43 Key.J, Key.K, Key.L, Key.M, Key.N, Key.O, Key.P, Key.Q, Key.R, Key.S, |
44 Key.T, Key.U, Key.V, Key.W, Key.X, Key.Y, Key.Z]: | 44 Key.T, Key.U, Key.V, Key.W, Key.X, Key.Y, Key.Z]: |
45 if keyWasPressed(c): | 45 if KeyWasPressed(c): |
46 discard mixer[].play("key") | 46 discard mixer[].Play("key") |
47 if keyIsDown(ShiftL) or keyIsDown(ShiftR): | 47 if KeyIsDown(ShiftL) or KeyIsDown(ShiftR): |
48 main_text.text = main_text.text & ($c).toRunes | 48 main_text.text = main_text.text & ($c).toRunes |
49 else: | 49 else: |
50 main_text.text = main_text.text & ($c).toRunes[0].toLower() | 50 main_text.text = main_text.text & ($c).toRunes[0].toLower() |
51 if keyWasPressed(Enter): | 51 if KeyWasPressed(Enter): |
52 discard mixer[].play("key") | 52 discard mixer[].Play("key") |
53 main_text.text = main_text.text & Rune('\n') | 53 main_text.text = main_text.text & Rune('\n') |
54 if keyWasPressed(Space): | 54 if KeyWasPressed(Space): |
55 discard mixer[].play("key") | 55 discard mixer[].Play("key") |
56 main_text.text = main_text.text & Rune(' ') | 56 main_text.text = main_text.text & Rune(' ') |
57 | 57 |
58 # remove character | 58 # remove character |
59 if keyWasPressed(Backspace) and main_text.text.len > 0: | 59 if KeyWasPressed(Backspace) and main_text.text.len > 0: |
60 discard mixer[].play("key") | 60 discard mixer[].Play("key") |
61 main_text.text = main_text.text[0 ..< ^1] | 61 main_text.text = main_text.text[0 ..< ^1] |
62 | 62 |
63 # alignemtn with F-keys | 63 # alignemtn with F-keys |
64 if keyWasPressed(F1): main_text.horizontalAlignment = Left | 64 if KeyWasPressed(F1): main_text.horizontalAlignment = Left |
65 elif keyWasPressed(F2): main_text.horizontalAlignment = Center | 65 elif KeyWasPressed(F2): main_text.horizontalAlignment = Center |
66 elif keyWasPressed(F3): main_text.horizontalAlignment = Right | 66 elif KeyWasPressed(F3): main_text.horizontalAlignment = Right |
67 elif keyWasPressed(F4): main_text.verticalAlignment = Top | 67 elif KeyWasPressed(F4): main_text.verticalAlignment = Top |
68 elif keyWasPressed(F5): main_text.verticalAlignment = Center | 68 elif KeyWasPressed(F5): main_text.verticalAlignment = Center |
69 elif keyWasPressed(F6): main_text.verticalAlignment = Bottom | 69 elif KeyWasPressed(F6): main_text.verticalAlignment = Bottom |
70 | 70 |
71 origin.refresh() | 71 origin.refresh() |
72 main_text.text = main_text.text & Rune('_') | 72 main_text.text = main_text.text & Rune('_') |
73 main_text.refresh() | 73 main_text.refresh() |
74 main_text.text = main_text.text[0 ..< ^1] | 74 main_text.text = main_text.text[0 ..< ^1] |