Skip to content

Commit 0bad661

Browse files
committed
Bird reset
1 parent c29be1e commit 0bad661

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

project/MyBird/MyBird.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ export class MyBird extends CGFobject {
2020
this.setLegs()
2121
this.setHat()
2222
this.setTail()
23+
24+
this.xInitial = position[0];
25+
this.yInitial = position[1];
26+
this.zInitial = position[2];
2327

2428
this.x = position[0];
2529
this.y = position[1];
@@ -29,14 +33,14 @@ export class MyBird extends CGFobject {
2933
this.scaleFactor = scaleFactor;
3034

3135
this.oscillatoryY = 0;
32-
this.velocity = 0;
3336
this.wingAngleVariation = 0;
34-
37+
3538
this.accelerating = 0;
3639
this.turning = 0;
37-
40+
3841
this._MAX_VELOCITY = 3;
39-
42+
43+
this.velocity = 0;
4044
this.rotation = 0;
4145
}
4246

@@ -108,6 +112,21 @@ export class MyBird extends CGFobject {
108112

109113
clamp(a, min = 0, max = 1) { return Math.min(max, Math.max(min, a)); }
110114

115+
reset() {
116+
this.x = this.xInitial;
117+
this.y = this.yInitial;
118+
this.z = this.zInitial;
119+
120+
this.oscillatoryY = 0;
121+
this.wingAngleVariation = 0;
122+
123+
this.accelerating = 0;
124+
this.turning = 0;
125+
126+
this.velocity = 0;
127+
this.rotation = 0;
128+
}
129+
111130
turn(v) {
112131
this.turning = v;
113132
}

project/MyInterface.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class MyInterface extends CGFinterface {
2727
f0.add(this.scene, "birdSpeedFactor", 0.1, 3)
2828
.name("Speed Factor")
2929
.onChange(this.scene.updateBirdFactors.bind(this.scene));
30-
f0.add(this.scene, "birdScaleFactor", 0.1, 3)
30+
f0.add(this.scene, "birdScaleFactor", 0.1, 5)
3131
.name("Scale Factor")
3232
.onChange(this.scene.updateBirdFactors.bind(this.scene));
3333
var f1 = this.gui.addFolder("Panorama");

project/MyScene.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ export class MyScene extends CGFscene {
178178
this.bird.turn(-1);
179179
if (this.gui.isKeyPressed("ArrowLeft"))
180180
this.bird.turn(1)
181+
if (this.gui.isKeyPressed("KeyR"))
182+
this.bird.reset()
181183
}
182184

183185
display() {

0 commit comments

Comments
 (0)