katbugjs/Catbug.js

33 lines
472 B
JavaScript

var catbug = {
x: 45,
y: 90,
vX: 0,
vY: 0,
frame: 0,
HP: 3,
maxHP: 3
};
catbug.move = function()
{
this.x += this.vX;
this.y += this.vY;
if (this.x <= 0 || this.x >= 320)
{
this.x -= this.vX;
}
if (this.y <= 0 || this.y >= 180)
{
this.y -= this.vY;
}
}
catbug.isInRect = function(box)
{
if (this.x >= box.x && this.x <= box.x + box.w
&& this.y >= box.y && this.y <= box.y + box.h)
{
return true;
}
return false;
}