Compare commits

...
This repository has been archived on 2025-05-04. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.

3 commits

Author SHA1 Message Date
Code Ninjas Garden Grove
17a36fe194
Update circus-bounce.md 2021-02-10 17:07:13 -08:00
EthanThatOneKid
d270e84a9d
Merge pull request from codeninjasgg/patch-1
Create circus-bounce.md
2021-02-10 17:00:21 -08:00
Code Ninjas Garden Grove
de8be3d977
Create circus-bounce.md 2021-02-10 16:59:03 -08:00

View file

@ -0,0 +1,51 @@
# Circus Bounce
> `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);
}
```