make all games timed games
This commit is contained in:
parent
5cb4c299a3
commit
0e1444ca47
5 changed files with 25 additions and 18 deletions
|
|
@ -1,12 +1,12 @@
|
|||
import { Application, Assets, Container, Sprite, Rectangle } from "pixi.js";
|
||||
import { Game } from "./game";
|
||||
import { TimedGame } from "./timedGame";
|
||||
import { KeyBoardListener, makeDragable, getIntersection } from "../common";
|
||||
|
||||
const itemTypes = { TRASH: "TRASH", HARDWARE: "HARDWARE" };
|
||||
|
||||
export class CleanupHS extends Game {
|
||||
export class CleanupHS extends TimedGame {
|
||||
constructor(width, height) {
|
||||
super();
|
||||
super(10000);
|
||||
|
||||
this._elementCount = this._difficulty * 6;
|
||||
this._elementsPlaced = 0;
|
||||
|
|
@ -14,6 +14,8 @@ export class CleanupHS extends Game {
|
|||
this._scree_w = width;
|
||||
this._scree_h = height;
|
||||
|
||||
this.timeout = this._elementCount * 1000; // 1s per element
|
||||
|
||||
this.gameContainer.layout = {
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
|
|
@ -109,7 +111,7 @@ export class CleanupHS extends Game {
|
|||
}
|
||||
|
||||
if (this._elementsPlaced >= this._elementCount) {
|
||||
this._win();
|
||||
this.end(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import {
|
|||
getIntersection,
|
||||
makeUnDragable,
|
||||
} from "../common";
|
||||
import { Game } from "./game";
|
||||
import { TimedGame } from "./timedGame";
|
||||
|
||||
class DropZone {
|
||||
constructor(sprite) {
|
||||
|
|
@ -22,13 +22,15 @@ class DropZone {
|
|||
}
|
||||
}
|
||||
|
||||
export class Fridge extends Game {
|
||||
export class Fridge extends TimedGame {
|
||||
constructor() {
|
||||
super();
|
||||
super(10000);
|
||||
|
||||
this._bottleCount = 6;
|
||||
this._bottlePlaced = 0;
|
||||
|
||||
this.timeout = this._bottleCount * 1500; // 1.5s per bottle
|
||||
|
||||
const fridgeContainer = new Container();
|
||||
fridgeContainer.layout = { width: "50%" };
|
||||
const fridge = Sprite.from("frigo");
|
||||
|
|
@ -85,16 +87,16 @@ export class Fridge extends Game {
|
|||
sprite.x = 0;
|
||||
sprite.y = 0;
|
||||
}
|
||||
|
||||
for (let i = 0; i < this._bottleCount; i++) {
|
||||
const newBottle = Sprite.from("clubmate");
|
||||
makeDragable(newBottle, (node) => {
|
||||
this._onBottleDrop(node);
|
||||
if (this._bottlePlaced >= this._bottleCount) {
|
||||
this._win();
|
||||
this.end(true);
|
||||
}
|
||||
});
|
||||
this.gameContainer.addChild(newBottle);
|
||||
|
||||
this.bottles.push(newBottle);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,18 @@
|
|||
import { Application, Assets, Container, Sprite } from "pixi.js";
|
||||
import { Game } from "./game";
|
||||
import { TimedGame } from "./timedGame";
|
||||
|
||||
export class Opinator extends Game {
|
||||
export class Opinator extends TimedGame {
|
||||
constructor() {
|
||||
super();
|
||||
super(10000);
|
||||
this._inMove = false; // indicates if player has grabed the wire (is mouse down)
|
||||
this._currentScore = 0;
|
||||
this._pixelGoalScore = undefined;
|
||||
this._goalScore = 8 * this._difficulty; // goal to match, measured in play area, 10 = moving the mouse on the equivalent of 10 play areas
|
||||
this._baseGoalScore = 8;
|
||||
this._goalScore = this._baseGoalScore * this._difficulty; // goal to match, measured in play area, 10 = moving the mouse on the equivalent of 10 play areas
|
||||
this._lastMousePos = undefined; // use to compute the travelled distance
|
||||
|
||||
this.timeout = this._baseGoalScore * 1000; // 1s per sprite len
|
||||
|
||||
this._backgroundSprite = Sprite.from("opinator");
|
||||
|
||||
this._backgroundSprite.eventMode = "static";
|
||||
|
|
@ -48,7 +51,7 @@ export class Opinator extends Game {
|
|||
this._pixelGoalScore,
|
||||
);
|
||||
if (this._pixelGoalScore < this._currentScore) {
|
||||
this._win();
|
||||
this.end(true);
|
||||
}
|
||||
} //else ignore, not enough move to get some distance
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { KeyBoardListener } from "../common";
|
|||
|
||||
export class SmartMonday extends TimedGame {
|
||||
constructor() {
|
||||
super(10000); // 10 chars per second
|
||||
super(10000);
|
||||
|
||||
this._goal = 100 * this._difficulty; // number of characters
|
||||
this.timeout = 1000 * (this._goal / 10); // 10 chars per second
|
||||
|
|
|
|||
|
|
@ -102,10 +102,10 @@ function switchToGame(gameContainer, newGame) {
|
|||
const cleanupHS = new CleanupHS(root.width, root.height);
|
||||
//gameContainter.addChild(fridge.gameContainer);
|
||||
//gameContainter.addChild(opinator.gameContainer);
|
||||
gameContainter.addChild(smartMonday.gameContainer);
|
||||
//gameContainter.addChild(cleanupHS.gameContainer);
|
||||
//gameContainter.addChild(smartMonday.gameContainer);
|
||||
gameContainter.addChild(cleanupHS.gameContainer);
|
||||
|
||||
root.addChild(gameContainter);
|
||||
|
||||
smartMonday.start();
|
||||
cleanupHS.start();
|
||||
})();
|
||||
|
|
|
|||
Loading…
Reference in a new issue