added entitys, enemys, bats and custom attack hitboxes for players

added map loading and one-way collision (needs to move to tiled attribute tho)

Signed-off-by: Pascal Syma <pascal@syma.dev>
This commit is contained in:
2020-05-20 11:13:21 +02:00
parent 4a22dbe657
commit a726db1306
22 changed files with 2166 additions and 30 deletions
+42 -18
View File
@@ -3,29 +3,53 @@
* All rights reserved.
*/
import logoImg from "../assets/logo.png";
import Player from "../entities/Player";
export default class Menu extends Phaser.Scene {
constructor() {
super("Menu");
}
preload() {
this.load.image("logo", logoImg);
}
create() {
const logo = this.add.image(this.cameras.main.centerX, this.cameras.main.centerY * 1.5, "logo").setOrigin(0.5, 0.5);
this.tweens.add({
targets: logo,
y: this.cameras.main.centerY,
duration: 2000,
ease: "Power2",
yoyo: true,
loop: -1
super({
key: "Menu",
pixelArt: true,
physics: {
default: 'arcade',
arcade: {
gravity: {y: 0},
// debug: true
}
}
});
}
create() {
const w = this.cameras.main.centerX;
const h = this.cameras.main.centerY;
[{x: w / 2, y: h / 2, key: 'A'},
{x: w / 2 + w, y: h / 2, key: 'B'},
{x: w / 2, y: h / 2 + h, key: 'C'},
{x: w / 2 + w, y: h / 2 + h, key: 'D'}]
.forEach((e) => this.addOption(e));
}
addOption(options) {
this.anims.create({
key: 'idle' + options.key,
frames: this.anims.generateFrameNumbers('char' + options.key, {start: 126, end: 131}),
frameRate: 10,
repeat: -1
});
new Player(this, options, 'char' + options.key).play('idle' + options.key, true)
.setInteractive()
.on('pointerdown', () => {
this.textures.addSpriteSheet('char', this.textures.get('char' + options.key).getSourceImage(), {
frameWidth: 79,
frameHeight: 63
});
this.scene.start('Game');
})
}
}