Closed thornyd closed 12 years ago
Here's a robot I tried to make where it accelerates towards the player based on the value of the distance between the player and the robot. Here's the source code and the before and after screenshots.
http://i40.tinypic.com/111ujbl.png
http://i39.tinypic.com/2lliyhe.jpg
{ "robot": "0.9", "properties": { "displayName": "Unnamed Robot", "description": "Describe your robot here.", "health": "100", "maxhealth": "100", "immortal": true, "solid": false, "physics": false, "name": "Unnamed-Robot" }, "behavior": [ { "event": "onSpawn", "eventsheet": { "position": { "top": 76, "left": 125 } }, "commands": [ { "action": "messageSelf", "message": "facing" } ] }, { "event": "onSpawn", "eventsheet": { "position": { "top": 79, "left": 530 } }, "commands": [ { "action": "messageSelf", "message": "y axis" } ] }, { "event": "onMessage", "eventsheet": { "position": { "top": 269, "left": 96 } }, "commands": [ { "action": "ifElse", "condition": { "token": "opGreaterThan", "operand1": { "token": "coordinateXOfNode", "node": { "token": "thisLocation" } }, "operand2": { "token": "coordinateXOfNode", "node": { "token": "locationOfInstance", "instance": { "token": "player" } } } }, "onTrue": [ { "action": "changeXvelocity", "delta": { "token": "opMultiplication", "operand1": null, "operand2": { "token": "distanceToInstance", "instance": { "token": "player" }, "location": { "token": "thisLocation" } } } } ], "onFalse": [ { "action": "changeXvelocity", "delta": { "token": "distanceToInstance", "instance": { "token": "player" }, "location": { "token": "thisLocation" } } } ] }, { "action": "faceObject", "objinstance": { "token": "player" } }, { "action": "messageSelfAfterDelay", "message": "facing", "delay": 100 } ], "messageName": "facing" }, { "event": "onMessage", "eventsheet": { "position": { "top": 274, "left": 609 } }, "commands": [ { "action": "ifElse", "condition": { "token": "opGreaterThan", "operand1": { "token": "coordinateYOfNode", "node": { "token": "thisLocation" } }, "operand2": { "token": "coordinateYOfNode", "node": { "token": "locationOfInstance", "instance": { "token": "player" } } } }, "onTrue": [ { "action": "changeYvelocity", "delta": { "token": "opMultiplication", "operand1": null, "operand2": { "token": "distanceToInstance", "instance": { "token": "player" }, "location": { "token": "thisLocation" } } } } ], "onFalse": [ { "action": "changeYvelocity", "delta": { "token": "distanceToInstance", "instance": { "token": "player" }, "location": { "token": "thisLocation" } } } ] }, { "action": "messageSelfAfterDelay", "message": "y axis", "delay": 100 } ], "messageName": "y axis" }, { "event": "onOutShot", "__eventsheet": { "position": { "top": 105, "left": 826 } }, "commands": [ { "action": "setXvelocity", "velocity": 1 }, { "action": "setYvelocity", "velocity": 1 } ] } ], "variables": {}, "kinds": {} }
Here's a robot I tried to make where it accelerates towards the player based on the value of the distance between the player and the robot. Here's the source code and the before and after screenshots.
http://i40.tinypic.com/111ujbl.png
http://i39.tinypic.com/2lliyhe.jpg
{ "robot": "0.9", "properties": { "displayName": "Unnamed Robot", "description": "Describe your robot here.", "health": "100", "maxhealth": "100", "immortal": true, "solid": false, "physics": false, "name": "Unnamed-Robot" }, "behavior": [ { "event": "onSpawn", "eventsheet": { "position": { "top": 76, "left": 125 } }, "commands": [ { "action": "messageSelf", "message": "facing" } ] }, { "event": "onSpawn", "eventsheet": { "position": { "top": 79, "left": 530 } }, "commands": [ { "action": "messageSelf", "message": "y axis" } ] }, { "event": "onMessage", "eventsheet": { "position": { "top": 269, "left": 96 } }, "commands": [ { "action": "ifElse", "condition": { "token": "opGreaterThan", "operand1": { "token": "coordinateXOfNode", "node": { "token": "thisLocation" } }, "operand2": { "token": "coordinateXOfNode", "node": { "token": "locationOfInstance", "instance": { "token": "player" } } } }, "onTrue": [ { "action": "changeXvelocity", "delta": { "token": "opMultiplication", "operand1": null, "operand2": { "token": "distanceToInstance", "instance": { "token": "player" }, "location": { "token": "thisLocation" } } } } ], "onFalse": [ { "action": "changeXvelocity", "delta": { "token": "distanceToInstance", "instance": { "token": "player" }, "location": { "token": "thisLocation" } } } ] }, { "action": "faceObject", "objinstance": { "token": "player" } }, { "action": "messageSelfAfterDelay", "message": "facing", "delay": 100 } ], "messageName": "facing" }, { "event": "onMessage", "eventsheet": { "position": { "top": 274, "left": 609 } }, "commands": [ { "action": "ifElse", "condition": { "token": "opGreaterThan", "operand1": { "token": "coordinateYOfNode", "node": { "token": "thisLocation" } }, "operand2": { "token": "coordinateYOfNode", "node": { "token": "locationOfInstance", "instance": { "token": "player" } } } }, "onTrue": [ { "action": "changeYvelocity", "delta": { "token": "opMultiplication", "operand1": null, "operand2": { "token": "distanceToInstance", "instance": { "token": "player" }, "location": { "token": "thisLocation" } } } } ], "onFalse": [ { "action": "changeYvelocity", "delta": { "token": "distanceToInstance", "instance": { "token": "player" }, "location": { "token": "thisLocation" } } } ] }, { "action": "messageSelfAfterDelay", "message": "y axis", "delay": 100 } ], "messageName": "y axis" }, { "event": "onOutShot", "__eventsheet": { "position": { "top": 105, "left": 826 } }, "commands": [ { "action": "setXvelocity", "velocity": 1 }, { "action": "setYvelocity", "velocity": 1 } ] } ], "variables": {}, "kinds": {} }