Created
March 22, 2024 19:13
-
-
Save jamesmurdza/a393c11761c9183cb8bdfc1c0622a509 to your computer and use it in GitHub Desktop.
Game
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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