diff --git a/GameEngine/resources/GameEngineTest.model b/GameEngine/resources/GameEngineTest.model index 9d48131..c0e02a7 100644 --- a/GameEngine/resources/GameEngineTest.model +++ b/GameEngine/resources/GameEngineTest.model @@ -1,60 +1,4 @@ init { -enemy := { - "001": { - "transform": { - "rotation": { - "x": 0.0, - "y": 0.0, - "z": 0.0 - }, - "scale": { - "x": 1.0, - "y": 1.0, - "z": 1.0 - }, - "position": { - "x": 0.0, - "y": 0.0, - "z": 0.0 - } - }, - "move": { - "type": straight, - "speed": 5.0 - }, - "mesh": { - "sprite": "GameEngine/resources/enemy1.png", - "type": "sprite" - } - }, - "002": { - "transform": { - "rotation": { - "x": 0.0, - "y": 0.0, - "z": 0.0 - }, - "scale": { - "x": 1.0, - "y": 1.0, - "z": 1.0 - }, - "position": { - "x": 0.0, - "y": 0.0, - "z": 0.0 - } - }, - "move": { - "type": straight, - "speed": 5.0 - }, - "mesh": { - "sprite": "GameEngine/resources/enemy1.png", - "type": "sprite" - } - } -} player := { "transform": { "rotation": { @@ -78,10 +22,28 @@ "type": "sprite" } } -timers := { - "000": { - "count": 0, - "interval": 100 +enemy1 := { + "eid": "1", + "transform": { + "rotation": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "scale": { + "x": 1.0, + "y": 1.0, + "z": 1.0 + }, + "position": { + "x": 600.0, + "y": 450.0, + "z": 0.0 + } + }, + "mesh": { + "sprite": "GameEngine/resources/enemy1.png", + "type": "sprite" } } } @@ -113,9 +75,10 @@ native channel EntityPositionUpdate(eid:Str) { in scene.entities.{eid:Str}.transform.position(curPos:Json,updatePosition(nextPos.x,nextPos.y,nextPos.z)) = nextPos } -channel MoveEnemy(eid:Str) { - in enemies.{eid:Str}.transform.position(curPos:Json,moveEnemy(nextPos)) = nextPos - out scene.entities.{eid:Str}.transform.position(curPos:Json,moveEnemy(nextPos)) = nextPos +channel MoveEnemy1(eid:Str) { + in enemy1.transform.position(curPos:Json,moveEnemy1(nextPos,eid)) = nextPos + ref enemy1.eid(eid,moveEnemy1(nextPos,eid)) + out enemy1.transform.position(curPos:Json,moveEnemy1(nextPos,eid)) = nextPos } native channel CameraProjectionUpdate { in scene.camera.projection(curProj:Json,updateProjection(curProj,nextProj)) = nextProj @@ -123,6 +86,16 @@ native channel CameraScaleUpdate { in scene.camera.transform.scale(curScale:Json,updateScale(nextScale.x,nextScale.y,nextScale.z)) = nextScale } +channel UpdateEnemy1(tid:Str) { + in timers.{tid:Str}.count(curCount:Long,updateEnemy1(type,speed)) = nextCount + ref enemy1.move.speed(speed:Float,updateEnemy1(type,speed)) + ref enemy1.move.type(type:Str,updateEnemy1(type,speed)) + out enemy1.transform.position(curPos:Json,updateEnemy1(type,speed)) = { + "x": curPos.x, + "y": (curPos.y+speed), + "z": curPos.z +} +} native channel EntitySpriteUpdate(eid:Str) { in scene.entities.{eid:Str}.mesh(curMesh:Json,updateSprite(spritePath:Str)) = { "sprite": spritePath, @@ -132,23 +105,14 @@ native channel EntityScaleUpdate(eid:Str) { in scene.entities.{eid:Str}.transform.scale(curScale:Json,updateScale(nextScale.x,nextScale.y,nextScale.z)) = nextScale } -channel RotateEnemy(eid:Str) { - in enemies.{eid:Str}.transform.rotation(curRot:Json,rotateEnemy(nextRot)) = nextRot - out enemies.{eid:Str}.transform.rotation(curRot:Json,rotateEnemy(nextRot)) = nextRot -} -channel UpdateEnemy(tid:Str, eid:Str) { - in timers.{tid:Str}.count(curCount:Long,updateEnemy(type,speed)) = nextCount - ref enemies.{eid:Str}.move.speed(speed:Float,updateEnemy(type,speed)) - ref enemies.{eid:Str}.move.type(type:Str,updateEnemy(type,speed)) - out enemies.{eid:Str}.transform.position(curPos:Json,updateEnemy(type,speed)) = { - "x": curPos.x, - "y": (curPos.y+speed), - "z": curPos.z -} -} native channel TimersUpdated { in timers(curTimers:Map,update(curTimers,nextTimers)) = nextTimers } +channel RotateEnemy1(eid:Str) { + in enemy1.transform.rotation(curRot:Json,rotateEnemy1(nextRot,eid)) = nextRot + ref enemy1.eid(eid,rotateEnemy1(nextRot,eid)) + out enemy1.transform.rotation(curRot:Json,rotateEnemy1(nextRot,eid)) = nextRot +} native channel CameraPositionUpdate { in scene.camera.transform.position(curPos:Json,updatePosition(nextPos.x,nextPos.y,nextPos.z)) = nextPos }