Skip to content

Commit e280b82

Browse files
authored
Add UiNode class for UI rendering
1 parent c0f4df7 commit e280b82

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

std/ui.das

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
options gen2
2+
3+
require node
4+
require grngame_renderer
5+
6+
class UiNode : Node {
7+
center: bool
8+
flip_x: bool
9+
alpha: int
10+
rotation: int
11+
coeff: int
12+
13+
def UiNode(ui_name: string, w: int, h: int, is_center: bool) {
14+
Node`Node(self, ui_name)
15+
self.coeff = 1
16+
self.center = is_center
17+
self.flip_x = false
18+
self.alpha = 255
19+
self.rotation = 0
20+
}
21+
22+
def get_draw_position() : float2 {
23+
if (center) {
24+
//todo center position
25+
return position
26+
}
27+
return position
28+
}
29+
30+
def override render() {
31+
super.render()
32+
if (alpha == 0) {
33+
return
34+
}
35+
var draw_pos = get_draw_position()
36+
draw(name, draw_pos.x, draw_pos.y,coeff, flip_x, rotation, alpha)
37+
}
38+
}

0 commit comments

Comments
 (0)