Mercurial > games > semicongine
comparison tests/test_panel.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 counter.inc | 10 counter.inc |
11 if buttons.contains(Mouse3): | 11 if buttons.contains(Mouse3): |
12 counter.dec | 12 counter.dec |
13 counterText.text = $counter | 13 counterText.text = $counter |
14 proc enter(panel: var Panel) = | 14 proc enter(panel: var Panel) = |
15 panel.mesh.transform = panel.mesh.transform * scale(1.05, 1.05) | 15 panel.mesh.transform = panel.mesh.transform * Scale(1.05, 1.05) |
16 panel.color = newVec4f(1, 0, 0, 0.3) | 16 panel.color = NewVec4f(1, 0, 0, 0.3) |
17 proc leave(panel: var Panel) = | 17 proc leave(panel: var Panel) = |
18 panel.mesh.transform = panel.mesh.transform * scale(1 / 1.05, 1 / 1.05) | 18 panel.mesh.transform = panel.mesh.transform * Scale(1 / 1.05, 1 / 1.05) |
19 panel.color = newVec4f(1, 0, 0, 0.5) | 19 panel.color = NewVec4f(1, 0, 0, 0.5) |
20 | 20 |
21 proc main() = | 21 proc main() = |
22 # setup engine | 22 # setup engine |
23 var engine = initEngine("Test panels") | 23 var engine = initEngine("Test panels") |
24 engine.initRenderer([]) | 24 engine.initRenderer([]) |
29 # | 29 # |
30 var | 30 var |
31 font = loadFont("DejaVuSans.ttf", lineHeightPixels = 210'f32) | 31 font = loadFont("DejaVuSans.ttf", lineHeightPixels = 210'f32) |
32 scene = Scene(name: "main") | 32 scene = Scene(name: "main") |
33 origin = initPanel( | 33 origin = initPanel( |
34 transform = scale(0.005, 0.005), | 34 transform = Scale(0.005, 0.005), |
35 color = newVec4f(1, 1, 1, 1), | 35 color = NewVec4f(1, 1, 1, 1), |
36 texture = Texture(isGrayscale: false, colorImage: newImage[RGBAPixel](3, 3, [T, B, T, B, B, B, T, B, T]), sampler: NEAREST_SAMPLER), | 36 texture = Texture(isGrayscale: false, colorImage: newImage[RGBAPixel](3, 3, [T, B, T, B, B, B, T, B, T]), sampler: NEAREST_SAMPLER), |
37 ) | 37 ) |
38 button = initPanel( | 38 button = initPanel( |
39 transform = translate(0.2, 0.1) * scale(0.3, 0.1), | 39 transform = Translate(0.2, 0.1) * Scale(0.3, 0.1), |
40 color = newVec4f(1, 0, 0, 0.5), | 40 color = NewVec4f(1, 0, 0, 0.5), |
41 onMouseDown = click, | 41 onMouseDown = click, |
42 onMouseEnter = enter, | 42 onMouseEnter = enter, |
43 onMouseLeave = leave | 43 onMouseLeave = leave |
44 ) | 44 ) |
45 help_text = font.initText("""Controls | 45 help_text = font.initText("""Controls |
52 F4: Top | 52 F4: Top |
53 F5: Center | 53 F5: Center |
54 F6: Bottom | 54 F6: Bottom |
55 Mouse: | 55 Mouse: |
56 Left click: Increase counter | 56 Left click: Increase counter |
57 Right click: Decrease counter""".toRunes, horizontalAlignment = Left, verticalAlignment = Top, transform = translate(-0.9, -0.9) * scale(0.0002, 0.0002)) | 57 Right click: Decrease counter""".toRunes, horizontalAlignment = Left, verticalAlignment = Top, transform = Translate(-0.9, -0.9) * Scale(0.0002, 0.0002)) |
58 | 58 |
59 counterText = font.initText(($counter).toRunes, maxLen = 99, transform = translate(0.2, 0.1) * scale(0.0004, 0.0004)) | 59 counterText = font.initText(($counter).toRunes, maxLen = 99, transform = Translate(0.2, 0.1) * Scale(0.0004, 0.0004)) |
60 | 60 |
61 scene.add counterText | 61 scene.add counterText |
62 scene.add button | 62 scene.add button |
63 scene.add help_text | 63 scene.add help_text |
64 scene.add origin | 64 scene.add origin |