Skip to content

Instantly share code, notes, and snippets.

@jamesmurdza
Created March 22, 2024 19:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesmurdza/a393c11761c9183cb8bdfc1c0622a509 to your computer and use it in GitHub Desktop.
Save jamesmurdza/a393c11761c9183cb8bdfc1c0622a509 to your computer and use it in GitHub Desktop.
Game
import Phaser from "phaser";
function preload() {
this.load.image("sky", "Assets/sky.png");
this.load.image("ground", "Assets/platform.png");
this.load.image("star", "Assets/star.png");
this.load.image("bomb", "Assets/bomb.png");
this.load.spritesheet("dude", "Assets/dude.png", {
frameWidth: 32,
frameHeight: 48,
});
}
function create() {
// Add the player to the game at the middle of the screen without gravity
this.player = this.physics.add.sprite(400, 300, "dude");
// Disable gravity for the player
this.player.body.setGravity(0, 0);
// Set the physics properties of the player
this.player.setBounce(0.2);
this.player.setCollideWorldBounds(true);
}
function update() {}
let config = {
type: Phaser.AUTO,
width: 800,
height: 600,
physics: {
default: "arcade",
arcade: {
gravity: { y: 0 },
debug: false,
},
},
scene: {
preload: preload,
create: create,
update: update,
},
};
let game = new Phaser.Game(config);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment