| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- //meteor - Update Every Frame
- //Code below is given up to the next comment where ninjas add to code to "make the game more interesting"
- //Should also talk about where in the game the score is being added.
- moveX($this);
- moveY($this);
- var bullet = $this.scene.projectile;
- if(bullet && $this.isTouching(bullet)){
-
- $this.scaleX($this.scaleX()/2);
- $this.scaleY($this.scaleY()/2);
- $this.offsetX($this.offsetX()/2);
- $this.offsetY($this.offsetY()/2);
-
- $this.scene.projectile = null;
- bullet.remove();
-
- $this.scene.scoreValue++;
- score.text("Score: "+$this.scene.scoreValue);
- /**
- This is where you add the code in step 3, inside the if ($this.isTouching(bullet)) statement
- Good place to have ninja explain what this code is doing
- Review conditionals and comparison operators
- Remember that this section is all about Math
- Draw the connections between math and computer science - math is definitely important in game dev!
- **/
- if (this.scaleX() >= 0.25) {
- var ncircle = $this.clone();
- ncircle.x($this.x()+100);
- } else {
- $this.remove();
- }
- }
- //Ask the ninja what this code is doing
- //It is given to us but we should know what it is doing.
- //They've seen this code in Hungry Ninja,
- //The follow code resets the position of the meteor when he flies off the screen.
- if($this.y()>700){
- $this.y(0);
- }
- if($this.y()<-100){
- $this.y(600);
- }
- if($this.x()>900){
- $this.x(0);
- }
- if($this.x()<-100){
- $this.x(800);
- }
|