Skip to content

Commit

Permalink
feat(*): create phaser skeleton game
Browse files Browse the repository at this point in the history
  • Loading branch information
barnabas-lesti committed Sep 30, 2024
1 parent fb5daaf commit 01046b9
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 2 deletions.
4 changes: 3 additions & 1 deletion games/phaser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"lint": "prettier . --check && eslint .",
"lint:fix": "prettier . --write && eslint . --fix"
},
"dependencies": {},
"dependencies": {
"phaser": "^3.85.2"
},
"devDependencies": {
"@wds/tools.prettier": "*",
"@wds/tools.eslint": "*",
Expand Down
5 changes: 5 additions & 0 deletions games/phaser/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ body {
margin: 0;
padding: 0;
}

canvas {
width: 100%;
height: 100%;
}
43 changes: 42 additions & 1 deletion games/phaser/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,44 @@
import { AUTO, Game, Scene } from "phaser";

import "./index.css";

console.debug("working");
class ExampleScene extends Scene {
preload() {
this.load.setBaseURL("/assets");

this.load.image("sky", "skies/space3.png");
this.load.image("logo", "sprites/phaser3-logo.png");
this.load.image("red", "particles/red.png");
}

create() {
this.add.image(400, 300, "sky");

const particles = this.add.particles(0, 0, "red", {
speed: 100,
scale: { start: 1, end: 0 },
blendMode: "ADD",
});

const logo = this.physics.add.image(400, 100, "logo");

logo.setVelocity(100, 200);
logo.setBounce(1, 1);
logo.setCollideWorldBounds(true);

particles.startFollow(logo);
}
}

new Game({
type: AUTO,
scene: ExampleScene,
width: 800,
height: 600,
physics: {
default: "arcade",
arcade: {
gravity: { y: 200, x: 0 },
},
},
});
Binary file added games/phaser/src/public/assets/particles/red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added games/phaser/src/public/assets/skies/space3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 01046b9

Please sign in to comment.