// New Code
const VIEWPORT_HEIGHT = 400;
const VIEWPORT_WIDTH = 400;
const MAX_BALLS_PER_GROUP = 5;
const PLAYER_SPEED = 5;
const PLAYER_RADIUS = 15;
const BALL_RADIUS = 10;
const BALL_COLOR_ID = ['red', 'blue', 'yellow'];
const MIN_VELOCITY = 15;
const MAX_VELOCITY = 200;
const GAME = new Phaser.Game({
    backgroundColor: '#efefef',
    height: VIEWPORT_HEIGHT,
    parent: 'game',
    state: {
        preload: preload,
        create: create,
        update: update,
    },
    type: Phaser.AUTO,
    width: VIEWPORT_WIDTH,
});
// New Code
let player;
let balls;
let groups = {};
let counter = 0;

function preload() {}

function create() {}

function update() {}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/phaser-ce/2.11.1/phaser.min.js