| 1 | module main |
| 2 | |
| 3 | @[heap] |
| 4 | interface IGameObject { |
| 5 | mut: |
| 6 | name string |
| 7 | parent ?&IGameObject |
| 8 | children []&IGameObject |
| 9 | advance() |
| 10 | } |
| 11 | |
| 12 | @[heap] |
| 13 | struct GameObject implements IGameObject { |
| 14 | mut: |
| 15 | name string |
| 16 | parent ?&IGameObject |
| 17 | children []&IGameObject |
| 18 | } |
| 19 | |
| 20 | struct Ship implements IGameObject { |
| 21 | GameObject |
| 22 | speed f32 |
| 23 | } |
| 24 | |
| 25 | fn (mut gameobject GameObject) advance() { |
| 26 | for mut child in gameobject.children { |
| 27 | go child.advance() |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | fn test_main() { |
| 32 | mut ship := &Ship{ |
| 33 | name: 'ship' |
| 34 | } |
| 35 | ship.advance() |
| 36 | assert true |
| 37 | } |
| 38 |