aboutsummaryrefslogtreecommitdiffstats
path: root/src/enemies/BigCircle.ts
diff options
context:
space:
mode:
authorMaksymilian Jopek <maks@jopek.eu>2022-05-25 22:55:57 +0200
committerMaksymilian Jopek <maks@jopek.eu>2022-05-25 22:55:57 +0200
commit344737031e5bbad5f24469aabf45be6535c893f3 (patch)
tree89f7312b24a2f9f6c7d48ddb1f0b5874939f6d21 /src/enemies/BigCircle.ts
parent2f8b8c87fb2062313afea7b625ccb20d1bea95b9 (diff)
download1942-344737031e5bbad5f24469aabf45be6535c893f3.tar.gz
1942-344737031e5bbad5f24469aabf45be6535c893f3.tar.zst
1942-344737031e5bbad5f24469aabf45be6535c893f3.zip
Numbers and better rectangles
Diffstat (limited to 'src/enemies/BigCircle.ts')
-rw-r--r--src/enemies/BigCircle.ts223
1 files changed, 143 insertions, 80 deletions
diff --git a/src/enemies/BigCircle.ts b/src/enemies/BigCircle.ts
index 3a5506c..233491d 100644
--- a/src/enemies/BigCircle.ts
+++ b/src/enemies/BigCircle.ts
@@ -1,6 +1,6 @@
import { canvas } from "../consts";
-// import { keys } from "../Events";
import { Rectangle } from "../Drawable";
+import { keys } from "../Events";
import { IMGS } from "../Images";
import Enemy from "./Enemy";
@@ -8,18 +8,10 @@ export default class BigCircle extends Enemy {
width = 48
height = 40
sprite: HTMLImageElement | string = IMGS.bigCircleDown;
- sprites = ["pink", "red", "blue", "green", "black", "white"]
- vel = 1.8
+ vel = 2
phase = 0;
- squares: Rectangle[] = [
- // new Rectangle(this.x, this.y, this.width, this.height),
- new Rectangle(this, 14, 0, 20, 8),
- new Rectangle(this, 20, 7, 8, 12),
- new Rectangle(this, 0, 20, 48, 20),
- ]
-
counter = 0;
move() {
if (this.sprite instanceof HTMLImageElement && this.sprite.src == null) this.sprite = IMGS.bigCircleDown
@@ -30,120 +22,191 @@ export default class BigCircle extends Enemy {
switch (this.phase) {
case 0:
+ this.squares = this.allSqaures.bigCircleDown;
yShift = this.vel;
// if (this.y2 > 124) { this.phase++; keys.fps = 1 }
if (this.y2 > 124) this.phase++
break;
case 1:
+ keys.fps = 1
this.sprite = IMGS.bigCircleDownToRight1;
- // this.squares = [new Rectangle(this.x, this.y, this.width, this.height)]
+ this.squares = this.allSqaures.bigCircleDownToRight1;
+ this.counter = 0;
this.phase++;
break;
case 2:
yShift = this.vel;
xShift = this.vel;
- this.phase++;
+ if (this.counter++ === 3) this.phase++;
break;
case 3:
this.sprite = IMGS.bigCircleDownToRight2;
- // this.squares = [new Rectangle(this.x, this.y, this.width, this.height)]
+ this.squares = this.allSqaures.bigCircleDownToRight2;
this.counter = 0;
this.phase++;
break;
case 4:
xShift = this.vel;
yShift = this.vel;
- if (this.counter++ === 1) this.phase++;
+ if (this.counter++ === 3) this.phase++;
break;
case 5:
this.sprite = IMGS.bigCircleDownToRight3;
- // this.squares = [new Rectangle(this.x, this.y, this.width, this.height)]
+ this.squares = this.allSqaures.bigCircleDownToRight3;
+ this.counter = 0;
this.phase++;
break;
case 6:
xShift = this.vel;
yShift = this.vel;
- this.phase++;
+ if (this.counter++ === 3) this.phase++;
break;
case 7:
this.sprite = IMGS.bigCircleRight;
- // width = 48
- // height = 40
- this.squares[0].change(0, 14, 8, 16);
- this.squares[1].change(0, 18, 44, 8);
- this.squares[2].change(22, 0, 14, 43);
- // new Rectangle(this.x + 20, this.y + 7, 8, 12),
- // new Rectangle(this.x, this.y + 20, 48, 20),
+ this.squares = this.allSqaures.bigCircleRight;
this.phase++;
break;
case 8:
+ keys.fps = 50
xShift = this.vel;
+ if(this.x2 > 184) this.phase++;
+ break;
+ case 9:
+ keys.fps = 1
+ this.sprite = IMGS.bigCircleRightToUp1;
+ this.phase++;
+ this.counter = 0;
+ break;
+ case 10:
+ xShift = this.vel
+ yShift = -this.vel
+ if (this.counter++ === 3) this.phase++;
+ break;
+ case 11:
+ this.sprite = IMGS.bigCircleRightToUp2;
+ this.phase++;
+ this.counter = 0;
+ break;
+ case 12:
+ xShift = this.vel
+ yShift = -this.vel
+ if (this.counter++ === 3) this.phase++;
+ break;
+ case 13:
+ this.sprite = IMGS.bigCircleRightToUp3;
+ this.phase++;
+ this.counter = 0;
+ break;
+ case 14:
+ xShift = this.vel
+ yShift = -this.vel
+ if (this.counter++ === 3) this.phase++;
+ break;
+ case 15:
+ this.sprite = IMGS.bigCircleUp;
+ this.phase++;
+ break;
+ case 16:
+ yShift = -this.vel;
+ if(this.y < 50) this.phase++;
+ break;
+ // uptoleft at 77 + 24 + ~8
+ // leftToDown at 268
+ case 17:
+ this.sprite = IMGS.bigCircleUpToLeft1;
+ this.phase++;
+ this.counter = 0;
+ break;
+ case 18:
+ xShift = -this.vel
+ yShift = -this.vel
+ if (this.counter++ === 3) this.phase++;
+ break;
+ case 19:
+ this.sprite = IMGS.bigCircleUpToLeft2;
+ this.phase++;
+ this.counter = 0;
+ break;
+ case 20:
+ xShift = -this.vel
+ yShift = -this.vel
+ if (this.counter++ === 3) this.phase++;
+ break;
+ case 21:
+ this.sprite = IMGS.bigCircleUpToLeft3;
+ this.phase++;
+ this.counter = 0;
+ break;
+ case 22:
+ xShift = -this.vel
+ yShift = -this.vel
+ if (this.counter++ === 3) this.phase++;
+ break;
+ case 23:
+ this.sprite = IMGS.bigCircleLeft;
+ this.phase++;
+ this.counter = 0;
+ break;
+ case 24:
+ xShift = -this.vel
+ if (this.x < 49) this.phase++;
+ break;
+ case 25:
+ this.sprite = IMGS.bigCircleLeftToDown1;
+ this.phase++;
+ this.counter = 0;
+ break;
+ case 26:
+ xShift = -this.vel
+ yShift = this.vel
+ if (this.counter++ === 3) this.phase++;
+ break;
+ case 27:
+ this.sprite = IMGS.bigCircleLeftToDown2;
+ this.phase++;
+ this.counter = 0;
+ break;
+ case 28:
+ xShift = -this.vel
+ yShift = this.vel
+ if (this.counter++ === 3) this.phase++;
+ break;
+ case 29:
+ this.sprite = IMGS.bigCircleLeftToDown3;
+ this.phase++;
+ this.counter = 0;
+ break;
+ case 30:
+ xShift = -this.vel
+ yShift = this.vel
+ if (this.counter++ === 3) this.phase++;
+ break;
+ case 31:
+ this.sprite = IMGS.bigCircleDown;
+ this.phase++;
+ this.counter = 0;
+ break;
+ case 32:
+ yShift = this.vel
+ // yShift = this.vel
+ // if (this.counter++ === 3) this.phase++;
break;
- // case 4:
- // // this.sprite = this.sprites[3];
- // xShift = this.vel;
- // yShift = this.vel;
- // if (this.y2 > 160) this.phase++;
- // break;
- // case 5:
- // // this.sprite = this.sprites[0];
- // xShift = this.vel;
- // if (this.x2 > 150) this.phase++;
- // break;
- // case 6:
- // // this.sprite = this.sprites[1];
- // yShift = -this.vel;
- // xShift = this.vel;
- // if (this.x2 > 220) this.phase++;
- // break;
- // case 7:
- // // this.sprite = this.sprites[2];
- // yShift = -this.vel;
- // xShift = this.vel;
- // if (this.x2 > 240) this.phase++;
- // break;
- // case 8:
- // // this.sprite = this.sprites[3];
- // yShift = -this.vel;
- // xShift = this.vel;
- // if (this.x2 > 260) this.phase++;
- // break;
- // case 9:
- // // this.sprite = this.sprites[0];
- // yShift = -this.vel;
- // if (this.y < 50) this.phase++;
- // break;
- // case 10:
- // yShift = -this.vel
-
default:
break;
}
- // if (this.y > 80 && this.phase === 0) this.phase++;
- // else if (this.x > 40) this.phase++;
-
- // if (this.x === 25 && this.y < 100) {
- // yShift = this.vel
- // } else if (this.y.toFixed(0) === '101' && this.x < 200) {
- // xShift = this.vel
- // } else if (this.y > 20) {
- // yShift = -this.vel;
- // } else if (this.x > 25) {
- // xShift = -this.vel;
- // } else {
- // yShift = this.vel;
- // }
-
this.x += xShift;
this.y += yShift;
- // for (const s of this.squares) {
- // s.x += xShift;
- // s.y += yShift;
- // }
-
return this.x2 < 0 || this.y2 < 0 || this.x > canvas.width || this.y > canvas.height
}
+ readonly allSqaures = {
+ bigCircleDown: [new Rectangle(this, 14, 0, 20, 8), new Rectangle(this, 20, 0, 8, 40), new Rectangle(this, 0, 22, 48, 12)],
+ bigCircleDownToRight1: [new Rectangle(this, 4, 0, 14, 16), new Rectangle(this, 14, 10, 24, 20), new Rectangle(this, 0, 20, 24, 20)],
+ bigCircleDownToRight2: [new Rectangle(this, 0, 0, 14, 14), new Rectangle(this, 14, 14, 22, 22), new Rectangle(this, 28, 6, 14, 14), new Rectangle(this, 8, 28, 12, 14)],
+ bigCircleDownToRight3: [new Rectangle(this, 0, 2, 10, 22), new Rectangle(this, 10, 12, 30, 8), new Rectangle(this, 26, 0, 16, 12), new Rectangle(this, 18, 20, 24, 10), new Rectangle(this, 14, 30, 16, 12)],
+ bigCircleRight: [ new Rectangle(this, 0, 14, 8, 16), new Rectangle(this, 0, 18, 44, 8), new Rectangle(this, 22, 0, 14, 43), ],
+ };
+
}