sdlvisu::Map Class Reference
[2D Graphical User Inteface]

Game map (on the left).It includes field and dugout. More...

#include <Map.hh>

Inheritance diagram for sdlvisu::Map:
Inheritance graph
[legend]

List of all members.

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 VisuPlayergetSelectedPlayer () 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.

Detailed Description

Game map (on the left).

It includes field and dugout.


Member Function Documentation

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.

Parameters:
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.

Returns:
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.

Returns:
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.

Returns:
Square coordinates (between 0 and ROWS/COLS).

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.

Parameters:
old_status Old player status. It determines the zone he comes from.
new_status New player status. It determines the zone he goes to.
team_id Team id of the player.
player_id Player id.
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.

Parameters:
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, ...

Note:
Don't forget to call update for the base class at the end of your function , otherwise strange things will happen.

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.


The documentation for this class was generated from the following files:
Generated on Mon Apr 5 21:18:06 2010 for Stechec/TBT by  doxygen 1.6.3