42 lines
No EOL
1.3 KiB
JavaScript
42 lines
No EOL
1.3 KiB
JavaScript
(function() {
|
|
var _this;
|
|
var _entityID;
|
|
|
|
function quarterCoin() {
|
|
_this = this;
|
|
}
|
|
quarterCoin.prototype = {
|
|
preload: function(entityID) {
|
|
_this.entityID = entityID;
|
|
print("Preloaded coin");
|
|
},
|
|
mouseReleaseOnEntity: function(otherEntity) {
|
|
launchCoin();
|
|
print("launch");
|
|
},
|
|
stopFarTrigger: function(otherEntity) {
|
|
launchCoin();
|
|
print("launch");
|
|
}
|
|
};
|
|
|
|
function launchCoin() {
|
|
var entityProperties = Entities.getEntityProperties(_this.entityID);
|
|
entityProperties.velocity = { "x": Math.floor(Math.random() * 1) * 3, "y": 5, "z": 0 };
|
|
entityProperties.acceleration = { "x": 0, "y": 5, "z": 0 };
|
|
var randX = Math.floor(Math.random() * 10);
|
|
var randY = Math.floor(Math.random() * 10);
|
|
var randZ = Math.floor(Math.random() * 10);
|
|
|
|
Entities.editEntity(_this.entityID, {
|
|
velocity: { x: 0, y: 5, z: 0 },
|
|
acceleration: { x: 0, y: 5, z: 0 },
|
|
angularVelocity: { x: randX * 3, y: randY * 3, z: randZ * 3}
|
|
});
|
|
|
|
print("launched " + _this.entityID);
|
|
print(entityProperties.velocity);
|
|
}
|
|
|
|
return new quarterCoin();
|
|
}); |