Wizard Fu's Cocos2dx Platformer Game Engine v1.0.1

nat@wizardfu.com

See the file LICENSE for the license governing this code.

LevelObject > Character > AI > Enemy > Enemies

#pragma once
#include "Headers.h"

There are two ways of changing the general attributes of enemies:

  1. Edit the attributes in the enemy’s profile property list. Example: Assets/Profiles/Blob.plist > attributes > hp = 5.
  2. Add a tmx object property. Example: set hp property to 5 in the tmx file.

Blob

Hops around randomly, clinging to walls and ceilings. Deals light damage and has low health.

class Blob : public Enemy
{
	public:
		virtual const char* const profileName() {return "Blob";}
		Blob();
		virtual ~Blob();
		virtual void setProperties(Level& level, ValueMap& dict);
		virtual void createFixtures();
		virtual void attackedBy(LevelObject* o);
		virtual void moodSeek(float delta);
		virtual void die();

	private:
		typedef Enemy super;
		typedef Blob self;
		
		bool sticky;
		bool clockwise;
		Vec2 vec;
		float speed;
		int direction;
		double jumpTime;
};

Skeleton

Jukes back and forth, every once in awhile firing a Bone projectile in an arc toward the player. Low hitpoints, medium damage.

class Skeleton : public Enemy
{
	public:
		virtual const char* const profileName() {return "Skeleton";}
		Skeleton();
		virtual ~Skeleton();
		virtual void setProperties(Level& level, ValueMap& dict);
		virtual void createFixtures();
		virtual void moodSleep(float delta);
		virtual void moodSeek(float delta);
		virtual void moodAttack(float delta);
		virtual void die();

	private:
		typedef Enemy super;
		typedef Skeleton self;
		
		bool retreat;
};

Knight

A miniboss. A statue that comes to life and jumps towards the player, shaking the screen. High hit points, high damage.

class Knight : public Enemy
{
	public:
		virtual const char* const profileName() {return "Knight";}
		Knight();
		virtual ~Knight();
		virtual void setProperties(Level& level, ValueMap& dict);
		virtual void createFixtures();
		virtual void moodSleep(float delta);
		virtual void moodSeek(float delta);
		virtual void moodAttack(float delta);
		virtual void die();

	private:
		typedef Enemy super;
		typedef Knight self;
};

BotPlayer

An AI-controlled player. Used in networked multiplayer when a human player cannot be found. Has the same abilities and attributes as a default player.

class BotPlayer : public Enemy
{
	public:
		virtual const char* const profileName() {return "BotPlayer";}
		BotPlayer();
		virtual ~BotPlayer();
		virtual void setProperties(Level& level, ValueMap& dict);
		virtual void createFixtures();
		virtual void moodSleep(float delta);
		virtual void moodSeek(float delta);
		virtual void moodAttack(float delta);
		virtual void die();

	private:
		typedef Enemy super;
		typedef BotPlayer self;
};

Bat

Hangs on the ceiling and swoops down at the player. Low health, low damage.

class Bat : public Enemy
{
	public:
		virtual const char* const profileName() {return "Bat";}
		Bat();
		virtual ~Bat();
		virtual void setProperties(Level& level, ValueMap& dict);
		virtual void createFixtures();
		virtual void moodSleep(float delta);
		virtual void moodSeek(float delta);
		virtual void moodAttack(float delta);
		virtual void die();

	private:
		typedef Enemy super;
		typedef Bat self;
		
		float swoopX;
		bool swoopUp;
};

Mage

Teleports around the level, firing MagicBall projectiles at the player. Medium health, medium damage.

class Mage : public Enemy
{
	public:
		virtual const char* const profileName() {return "Mage";}
		Mage();
		virtual ~Mage();
		virtual void setProperties(Level& level, ValueMap& dict);
		virtual void createFixtures();
		virtual void moodSleep(float delta);
		virtual void moodSeek(float delta);
		virtual void moodAttack(float delta);
		virtual void die();
		virtual void isNowSolid();

	private:
		typedef Enemy super;
		typedef Mage self;
};

Sasquatch

A boss. Jumps and slams the ground, dealing a shockwave of explosions. Roars, beats chest, shakes the screen. High health, high damage.

Note: Sasquatch is not finished yet. Coming in the next release.

class Sasquatch : public Enemy
{
	public:
		virtual const char* const profileName() {return "Sasquatch";}
		Sasquatch();
		virtual ~Sasquatch();
		virtual void setProperties(Level& level, ValueMap& dict);
		virtual void createFixtures();
		virtual void moodSleep(float delta);
		virtual void moodSeek(float delta);
		virtual void moodAttack(float delta);
		virtual void die();

	private:
		typedef Enemy super;
		typedef Sasquatch self;
};

Class hierarchy

 
h