See the file LICENSE for the license governing this code.
LevelObject > Solid > Solids
#pragma once
#include "Headers.h"A Chest is a essentially an Item (see NonSolids) which has hitpoints, must be opened via attacking it and plays a neat animation when the item is finally obtained.
item (string) to specify the kind of item the chest contains. Currently maxhealth, ability0, ability1, ability2 etc. are meant to be used by the chest.small (boolean 1 or true) to make the chest small and enable it to be opened by jumping on it.hp (integer) to specify how many hitpoints the chest has.id (string) to specify a globally unique id for this chest if you do not want the player to acquire it’s contents twice.class Chest : public Solid
{
public:
GETTER(string, item, Item);
virtual const char* const profileName() {return "Chest";}
Chest();
virtual ~Chest();
virtual void setProperties(Level& level, ValueMap& dict);
virtual void createFixtures();
virtual void attackedBy(LevelObject* o);
virtual void tick(float delta);
virtual void animate(float delta);
virtual void open();
virtual void take();
virtual void disable();
private:
typedef Solid super;
typedef Chest self;
int hp, maxHP;
bool isSmall, isOpen;
SpriteMirrored* triangle, *grad;
double lastAmbienceTime;
double lastHitTime;
void setOpenState();
};Launches the player into the air when the player comes in contact.
strength (floating point) to specify how much to launch the player. Around 50 is a reasonable starting value.vector (two floating points separated by a comma) to specify the vector along which to launch the player.class JumpPad : public Solid
{
private:
typedef Solid super;
typedef JumpPad self;
bool open;
float strength;
Vec2 vec;
public:
virtual const char* const profileName() {return "JumpPad";}
JumpPad();
virtual ~JumpPad();
virtual void setProperties(Level& level, ValueMap& dict);
virtual void createFixtures();
virtual void attackedBy(LevelObject* o);
virtual void setFirstFrame();
};A Platform is a solid rectangular object that can move along a path and which the player can land on.
movement (vector of two floating points separated by a comma, measured in tiles) to specify the one-way movement that the platform will take.repeat (boolean 1 or true) to make the platform perform a round-trip journey and repeat indefinitely.class Platform : public Solid
{
public:
virtual const char* const profileName() {return "Platform";}
Platform();
virtual ~Platform();
virtual void setProperties(Level& level, ValueMap& dict);
virtual void createFixtures();
virtual void tick(float delta);
private:
typedef Solid super;
typedef Platform self;
Vec2 startPosition;
Vec2 movement;
float speed;
bool repeat, reversed, stopped;
double reverseTime;
};A protocol for door-like objects. Inheriting from this protocol means an object can be opened with a trigger, like on an enemy’s death.
class DoorProtocol
{
public:
virtual void open(LevelObject* opener) = 0;
};A Door is a solid rectangular object taking it’s x, y, width and height from the tmx object.
It can be opened using a trigger or by its hitpoints reaching zero.
Upon opening, it immediately becomes a non-solid object.
Then it either slides open in a given direction or explodes into many Debris objects.
color (0-255, 0-255, 0-255) to specify the RGB color of the door. Defaults to the color of the current Level.sprite (string) to specfiy the filename of a sprite (or spriteframe) to use like a decal. If not specified, the Door is a colored rectangle.hp (integer) to specify how many hitpoints the Door has (used with activate). Default: 1.activate (string) to specify a class which causes the Door to lose hitpoints. Only the class missile is currently implemented, which causes the Door to lose hp when hit by the player’s projectiles.explode (boolean 1 or true) to explode into Debris objects when triggered to open.sound-open (string) to specify the filename of a sound to play when triggered to open.duration (floating point) to specify the duration in seconds for the open animation.shake (boolean 1 or true) to shake the screen after the Door has been triggered open and the duration has passed.Trigger example:
Door0onDeath with value open Door0class Door : public Solid, public DoorProtocol
{
public:
virtual const char* const profileName() {return "Door";}
Door();
virtual ~Door();
virtual void setProperties(Level& level, ValueMap& dict);
virtual void createFixtures();
virtual void open(LevelObject* opener);
virtual void attackedBy(LevelObject* obj);
private:
typedef Solid super;
typedef Door self;
int openDirection;
string openSound;
float openDuration;
float shakeDuration;
bool explode, activateViaMissile;
int hp;
};A piece of Debris is a solid object which collides with other Debris objects and solid fixtures, but not the Player or any other level objects.
The Door class can be set to create a lot of these and sends them flying in the air when a opening.
This creates an explosion effect, the Debris objects bouncing off each other and the Level.
hue (integer 0-359) to specify the hue.direction (string left, right, up or down) to specify a direction for initial velocity. A degree of randomness will be added to the direction.x, y, width and height to specify the Debris object’s shape and position.class Debris : public Solid
{
public:
virtual const char* const profileName() {return "Debris";}
Debris();
virtual ~Debris();
virtual void setProperties(Level& level, ValueMap& dict);
virtual void createFixtures();
virtual void tick(float);
private:
typedef Solid super;
typedef Debris self;
int direction;
};A Box can be moved around, used to jump from and blocks projectiles.
x, y, width and height to specify the object’s shape and position.sprite (string) to specify the filename of a sprite (or spriteframe) to load. The Box will use the sprite’s width and height. If no sprite is specified, the box will be a solid rectangle.color (0-255, 0-255, 0-255) to specify the RGB color of the box.class Box : public Solid
{
public:
virtual const char* const profileName() {return "Box";}
Box();
virtual ~Box();
virtual void setProperties(Level& level, ValueMap& dict);
virtual void createFixtures();
private:
typedef Solid super;
typedef Box self;
};A solid object animated with Flicker and particles to resemble fire that damages Characters who come in contact with it.
Default damage 1.
x, y, width and height to specify the object’s shape and position. Currently Fire is a square, so it uses width also as a height.damage (integer) to set the damage dealt.color-max (0-255, 0-255, 0-255) to specify the maximum RGB color of the flicker.color-min (0-255, 0-255, 0-255) to specify the minimum RGB color of the flicker.class Fire : public Solid
{
public:
virtual const char* const profileName() {return "Fire";}
Fire();
virtual ~Fire();
virtual void setProperties(Level& level, ValueMap& dict);
virtual void createFixtures();
virtual void tick(float delta);
virtual void attackedBy(LevelObject* o);
private:
typedef Solid super;
typedef Fire self;
double wavelength;
};
Core
Object types