Skip to content

Commit 5f55b34

Browse files
committed
start working on std
1 parent cc7bb92 commit 5f55b34

File tree

3 files changed

+72
-1
lines changed

3 files changed

+72
-1
lines changed

scripts/asset_pipeline.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,10 @@ def bundle_assets(dir_from: str, dir_to: str) -> None:
66
shutil.copytree(dir_from, dir_to, dirs_exist_ok=True,
77
copy_function=shutil.copy2)
88

9+
def bundle_std(dir_to: str) -> None:
10+
shutil.copytree('std', os.path.join(dir_to, 'scripts', 'std'), dirs_exist_ok=True,
11+
copy_function=shutil.copy2)
12+
913
if __name__ == '__main__':
10-
bundle_assets(sys.argv[1], sys.argv[2])
14+
bundle_assets(sys.argv[1], sys.argv[2])
15+
bundle_std(sys.argv[2])

std/core/node.das

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
options gen2
2+
3+
module node public;
4+
5+
class Node {
6+
name : string
7+
position : float2
8+
children : array<Node?>
9+
parent : Node?
10+
11+
def Node(name : string) {
12+
self.name = name
13+
self.parent = null
14+
self.position = float2(0.0, 0.0)
15+
}
16+
17+
def add_child(var node : Node?) {
18+
node.parent = unsafe(addr(self))
19+
children.push(node)
20+
}
21+
22+
def get_node(name : string) : Node? {
23+
for (child in children) {
24+
if (child.name == name) {
25+
return child;
26+
}
27+
}
28+
return null
29+
}
30+
31+
def start() {
32+
for (c in children) {
33+
c.start()
34+
}
35+
}
36+
37+
def update(dt : float) {
38+
for (c in children) {
39+
c.update(dt)
40+
}
41+
}
42+
43+
def render(dt : float) {
44+
for (c in children) {
45+
c.render(dt)
46+
}
47+
}
48+
49+
def fixed_update(dt : float) {
50+
for (c in children) {
51+
c.fixed_update(dt)
52+
}
53+
}
54+
55+
def destroy() {
56+
for (c in children) {
57+
c.destroy()
58+
}
59+
}
60+
61+
def finalize {
62+
destroy()
63+
}
64+
}

test_game/scripts/main.das

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ require grngame_renderer
33

44
var emit : ParticleEmitter
55

6+
require std/core/node
7+
68
[export]
79
def on_start()
810
let sound_info = sound_info_default()

0 commit comments

Comments
 (0)