random ints
This commit is contained in:
parent
6c0e850180
commit
4c77c5f472
|
@ -522,8 +522,9 @@ Math.angledist = function (a1, a2) {
|
||||||
return wrap;
|
return wrap;
|
||||||
};
|
};
|
||||||
|
|
||||||
Math.deg2rad = function(deg) { return deg * 0.0174533; }
|
Math.deg2rad = function(deg) { return deg * 0.0174533; };
|
||||||
Math.rad2deg = function(rad) { return rad / 0.0174533; }
|
Math.rad2deg = function(rad) { return rad / 0.0174533; };
|
||||||
|
Math.randomint = function(max) { return Math.clamp(Math.floor(Math.random() * max), 0, max-1); };
|
||||||
|
|
||||||
/* BOUNDINGBOXES */
|
/* BOUNDINGBOXES */
|
||||||
function cwh2bb(c, wh) {
|
function cwh2bb(c, wh) {
|
||||||
|
|
|
@ -1704,6 +1704,12 @@ var gameobject = {
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
instandup() {
|
||||||
|
var dup = World.spawn(gameobjects[this.from]);
|
||||||
|
dup.pos = this.pos;
|
||||||
|
dup.velocity = this.velocity;
|
||||||
|
},
|
||||||
|
|
||||||
ed_locked: false,
|
ed_locked: false,
|
||||||
|
|
||||||
|
@ -1741,7 +1747,6 @@ var gameobject = {
|
||||||
flipx: false,
|
flipx: false,
|
||||||
flipy: false,
|
flipy: false,
|
||||||
|
|
||||||
|
|
||||||
body: -1,
|
body: -1,
|
||||||
controlled: false,
|
controlled: false,
|
||||||
|
|
||||||
|
@ -1840,12 +1845,13 @@ var gameobject = {
|
||||||
get boundingbox() {
|
get boundingbox() {
|
||||||
var boxes = [];
|
var boxes = [];
|
||||||
boxes.push({t:0, r:0,b:0,l:0});
|
boxes.push({t:0, r:0,b:0,l:0});
|
||||||
|
|
||||||
for (var key in this.components) {
|
for (var key in this.components) {
|
||||||
if ('boundingbox' in this.components[key])
|
if ('boundingbox' in this.components[key])
|
||||||
boxes.push(this.components[key].boundingbox);
|
boxes.push(this.components[key].boundingbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (boxes.empty) return;
|
if (boxes.empty) return cwh2bb([0,0], [0,0]);
|
||||||
|
|
||||||
var bb = boxes[0];
|
var bb = boxes[0];
|
||||||
|
|
||||||
|
@ -1880,6 +1886,8 @@ var gameobject = {
|
||||||
|
|
||||||
stop() {},
|
stop() {},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
kill() {
|
kill() {
|
||||||
if (this.body === -1) {
|
if (this.body === -1) {
|
||||||
Log.warn(`Object is already dead!`);
|
Log.warn(`Object is already dead!`);
|
||||||
|
@ -2201,4 +2209,4 @@ for (var key in prototypes) {
|
||||||
|
|
||||||
function save_gameobjects_as_prototypes() { slurpwrite(JSON.stringify(gameobjects,null,2), "proto.json"); };
|
function save_gameobjects_as_prototypes() { slurpwrite(JSON.stringify(gameobjects,null,2), "proto.json"); };
|
||||||
|
|
||||||
let Gamestate = {};
|
var Gamestate = {};
|
||||||
|
|
Loading…
Reference in a new issue