Making the player character

Finally, we will create our player character and the namesake of our game, the Star Walrus! This walrus will also have a two-frame animation loop like the enemies.

Since this is a game that will be playable on both desktop and touch-based platforms, we'll be keeping the walrus controls nice and simple. The walrus will automatically shoot while the player moves it around the screen using the keyboard, mouse, or touch input.

Creating the class

First, let's create the class. In the source folder, make a new class named Player that extends FlxGroup:

package;

import flixel.group.FlxGroup;

class Player extends FlxGroup
{
  public function new() 
  {
    super();
  }
}

Adding imports

Next, let's add the imports:

import flixel.FlxSprite; import ...

Get Haxe Game Development Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.