Game map (on the left).It includes field and dugout. More...
#include <Map.hh>

Classes | |
| class | DugoutsCallback |
Public Member Functions | |
| Map (Game &g) | |
| bool | mouseInsideMap () const |
| Check if the mouse is inside the visible game stadium. | |
| bool | mouseInsideField () const |
| Check if the mouse is inside the visible game field. | |
| Coordinates | mouseToSquare () const |
| Convert mouse position to square coordinates. | |
| Point | squareToMap (const Coordinates &coord, const Point &adjust=Point(0, 0)) const |
| Convert a field position to a map position, where to place Surface. | |
| void | setMarker (const Point &square, int type) |
| void | removeMarker () |
| void | setBallCoord (const Coordinates &coord) |
| void | removeBall () |
| void | addPlayer (VisuPlayer *vp) |
| Add a VisuPlayer to the map. | |
| void | movePlayer (enum eStatus old_status, enum eStatus new_status, int team_id, int player_id) |
| Move a VisuPlayer from a zone to another, if needed. | |
| const VisuPlayer * | getSelectedPlayer () const |
| Get selected player. | |
| void | setSelectedPlayer (VisuPlayer *vp) |
| Set selected player. Unselect previously selected player, if any. | |
| void | unselectPlayer () |
| Unselect selected player, if any. | |
| void | drawPath () |
| Draw path to mouse pointer for selected player. | |
| void | clearPath (unsigned int from_step=0) |
| Clear currently drawn path. | |
| void | drawBlock () |
| Draw block dices number for selected player against pointed player. | |
| void | clearBlock () |
| Clear currently drawn block dices number. | |
| void | drawThrow () |
| Draw difficulty of a throw to pointed square for selected player. | |
| void | clearThrow () |
| Clear currently drawn throw difficulty. | |
| void | centerViewTo (const Point &pos) |
| Move view until it gets centered on specified position. | |
| bool | getDrawTicks () const |
| void | setDrawTicks (bool enable) |
| virtual void | update () |
| Method called each frame, to perfom user custom code. | |
Game map (on the left).
It includes field and dugout.
| void sdlvisu::Map::addPlayer | ( | VisuPlayer * | vp | ) |
Add a VisuPlayer to the map.
VisuPlayer will be added to the map and placed in the reserve. Use this instead of addChild, because map handles player position in dugouts.
| vp | VisuPlayer to add to the map. |
References VirtualSurface::addChild(), and sdlvisu::VisuPlayer::getPlayer().
| bool sdlvisu::Map::mouseInsideField | ( | ) | const |
Check if the mouse is inside the visible game field.
true if the mouse is inside one game square. References Coordinates::col, COLS, mouseInsideMap(), mouseToSquare(), Coordinates::row, and ROWS.
Referenced by sdlvisu::VisuPlayer::update(), and update().
| bool sdlvisu::Map::mouseInsideMap | ( | ) | const |
Check if the mouse is inside the visible game stadium.
true if the mouse is inside game stadium. References VirtualScrollableSurface::getRenderRect(), and Input::mouse_.
Referenced by mouseInsideField().
| Coordinates sdlvisu::Map::mouseToSquare | ( | ) | const |
Convert mouse position to square coordinates.
References VirtualScrollableSurface::getScreenRect(), and Input::mouse_.
Referenced by drawBlock(), drawPath(), drawThrow(), mouseInsideField(), sdlvisu::VisuPlayer::update(), and update().
| void sdlvisu::Map::movePlayer | ( | enum eStatus | old_status, | |
| enum eStatus | new_status, | |||
| int | team_id, | |||
| int | player_id | |||
| ) |
Move a VisuPlayer from a zone to another, if needed.
| Point sdlvisu::Map::squareToMap | ( | const Coordinates & | coord, | |
| const Point & | adjust = Point(0, 0) | |||
| ) | const |
Convert a field position to a map position, where to place Surface.
| coord | A square coordinates on the field (between 0 and ROWS/COLS). | |
| adjust | Map position adjustement, when you want to center object on a square. |
Referenced by drawBlock(), drawPath(), drawThrow(), and update().
| void sdlvisu::Map::update | ( | ) | [virtual] |
Method called each frame, to perfom user custom code.
You should override it.
Since a parent is assigned to the surface (and this parent is itself attached by other means to the root screen), this method is called at each frame. It is not called if this surface or one of its parent is disabled. In this method you can do what you want with your object, like processing input, updating other programs attributes, changing surface property, ...
Reimplemented from VirtualScrollableSurface.
References Input::button_pressed_, Api::doGiveBall(), Api::doPlaceBall(), Api::getPlayer(), VirtualScrollableSurface::getScreenRect(), BaseApi< T >::getState(), GS_KICKOFF, GS_TOUCHBACK, sdlvisu::Game::isStateSet(), Input::mouse_, mouseInsideField(), mouseToSquare(), Api::mustMakeChoice(), Api::myTeamId(), ROWS, Surface::show(), squareToMap(), Sprite::stopMove(), sdlvisu::VGS_SHOWDLGBOX, and TPoint< T >::y.
1.6.3