comparison tests/test_font.nim @ 1136:71315636ba82

did: refactor naming in tons of places
author sam <sam@basx.dev>
date Tue, 04 Jun 2024 16:51:50 +0700
parents 74957cbf589b
children a4aa9f374d44
comparison
equal deleted inserted replaced
1135:74957cbf589b 1136:71315636ba82
10 engine.initRenderer([]) 10 engine.initRenderer([])
11 11
12 # build scene 12 # build scene
13 var scene = Scene(name: "main") 13 var scene = Scene(name: "main")
14 var font = loadFont("DejaVuSans.ttf", lineHeightPixels = 210'f32) 14 var font = loadFont("DejaVuSans.ttf", lineHeightPixels = 210'f32)
15 var origin = initPanel(transform = scale(0.01, 0.01)) 15 var origin = initPanel(transform = Scale(0.01, 0.01))
16 var main_text = font.initText("".toRunes, maxLen = 255, color = newVec4f(1, 0.15, 0.15, 1), maxWidth = 1.0, transform = scale(0.0005, 0.0005)) 16 var main_text = font.initText("".toRunes, maxLen = 255, color = NewVec4f(1, 0.15, 0.15, 1), maxWidth = 1.0, transform = Scale(0.0005, 0.0005))
17 var help_text = font.initText("""Controls 17 var help_text = font.initText("""Controls
18 18
19 Horizontal alignment: 19 Horizontal alignment:
20 F1: Left 20 F1: Left
21 F2: Center 21 F2: Center
22 F3: Right 22 F3: Right
23 Vertical alignment: 23 Vertical alignment:
24 F4: Top 24 F4: Top
25 F5: Center 25 F5: Center
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: