#include <logicgate.h>
Inherits LogicComponent.

Public Member Functions | |
| LogicGate () | |
| LogicGate (LogicMinigame *game, int type) | |
| LogicGate (LogicMinigame *game, int type, Point p) | |
| LogicGate (LogicMinigame *game, int type, int x, int y) | |
| int | nextSlot () |
| Returns the next open slot. | |
| void | addConnector (LogicConnector *connector) |
| Adds a new incoming connection. | |
| void | removeConnector (int slot) |
| Removes the connection from the given slot. | |
| Point | inpoint (int slot) |
| Returns the point matching the given slot. | |
| LogicConnector * | getConnector () |
| Returns the output connector for this gate. | |
| void | acceptRobot (bool value, int slot) |
| Accept a robot of the given truth value to the given slot. | |
| void | moved () |
| Call the repath methods of all the connections linked to this gate. | |
| void | disconnect () |
| Remove all incoming and outgoing connections. | |
| bool | containsPoint (Point p) |
| ~LogicGate () | |
| void | draw (BITMAP *canvas, Point offset) |
| This is the main reason for this class. | |
Protected Member Functions | |
| void | init () |
| Initializes the data structures. | |
Protected Attributes | |
| std::vector< LogicConnector * > | connectors |
| The connectors leading to and from this object. | |
| Point * | connectionPoints |
| The locations of the various connections. | |
| int | numConnections |
| How many connections this object can have. | |
| int | type |
| The type of gate or non-gate. | |
| BITMAP * | sprite |
| WaveSound * | sound |
| std::list< bool > | inputs |
| What truth values this gate has so far. | |
| int | inputPosition |
Static Protected Attributes | |
| static const int | NotVerticalOffset = 10 |
The LogicGate class is used to represent all of the different kinds of objects that are in the area of play during the logic game. This includes both the real logic gates, and the input and output locations.
| LogicGate::LogicGate | ( | ) |
| LogicGate::LogicGate | ( | LogicMinigame * | game, | |
| int | type | |||
| ) |
| LogicGate::LogicGate | ( | LogicMinigame * | game, | |
| int | type, | |||
| Point | p | |||
| ) |
| LogicGate::LogicGate | ( | LogicMinigame * | game, | |
| int | type, | |||
| int | x, | |||
| int | y | |||
| ) |
| LogicGate::~LogicGate | ( | ) |
| void LogicGate::acceptRobot | ( | bool | value, | |
| int | slot | |||
| ) | [virtual] |
Accept a robot of the given truth value to the given slot.
If slot is invalid, does nothing. If there is already a truth value for the slot, the new value overwrites it.
Takes a robot as input and either produces the appropriate type of robot or, if this is a gate that combines input, adds the robot to the queue of robots waiting to be matched
Reimplemented from LogicComponent.
| void LogicGate::addConnector | ( | LogicConnector * | connector | ) | [virtual] |
Adds a new incoming connection.
The new connection is placed in the slot returned by nextSlot(). If there are no open slots, this function does nothing.
Implements LogicComponent.
| bool LogicGate::containsPoint | ( | Point | p | ) | [virtual] |
Reimplemented from LogicComponent.
| void LogicGate::disconnect | ( | ) | [virtual] |
| void LogicGate::draw | ( | BITMAP * | canvas, | |
| Point | offset | |||
| ) | [virtual] |
| LogicConnector * LogicGate::getConnector | ( | ) | [virtual] |
| void LogicGate::init | ( | ) | [protected] |
Initializes the data structures.
| Point LogicGate::inpoint | ( | int | slot | ) | [virtual] |
Returns the point matching the given slot.
If the slot number is invalid, returns OFFSCREEN. Here, 0 is a valid slot number.
Implements LogicComponent.
| void LogicGate::moved | ( | ) | [virtual] |
Call the repath methods of all the connections linked to this gate.
Reimplemented from LogicComponent.
| int LogicGate::nextSlot | ( | ) | [virtual] |
Returns the next open slot.
If there are no open slots, returns 0. Note that slot 0 is reserved for the gate's output connection, so this is okay.
Implements LogicComponent.
| void LogicGate::removeConnector | ( | int | slot | ) | [virtual] |
Removes the connection from the given slot.
If there is no connection, or the slot number is invalid, this does nothing. Note that 0 is always invalid, because you can't remove the output.
Implements LogicComponent.
Point* LogicGate::connectionPoints [protected] |
The locations of the various connections.
std::vector<LogicConnector*> LogicGate::connectors [protected] |
The connectors leading to and from this object.
Connection 0 is reserved for the connection leading out. Note that the length of this array changes depending on what kind of gate this is.
int LogicGate::inputPosition [protected] |
std::list<bool> LogicGate::inputs [protected] |
What truth values this gate has so far.
const int LogicGate::NotVerticalOffset = 10 [static, protected] |
int LogicGate::numConnections [protected] |
How many connections this object can have.
WaveSound* LogicGate::sound [protected] |
BITMAP* LogicGate::sprite [protected] |
int LogicGate::type [protected] |
The type of gate or non-gate.
1.5.7.1