#include <ow_cell.h>
Public Member Functions | |
ow_cell (int screenx, int screeny, int boardside, int cellx, int celly) | |
int | countseeds () |
void | emptyseeds () |
int | addseeds (int seeds) |
int | takeseeds (int seeds) |
void | setaction (int action, int timeout) |
void | setstatus (int status, int timeout) |
void | update_status_action () |
void | set_gfxdata (SDL_Surface *gfxdat) |
void | draw (SDL_Surface *surface, TTF_Font *font) |
cellXY | getcellcoordXY () |
void | setcellname (string newcellname) |
int | isOverCoordXY (int coordx, int coordy) |
~ow_cell () | |
Private Attributes | |
int | x |
int | y |
string | cellname |
SDL_Surface * | gfxdata |
SDL_Surface * | background |
int | cellstatus |
int | cellaction |
int | cellseeds |
int | statusaction_timeout |
ow_cell::ow_cell | ( | int | screenx, | |
int | screeny, | |||
int | boardside, | |||
int | cellx, | |||
int | celly | |||
) |
Creates a new 'ow_cell' object.
screenx | Xpos of the cell in the draw_gfx screen. | |
screeny | Ypos of the cell in the draw_gfx screen. | |
boardside | Side of the board (BRD_SIDE_NORTH, BRD_SIDE_SOUTH). | |
cellx | Xpos of the specified cell in the board bcells array. | |
celly | Ypos of the specified cell in the board bcells array. |
ow_cell::~ow_cell | ( | ) |
Deletes the 'ow_cell' object.
int ow_cell::countseeds | ( | ) |
Count the number of seeds in the cell.
void ow_cell::emptyseeds | ( | ) |
Remove all the seeds from the cell.
int ow_cell::addseeds | ( | int | seeds | ) |
Add seeds to the cell.
seeds | Number of seeds to add to the cell. |
int ow_cell::takeseeds | ( | int | seeds | ) |
Take/Remove seeds to the cell.
seeds | Number of seeds to remove/take from the cell. |
void ow_cell::setaction | ( | int | action, | |
int | timeout | |||
) |
Change the 'action' the cell is performing.
action | Action currently running in the cell (CELL_ACTION_CANCEL,CELL_ACTION_MOVEL,CELL_ACTION_MOVER,CELL_ACTION_SELECT,CELL_ACTION_NONE). | |
timeout | program loops the cell holds the action before returning to NONE action. -1 if lasts forever. |
void ow_cell::setstatus | ( | int | status, | |
int | timeout | |||
) |
Change the 'status' of the cell.
status | Status of the cell (CELL_STATUS_NORM,CELL_STATUS_GREEN,CELL_STATUS_RED). RED is used for negative status like 'illegal movement' or 'captured cell'. GREEN is used for positive status like 'moving'. | |
timeout | program loops the cell holds the status before returning to NORMAL status. -1 if lasts forever. |
void ow_cell::update_status_action | ( | ) |
Update the status and action of the cell Basically it is used to update cells who has a timeout defined for setstatus() and setaction().
void ow_cell::set_gfxdata | ( | SDL_Surface * | gfxdat | ) |
Sets the gfx data in SDL format for the draw_gfx method
gfxdat | SDL surface containing the graphics for the cell. |
void ow_cell::draw | ( | SDL_Surface * | surface, | |
TTF_Font * | font | |||
) |
Draw the cell in the surface provided
surface | SDL surface where to draw the cell, usually is the screen surface. | |
font | SDL_ttf font used to print out cellname. |
cellXY ow_cell::getcellcoordXY | ( | ) |
Returns a cellXY struct with the cell screen coordinates.
void ow_cell::setcellname | ( | string | newcellname | ) |
Set the cell name
cellname | The new name to be given to the cell |
int ow_cell::isOverCoordXY | ( | int | coordx, | |
int | coordy | |||
) |
Checks if (coordx,coordy) point position is inside the cell drawing area in the screen.
coordx | Xcoordinate of the point to check. | |
coordy | Ycoordinate of the point to check. |