foxy-moxy/js/fox.js

52 lines
949 B
JavaScript
Raw Normal View History

2016-12-15 20:06:02 +00:00
// TODO: use query params for these
var gen = require('random-seed');
var IMG_WIDTH = 64;
var IMG_HEIGHT = 64;
// move to helper function
var genBetween = function (min, max) {
return min + (max - min) * gen();
}
2016-12-15 20:06:02 +00:00
var randomFox = (function () {
// head top left corner
var origin = Point(IMG_WIDTH / 4, IMG_HEIGHT / 4);
// head width and height
var width = IMG_WIDTH / 2;
var height = IMG_HEIGHT / 2;
var ears = (function () {
var offsetX = genBetween(0, width/2);
2016-12-15 20:06:02 +00:00
return {
left: {
x: origin.x + (width/2) - offsetX,
y: origin.y
2016-12-15 20:06:02 +00:00
},
right: {
x: origin.x + (width/2) + offsetX,
y: origin.y
2016-12-15 20:06:02 +00:00
}
};
}());
var eyes = (function () {
// TODO: generate stuff
return {
};
}());
2016-12-15 20:06:02 +00:00
return {
shape: {
origin: origin,
width: width,
height: height
},
2016-12-15 20:06:02 +00:00
ears: ears,
eyes: eyes,
nose: nose,
mouth: mouth
};
}());