Snake Game: Part 1 - Asset Loading
Initial setup for a Snake game, including game configuration and preloading image assets for the food and snake body.
640 × 480
class Example extends Phaser.Scene
{
preload ()
{
this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
this.load.image('food', 'assets/games/snake/food.png');
this.load.image('body', 'assets/games/snake/body.png');
}
create ()
{
}
update (time, delta)
{
}
}
const config = {
scale: { mode: Phaser.Scale.FIT },
type: Phaser.WEBGL,
width: 640,
height: 480,
backgroundColor: '#bfcc00',
parent: 'game-container',
scene: Example
};
const game = new Phaser.Game(config);