mirror of
https://github.com/codeninjasgg/code-sensei.git
synced 2025-02-17 00:30:22 -05:00
Update circus-bounce.md
This commit is contained in:
parent
d270e84a9d
commit
17a36fe194
1 changed files with 44 additions and 1 deletions
|
@ -1,8 +1,51 @@
|
|||
# Circus Bounce
|
||||
|
||||
> Scene, Update Every Frame
|
||||
> `scene`, Initialize When Scene Starts
|
||||
|
||||
```js
|
||||
$this.startSpeed = -100;
|
||||
$this.gravity = 5;
|
||||
$this.launchNinja = function() {
|
||||
let startX = 100;
|
||||
ninja.x(startX);
|
||||
let startY = 400;
|
||||
ninja.y(startY);
|
||||
ninja.speedY($this.startSpeed);
|
||||
};
|
||||
|
||||
if ($this.scene.state() === "PLAY") {
|
||||
$this.launchNinja();
|
||||
}
|
||||
```
|
||||
|
||||
> `scene`, Update Every Frame
|
||||
|
||||
```js
|
||||
const spinSpeed = 50;
|
||||
ninja.spin(spinSpeed);
|
||||
```
|
||||
|
||||
> `ninja`, Update Every Frame
|
||||
|
||||
```js
|
||||
$this.moveX($this.speedX());
|
||||
$this.speedY(ninja.speedY() + $this.scene.gravity);
|
||||
$this.moveY($this.speedY());
|
||||
|
||||
if ($this.x() >= 850) {
|
||||
ninja.x(-10);
|
||||
}
|
||||
|
||||
if ($this.y() >= 650) {
|
||||
$this.scene.stopCode();
|
||||
}
|
||||
```
|
||||
|
||||
> `trampoline`, Update Every Frame
|
||||
|
||||
```js
|
||||
$this.x(getPointerPos().x);
|
||||
if ($this.isTouching(ninja)) {
|
||||
ninja.speedY($this.scene.startSpeed);
|
||||
}
|
||||
```
|
||||
|
|
Loading…
Reference in a new issue