Merge branch 'master' of ssh://cryps.gg:40022/~/cryps
This commit is contained in:
commit
6dcab420fd
@ -1,10 +1,11 @@
|
|||||||
const Phaser = require('phaser');
|
const Phaser = require('phaser');
|
||||||
|
|
||||||
class LineBox extends Phaser.GameObjects.Graphics {
|
class LineBox extends Phaser.GameObjects.Graphics {
|
||||||
constructor(scene, x0, x1, y0, y1, speed) {
|
constructor(scene, x, y, width, height, colour, speed) {
|
||||||
super(scene);
|
super(scene);
|
||||||
this.x0 = x0; this.x1 = x1;
|
this.colour = colour;
|
||||||
this.y0 = y0; this.y1 = y1;
|
this.x0 = x; this.x1 = x + width;
|
||||||
|
this.y0 = y; this.y1 = y + height;
|
||||||
const margin = Math.abs(Math.floor((this.x1 - this.x0) / 4));
|
const margin = Math.abs(Math.floor((this.x1 - this.x0) / 4));
|
||||||
this.lineCoord = [this.x0 + margin, this.x1 - margin, this.y0, this.y0, 0];
|
this.lineCoord = [this.x0 + margin, this.x1 - margin, this.y0, this.y0, 0];
|
||||||
this.speed = speed;
|
this.speed = speed;
|
||||||
@ -13,7 +14,7 @@ class LineBox extends Phaser.GameObjects.Graphics {
|
|||||||
update() {
|
update() {
|
||||||
this.clear();
|
this.clear();
|
||||||
|
|
||||||
let vertX = this.x1 + 2;
|
let vertX = this.x1;
|
||||||
let horizY = this.y0;
|
let horizY = this.y0;
|
||||||
const genLine = () => {
|
const genLine = () => {
|
||||||
switch (this.lineCoord[4]) {
|
switch (this.lineCoord[4]) {
|
||||||
@ -57,8 +58,7 @@ class LineBox extends Phaser.GameObjects.Graphics {
|
|||||||
return delta[j];
|
return delta[j];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
this.lineStyle(5, this.colour, 1);
|
||||||
this.lineStyle(5, 0xFF00FF, 1);
|
|
||||||
this.lineBetween(this.lineCoord[0], horizY, this.lineCoord[1], horizY);
|
this.lineBetween(this.lineCoord[0], horizY, this.lineCoord[1], horizY);
|
||||||
this.lineBetween(vertX, this.lineCoord[2], vertX, this.lineCoord[3]);
|
this.lineBetween(vertX, this.lineCoord[2], vertX, this.lineCoord[3]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,36 +53,36 @@ class HomeCrypList extends Phaser.Scene {
|
|||||||
// Selection of cryps
|
// Selection of cryps
|
||||||
|
|
||||||
// Cryp avatar and interaction box
|
// Cryp avatar and interaction box
|
||||||
const crypInteract = this.add
|
const cReady = this.add
|
||||||
.rectangle(ROW_X, ROW_Y + ROW_HEIGHT * 0.2, BOX_WIDTH * 2, ROW_HEIGHT, FILL)
|
.rectangle(ROW_X, ROW_Y + ROW_HEIGHT * 0.2, BOX_WIDTH * 2, ROW_HEIGHT, FILL)
|
||||||
.setInteractive()
|
.setInteractive()
|
||||||
.setOrigin(0);
|
.setOrigin(0);
|
||||||
crypInteract.setAlpha(0.2);
|
cReady.setAlpha(0.2);
|
||||||
crypInteract.on('pointerdown', () => {
|
cReady.on('pointerdown', () => {
|
||||||
lineGroup.clear(true, true);
|
lineGroup.clear(true, true);
|
||||||
if (this.activeCryps.includes(crypInteract)) {
|
if (this.activeCryps.includes(cReady)) {
|
||||||
remove(this.activeCryps, n => n === crypInteract);
|
remove(this.activeCryps, n => n === cReady);
|
||||||
crypInteract.setAlpha(0.2);
|
cReady.setAlpha(0.2);
|
||||||
} else {
|
} else {
|
||||||
this.activeCryps.push(crypInteract);
|
this.activeCryps.push(cReady);
|
||||||
crypInteract.setAlpha(0.75);
|
cReady.setAlpha(0.75);
|
||||||
lineGroup.add(this.add.existing(
|
lineGroup.add(this.add.existing(
|
||||||
new LineBox(this, crypInteract.x, crypInteract.y, crypInteract.width, crypInteract.height, crypInteract.fillColor, 3)
|
new LineBox(this, cReady.x, cReady.y, cReady.width, cReady.height, cReady.fillColor, 3)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
crypInteract.itemSelect = () => {
|
cReady.itemSelect = () => {
|
||||||
crypInteract.setFillStyle(COLOURS.SELECT);
|
cReady.setFillStyle(COLOURS.SELECT);
|
||||||
};
|
};
|
||||||
crypInteract.itemDeselect = () => {
|
cReady.itemDeselect = () => {
|
||||||
crypInteract.setFillStyle(FILL, ACTIVE_FILL);
|
cReady.setFillStyle(FILL, ACTIVE_FILL);
|
||||||
};
|
};
|
||||||
|
|
||||||
crypInteract.cryp = cryp;
|
cReady.cryp = cryp;
|
||||||
this.add.image(
|
this.add.image(
|
||||||
crypInteract.getCenter().x,
|
cReady.getCenter().x,
|
||||||
crypInteract.getCenter().y,
|
cReady.getCenter().y,
|
||||||
'aztec',
|
'aztec',
|
||||||
genAvatar(cryp.name)
|
genAvatar(cryp.name)
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user