diff --git a/AlgebraicDataflowArchitectureModel/models/GameEngine.model b/AlgebraicDataflowArchitectureModel/models/GameEngine.model index 1e23e9b..8c6f525 100644 --- a/AlgebraicDataflowArchitectureModel/models/GameEngine.model +++ b/AlgebraicDataflowArchitectureModel/models/GameEngine.model @@ -1,6 +1,7 @@ init { enemy := { "position": {"x": 0.0, "y": 0.0, "z": 0.0}, + "rotation": {"x": 0.0, "y": 0.0, "z": 0.0}, "id": "001" } } @@ -9,10 +10,6 @@ out scene.time(time: Long, updateEvent(dt: Long)) = time + dt } -native channel KeyEvent(kno: Int) { - out scene.keys.{kno}.state(curState: Int, keyEvent(nextState)) = nextState -} - native channel SceneUpdate { in scene(curSc: Json, update(curSc, nextSc)) = nextSc } @@ -49,6 +46,10 @@ in scene.entities.{eid}.mesh(curMesh: Json, updateSprite(spritePath: Str)) = {"type": "sprite", "sprite": spritePath} } +native channel KeyEvent(kno: Int) { + out scene.keys.{kno}.state(curState: Int, keyEvent(nextState)) = nextState +} + native channel TimersUpdated { in timers(curTimers: Map, update(curTimers, nextTimers)) = nextTimers } @@ -86,11 +87,18 @@ channel UpdateEnemy(tid: Str) { in timers.{tid}.count(curCount: Long, updateEnemy(nextCount)) = nextCount - out enemy.position(curPos: Json, updateEnemy(nextCount)) = {"x": curPos.x, "y": curPos.y + 1, "z": curPos.z} + out enemy.position(curPos: Json, updateEnemy(nextCount)) = {"x": curPos.x, "y": curPos.y + 5, "z": curPos.z} + out enemy.rotation(curRot: Json, updateEnemy(nextCount)) = {"x": curRot.x, "y": curRot.y, "z": curRot.z + 5} } -channel ViewEnemy { - in enemy.position(curPos: Json, viewEnemy(nextPos, nextId)) = nextPos - in enemy.id(curId: Str, viewEnemy(nextPos, nextId)) = nextId - out scene.entities.{nextId}.transform.position(curPos: Json, viewEnemy(nextPos, nextId)) = nextPos +channel MoveEnemy { + in enemy.position(curPos: Json, moveEnemy(nextPos, nextRot, nextId)) = nextPos + in enemy.id(curId: Str, moveEnemy(nextPos, nextRot, nextId)) = nextId + out scene.entities.{nextId}.transform.position(curPos: Json, moveEnemy(nextPos, nextRot, nextId)) = nextPos +} + +channel RotateEnemy { + in enemy.rotation(curRot: Json, rotateEnemy(nextPos, nextRot, nextId)) = nextRot + in enemy.id(curId: Str, rotateEnemy(nextPos, nextRot, nextId)) = nextId + out scene.entities.{nextId}.transform.rotation(curRot: Json, rotateEnemy(nextPos, nextRot, nextId)) = nextRot }