this.scene.load.spritesheet(
"https://assets.codepen.io/9367036/Char_002_Idle.png",
this.scene.load.spritesheet(
"https://assets.codepen.io/9367036/Char_002.png",
this.sprite = this.scene.add
.sprite(x, y, "char_idle")
this.scene.anims.create({
frames: this.scene.anims.generateFrameNumbers("char_idle", {
this.scene.anims.create({
frames: this.scene.anims.generateFrameNumbers("char_idle", {
if (direction === "up") {
this.sprite.play("idle_back", true);
} else if (direction === "down") {
this.sprite.play("idle_front", true);
constructor(scene, radius) {
const size = Phaser.Math.Between(radius / 2, radius * 2);
const randomColor = Phaser.Math.RND.pick(colors);
this.rond = scene.add.circle(0, 0, size, randomColor);
this.light = scene.lights
.addLight(0, 0, this.radius * 11, randomColor)
this.angleDelta = Phaser.Math.FloatBetween(-3, 3);
x + this.radius * 10 * Math.cos(this.scene.angle * this.angleDelta);
y + this.radius * 10 * Math.sin(this.scene.angle * this.angleDelta);
this.light.x = this.rond.x;
this.light.y = this.rond.y;
class Jeu extends Phaser.Scene {
this.player = new Player(this);
this.load.image("map", "https://assets.codepen.io/9367036/blue-stars.png");
this.lights.setAmbientColor(0x666666);
.tileSprite(0, config.height, 256, 256 * 2, "map")
this.player.create(config.width / 2, config.height / 2);
this.keys = this.input.keyboard.addKeys({
w: Phaser.Input.Keyboard.KeyCodes.W,
s: Phaser.Input.Keyboard.KeyCodes.S
this.sun1 = new Sun(this, 10);
this.sun2 = new Sun(this, 15);
this.sun3 = new Sun(this, 30);
this.sun4 = new Sun(this, 11);
if (this.keys.w.isDown) {
this.map.tilePositionY -= 2;
} else if (this.keys.s.isDown) {
this.map.tilePositionY += 2;
this.player.move("down");
this.sun1.animate(this.player.sprite.x, this.player.sprite.y);
this.sun2.animate(this.player.sprite.x, this.player.sprite.y);
this.sun3.animate(this.player.sprite.x, this.player.sprite.y);
this.sun4.animate(this.player.sprite.x, this.player.sprite.y);
backgroundColor: "#000808",
const game = new Phaser.Game(config);
const scaleFactor = 800 / 256;
const colors = [0xff9999, 0x99ffff, 0xffff99, 0xffffff];
activateControls(["W", "S"]);