Skip to content
Snippets Groups Projects
Commit f9b1ebc9 authored by Paolo.Brasolin's avatar Paolo.Brasolin
Browse files

feat: #fe input feedback is way snappier

parent c943b14a
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ...@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
### Changed
- `FE` input is centered on screen.
- `FE` submit feedback is now always given and way snappier.
### Fixed ### Fixed
- `FE` player doesn't fall through ground on big screens. - `FE` player doesn't fall through ground on big screens.
......
...@@ -24,6 +24,7 @@ export default class FightScene extends Phaser.Scene { ...@@ -24,6 +24,7 @@ export default class FightScene extends Phaser.Scene {
beGame: Types.Game; beGame: Types.Game;
inputStatus: InputStatus; inputStatus: InputStatus;
typewriter: Typewriter; typewriter: Typewriter;
preview: Phaser.GameObjects.Text;
constructor() { constructor() {
super("fight"); super("fight");
...@@ -59,14 +60,6 @@ export default class FightScene extends Phaser.Scene { ...@@ -59,14 +60,6 @@ export default class FightScene extends Phaser.Scene {
frameWidth: 14, frameWidth: 14,
frameHeight: 33, frameHeight: 33,
}); });
this.load.spritesheet("hit", "assets/sprites/player/hit-sheet.png", {
frameWidth: 469,
frameHeight: 79,
});
this.load.spritesheet("miss", "assets/sprites/player/misssing-sheet.png", {
frameWidth: 466,
frameHeight: 76,
});
} }
async create() { async create() {
...@@ -92,8 +85,6 @@ export default class FightScene extends Phaser.Scene { ...@@ -92,8 +85,6 @@ export default class FightScene extends Phaser.Scene {
createAnim(this, "bear_walk", "bear", 17, 24); createAnim(this, "bear_walk", "bear", 17, 24);
createAnim(this, "spearAni", "spear", 0, 3); createAnim(this, "spearAni", "spear", 0, 3);
createAnim(this, "spearHitAni", "spearhit", 0, 8); createAnim(this, "spearHitAni", "spearhit", 0, 8);
createAnim(this, "hit", "hit", 0, 9);
createAnim(this, "missing", "miss", 0, 6);
this.physics.world.setBounds( this.physics.world.setBounds(
0, 0,
...@@ -161,33 +152,25 @@ export default class FightScene extends Phaser.Scene { ...@@ -161,33 +152,25 @@ export default class FightScene extends Phaser.Scene {
gameStart(this); gameStart(this);
} }
showMissMessage() { showSubmitFeedback(color: string) {
const message = this.add const text = this.add.text(
.sprite( this.cameras.main.width / 2,
this.cameras.main.width / 2, this.cameras.main.height / 2,
(3 * this.cameras.main.height) / 4, this.preview.text,
"miss", {
) font: "bold 64px Courier",
.setScale(1); color: color,
message.play({ key: "missing", repeat: 1 }); },
message.on("animationcomplete", () => { );
message.anims.remove("miss"); text.setOrigin(0.5, 0.5);
message.destroy(); this.tweens.add({
}); targets: text,
} scaleX: 5,
scaleY: 5,
showHitMessage() { alpha: 0,
const message = this.add ease: "Power2",
.sprite( duration: 500,
this.cameras.main.width / 2, onComplete: (_tween, [target]) => target.destroy(),
(3 * this.cameras.main.height) / 4,
"hit",
)
.setScale(1);
message.play({ key: "hit", repeat: 1 });
message.on("animationcomplete", () => {
message.anims.remove("hit");
message.destroy();
}); });
} }
...@@ -235,23 +218,30 @@ export default class FightScene extends Phaser.Scene { ...@@ -235,23 +218,30 @@ export default class FightScene extends Phaser.Scene {
// TODO: visual near misses based on score // TODO: visual near misses based on score
if (match === null) { if (match === null) {
// NOOP // NOOP
this.showSubmitFeedback("#FFFFFF");
} else if (score < 0.9) { } else if (score < 0.9) {
match.handleFailure(); match.handleFailure();
this.showMissMessage(); this.showSubmitFeedback("#FF0000");
new Spear(this, this.player, undefined); new Spear(this, this.player, undefined);
} else { } else {
this.popFoe(match); this.popFoe(match);
match.handleSuccess(); match.handleSuccess();
this.showHitMessage(); this.showSubmitFeedback("#00FF00");
new Spear(this, this.player, match.critter); new Spear(this, this.player, match.critter);
} }
} }
initAndBindGuessPreview() { initAndBindGuessPreview() {
const textEntry = this.add.text(100, this.cameras.main.height / 2, "", { this.preview = this.add.text(
font: "bold 64px Courier", this.cameras.main.width / 2,
color: "#ffffff", this.cameras.main.height / 2,
}); "",
{
font: "bold 64px Courier",
color: "#ffffff",
},
);
this.preview.setOrigin(0.5, 0.5);
this.typewriter = new Typewriter(); this.typewriter = new Typewriter();
this.typewriter.setHidden(this.game.device.os.desktop); this.typewriter.setHidden(this.game.device.os.desktop);
this.typewriter.onSubmit = (inputStatus) => { this.typewriter.onSubmit = (inputStatus) => {
...@@ -264,10 +254,10 @@ export default class FightScene extends Phaser.Scene { ...@@ -264,10 +254,10 @@ export default class FightScene extends Phaser.Scene {
typed: inputStatus.typed, typed: inputStatus.typed,
final: inputStatus.final, final: inputStatus.final,
}); });
textEntry.text = ""; this.preview.text = "";
}; };
this.typewriter.onChange = (inputStatus) => { this.typewriter.onChange = (inputStatus) => {
textEntry.text = inputStatus.final; this.preview.text = inputStatus.final;
}; };
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment