Loading Topvon AI...

Making Phaser 3 games with AI

Phaser 3 is the most popular JavaScript framework for 2D browser games. It gives you scenes, arcade physics, input and audio out of the box, which makes it a great target for AI: less code to write, fewer things to break.

Scenes are the structure

A Phaser game is a set of scenes: Boot, Menu, Play, GameOver. Each scene has preload, create and update. Asking the AI for this structure up front keeps the game easy to extend, and makes restarts clean because a scene can simply be restarted.

Arcade physics and feel

Arcade physics is fast and perfect for platformers and shooters. The feel comes from numbers: gravity, jump velocity, acceleration and drag. Ask for coyote time and jump buffering in platformers, and for camera follow with a small lerp, and the game instantly feels better.

// A minimal Phaser 3 scene with arcade physics and a player
class Play extends Phaser.Scene {
  create() {
    this.player = this.add.rectangle(100, 300, 32, 32, 0x3b82f6);
    this.physics.add.existing(this.player);
    this.player.body.setCollideWorldBounds(true);
    this.cursors = this.input.keyboard.createCursorKeys();
  }
  update() {
    const body = this.player.body;
    body.setVelocityX(0);
    if (this.cursors.left.isDown) body.setVelocityX(-240);
    if (this.cursors.right.isDown) body.setVelocityX(240);
    if (this.cursors.up.isDown && body.blocked.down) body.setVelocityY(-460);
  }
}

new Phaser.Game({
  type: Phaser.AUTO, width: 800, height: 450, backgroundColor: '#0b1020',
  physics: { default: 'arcade', arcade: { gravity: { y: 900 } } },
  scale: { mode: Phaser.Scale.FIT, autoCenter: Phaser.Scale.CENTER_BOTH },
  scene: Play,
});

Art without asset files

You can make good-looking Phaser games with no images at all: generate textures with Graphics, use particles for juice, and tween UI elements. Topvon builds games like this by default so they load instantly and never break because of a missing file.

Mobile and publishing

Use Phaser.Scale.FIT with autoCenter so the game fits every screen, and add touch buttons for phones. Build it in the Topvon Super Computer and publish it to the Arcade with one link.

Questions people ask

Is Phaser good for beginners?

Yes. Phaser hides the hard parts of browser games, and with AI you can start from a working game and change it in plain words.

Can AI use my own sprites in Phaser?

Yes. Mention your sprite sheet sizes and animation frames and the code loads and animates them.

Phaser or plain Canvas?

Phaser for platformers, shooters and tile-based games; plain Canvas for very small games where you want zero dependencies.

Does it work on phones?

Yes, with the Scale Manager and touch controls.

More guides

العربية