12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- function HeartDestination(startx, starty) {
- var position = {x : startx, y: starty};
- var expiration = 1000;
- this.isConsumed = false;
- var level = 1;
- var delay = 25;
- this.init = function(canvas) {
- expiration = 1000;
- };
- this.update = function(canvas) {
- expiration--;
- if(expiration <= 0) {
- this.isConsumed = true;
- }
- };
- this.draw = function(context, offset) {
- context.beginPath();
- context.strokeStyle = "#FF0000";
- context.rect(position.x - 5, position.y - 5, 10, 10);
- context.stroke();
- };
- this.getPosition = function() {
- return position;
- }
- this.visit = function(hero) {
- hero.actionDelay(25);
- if(hero.addHeart(level)) {
- this.isConsumed = true;
- }
- return this;
- }
- this.getType = function() {
- return "heart";
- }
- this.mouseMove = function(canvas, x, y) {
- };
- this.getName = function() {
- return this.getType();
- }
- this.getLevel = function() {
- return level;
- }
- }
|