coindestination.js 884 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. function CoinDestination(startx, starty, coinValue) {
  2. var position = {x : startx, y: starty};
  3. this.isConsumed = false;
  4. var value = coinValue;
  5. var delay = 25;
  6. this.init = function(canvas) {
  7. };
  8. this.update = function(canvas) {
  9. };
  10. this.draw = function(context, offset) {
  11. context.beginPath();
  12. context.strokeStyle = "#FFFF00";
  13. var size = 10 * (value + 1);
  14. var mid = size / 2;
  15. context.rect(position.x - mid, position.y - mid, size, size);
  16. context.stroke();
  17. };
  18. this.getPosition = function() {
  19. return position;
  20. }
  21. this.visit = function(hero) {
  22. hero.actionDelay(delay);
  23. hero.addCoin(Math.pow(10, value));
  24. this.isConsumed = true;
  25. return this;
  26. }
  27. this.getType = function() {
  28. return "coin";
  29. }
  30. this.mouseMove = function(canvas, x, y) {
  31. };
  32. this.getName = function() {
  33. return this.getType();
  34. }
  35. this.getLevel = function() {
  36. return value;
  37. }
  38. }