瀏覽代碼

Add Green Belt - Rooftop Runner

Michael Tang 2 年之前
父節點
當前提交
1498ba0464
共有 2 個文件被更改,包括 28 次插入0 次删除
  1. 二進制
      .DS_Store
  2. 28 0
      04-green/01-rooftop-runner.js

二進制
.DS_Store


+ 28 - 0
04-green/01-rooftop-runner.js

@@ -0,0 +1,28 @@
+// Setting the Scene
+// Common error is that ninjas add the asset to an existing asset thereby creating a unintended group. 
+// Teach ninjas to always go back to the scene before pressing the add asset button.
+
+// It's very easy for ninjas to neglect to set roles or speedX, or other properties because they are only looking
+// at pictures in the manual. When reading carefully, they should notice that the manual
+// asks SpeedX, roles, and positions (x,y, z) are provided for every object
+
+// background z 0
+// rooftop z 1
+// runner z 5 (higher than rooftops) ensures that it shows up on top
+
+//**************************** rooftop1 - Update Every Frame ********************************/
+// rooftop is always moving 
+// ensure speedX is set to -200 
+$this.moveX();
+
+if($this.x() <= -800) {
+    $this.x(1200);
+    $this.y(random(550,300));
+}
+
+//*************************** rooftop1 - Initialize When Scene Starts ***********************/
+// sets initial rooftop x and randomizes y (height)
+$this.x(0);
+$this.y(random(550, 300));
+
+//*************************** rooftop2 - Update When Scene Starts ***************************/