The Arena class creates four walls that are immovable at a specified distance from the center position. More...
#include <arena.h>
Public Member Functions | |
Arena (b2World *world, QPointF position=QPointF(0, 0), float halfWidth=200, float halfHeight=200) | |
Constructor creating an Arena object based on a number of parameters. More... | |
~Arena () | |
QRectF | boundingRect () const |
boundingRect returns the computed bounding rectangle used for drawing and redrawing the object. From the QGraphicsItem abstract base class. More... | |
void | paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
paint Draws the walls for display. From the QGraphicsItem abstract base class. More... | |
b2Body * | body () const |
Simple getter for _body field. From the PhysicalObject interface class. More... | |
QGraphicsItem * | item () const |
Simple getter for returning QGraphicsItem connected to this object. From the PhysicalObject interface class. More... | |
![]() | |
PhysicalObject () | |
virtual | ~PhysicalObject () |
virtual void | step (float dt) |
Called by World on all PhysicalObjects in the simulation so they can implement any custom physics. More... | |
virtual void | stepGraphics () |
stepGraphics More... | |
Private Member Functions | |
void | CreatePhysicalBody (QPointF position, float width, float height, b2World *world) |
Private Attributes | |
QRectF | _boundingRect |
b2Body * | _body |
Static Private Attributes | |
static const QString | Name = QString("Arena") |
Friends | |
PhysicalObject * | arenaFactory (World *world, const QJsonObject &obj) |
chirpFactory follows the PhysicalObject FactoryFunction, creating the Arena object from a QJsonObject. More... | |
The Arena class creates four walls that are immovable at a specified distance from the center position.
The Arena class creates four walls that are immovable at a specified distance from the center position. It handles creation of all four walls in the Box2D world, along with drawing them in the simulator. It's a handy class for restricting movement in the world.
|
explicit |
Constructor creating an Arena object based on a number of parameters.
world | World for the arena to be created in. |
position | Center position of the arena. |
halfWidth | Distance from center position to both walls on the x-axis. |
halfHeight | Distance from the center position to both walls on the y-axis. |
Creates a physical model of the arena with Box2D and sets up the drawing of the walls.
References CreatePhysicalBody().
Arena::~Arena | ( | ) |
|
inlinevirtual |
Simple getter for _body field. From the PhysicalObject interface class.
Implements PhysicalObject.
References _body.
QRectF Arena::boundingRect | ( | ) | const |
boundingRect returns the computed bounding rectangle used for drawing and redrawing the object. From the QGraphicsItem abstract base class.
References _boundingRect.
|
private |
|
inlinevirtual |
Simple getter for returning QGraphicsItem connected to this object. From the PhysicalObject interface class.
Implements PhysicalObject.
void Arena::paint | ( | QPainter * | painter, |
const QStyleOptionGraphicsItem * | option, | ||
QWidget * | widget | ||
) |
paint Draws the walls for display. From the QGraphicsItem abstract base class.
References _body, _boundingRect, and genericPaint().
|
friend |
chirpFactory follows the PhysicalObject FactoryFunction, creating the Arena object from a QJsonObject.
world | World to put the physical object model in. |
obj | JsonObject containing the parameters for the object. |
|
private |
Referenced by body(), CreatePhysicalBody(), and paint().
|
private |
Referenced by boundingRect(), and paint().
|
staticprivate |