04-06-shuriken-toss-pt-2.js 671 B

12345678910111213141516171819202122
  1. /**
  2. This lesson combines some of the more complex functions ninjas have learned so far
  3. like pointToCursor(),rotation() and moveForwardByRotation().
  4. They will also create and manipulate object properties.
  5. */
  6. //********************Star Object - Update Every Frame******************//
  7. if($this.thrown && $this.x() > 0 && $this.y() > 0 && $this.x() < 800 && $this.y() < 600 ){
  8. $this.moveForwardByRotation();
  9. }else{
  10. $this.thrown = false;
  11. $this.x(454);
  12. $this.y(462);
  13. }
  14. //*********************Background Object - Mouse Click Event************//
  15. if(!star.thrown){
  16. star.pointToCursor();
  17. star.rotation(star.rotation() -90);
  18. star.thrown=true;
  19. }