Explorar el Código

Add Meteors Part 2

michtang hace 3 años
padre
commit
80cc82b882

02-yellow/01-05 → 02-yellow/01-05-rain-catcher-pt-5.js


02-yellow/01-06 → 02-yellow/01-06-rain-catcher-pt-6.js


+ 7 - 1
02-yellow/02-01

@@ -6,7 +6,10 @@ var upPressed = isKeyPressed(Keys.upArrow);
 var spacePressed = isKeyPressed(Keys.space);
 var bullet =  $this.findName("bullet");
 
-//keypress conditionals
+//keypress conditionals\
+//The following control the shooting and up arrow 
+//controls which are pre-loaded.
+//The only code required is the code in the meteor
 if(spacePressed){
    //bullet.moving = true;
    if(!$this.scene.projectile)
@@ -51,5 +54,8 @@ if($this.x()<0){
     $this.x(800);
 }
 //meteor - Initialize When Scene Starts
+//Part 1 explores random() and this is a good
+//place to talk to the ninja about the random()
+//function as well as review how variables are used.
 var rot = random(359);
 $this.rotation(rot);

+ 9 - 1
02-yellow/02-02

@@ -1,4 +1,6 @@
 //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);
 
@@ -18,6 +20,9 @@ if(bullet && $this.isTouching(bullet)){
     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);
@@ -25,7 +30,10 @@ if(bullet && $this.isTouching(bullet)){
         $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);
 }

+ 6 - 1
02-yellow/PY-RollingDice

@@ -1,3 +1,5 @@
+//CN Sensei Guide Solution
+
 //Scene - Initialize when Scene Starts
 $this.dieClick=false;
 
@@ -20,7 +22,10 @@ if(!$this.scene.dieClick){
     $this.scene.dieClick=true;
 }
 
-//alternate solution
+//Alternate Solution - how our senseis teach it
+//We eliminate the use of the boolean to detect the mouse
+//click which is a topic taught in the next section
+
 //die1 - Mouse Click Event
 //Use random() to generate numbers to simulate die roll. 
 //Good place to teach ninjas about the possible numbers when running random(5) - 0,1,2,3,4,5