Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

View Class Reference

Inheritance diagram for View:

Inheritance graph
[legend]
Collaboration diagram for View:

Collaboration graph
[legend]

Detailed Description

View for model.

Definition at line 15 of file View.h.

Public Member Functions

 View (const ModelList &models)
 Create new view.
virtual ~View ()
void setScreenShift (const V2 &shift)
void noteNewRound (int phases)
 Prepare new anim.
void drawModel (Cube *model)
 Draw model.
virtual void drawOn (SDL_Surface *screen)
V2 getScreenPos (const Cube *model) const
 Returns position on screen when model will be drawn.
V2 getFieldPos (const V2 &cursor) const
 Returns position of tile under cursor.
void addDecor (Decor *new_decor)
void removeDecors ()

Static Public Attributes

static const int SCALE = 15


Constructor & Destructor Documentation

View::View const ModelList models  ) 
 

Create new view.

Parameters:
models wrapper arount models

Definition at line 25 of file View.cpp.

00026      : m_models(models), m_screenShift(0, 0)
00027 {
00028     m_animShift = 0;
00029     m_shiftSize = SCALE;
00030     m_screen = NULL;
00031 }

View::~View  )  [virtual]
 

Definition at line 33 of file View.cpp.

00034 {
00035     removeDecors();
00036 }


Member Function Documentation

void View::addDecor Decor new_decor  )  [inline]
 

Definition at line 40 of file View.h.

00040 { m_decors.push_back(new_decor); }

void View::drawModel Cube model  ) 
 

Draw model.

Care about model shift during move.

Definition at line 82 of file View.cpp.

00083 {
00084     if (!model->isLost()) {
00085         V2 screenPos = getScreenPos(model);
00086 
00087         Anim::eSide side = Anim::SIDE_LEFT;
00088         if (!model->isLeft()) {
00089             side = Anim::SIDE_RIGHT;
00090         }
00091         model->anim()->drawAt(m_screen,
00092                 screenPos.getX(), screenPos.getY(), side);
00093     }
00094 }

void View::drawOn SDL_Surface *  screen  )  [virtual]
 

Implements Drawable.

Definition at line 69 of file View.cpp.

00070 {
00071     m_screen = screen;
00072     m_animShift = min(SCALE, m_animShift + m_shiftSize);
00073     m_models.drawOn(this);
00074     drawDecors();
00075 }

V2 View::getFieldPos const V2 cursor  )  const
 

Returns position of tile under cursor.

Definition at line 132 of file View.cpp.

00133 {
00134     return cursor.minus(m_screenShift).shrink(SCALE);
00135 }

V2 View::getScreenPos const Cube model  )  const
 

Returns position on screen when model will be drawn.

Definition at line 114 of file View.cpp.

00115 {
00116     V2 shift(0, 0);
00117     Dir::eDir dir = model->getLastMoveDir();
00118     if (dir != Dir::DIR_NO) {
00119         shift = Dir::dir2xy(dir);
00120         shift = shift.scale(m_animShift);
00121     }
00122     shift = shift.plus(m_screenShift);
00123 
00124     V2 anim_shift = model->const_anim()->getViewShift();
00125     return model->getLocation().plus(anim_shift).scale(SCALE).plus(shift);
00126 }

void View::noteNewRound int  phases  ) 
 

Prepare new anim.

Definition at line 62 of file View.cpp.

00063 {
00064     m_animShift = 0;
00065     computeShiftSize(phases);
00066 }

void View::removeDecors  ) 
 

Definition at line 39 of file View.cpp.

00040 {
00041     t_decors::iterator end = m_decors.end();
00042     for (t_decors::iterator i = m_decors.begin(); i != end; ++i) {
00043         delete *i;
00044     }
00045     m_decors.clear();
00046 }

void View::setScreenShift const V2 shift  )  [inline]
 

Definition at line 32 of file View.h.

00032 { m_screenShift = shift; }


Field Documentation

const int View::SCALE = 15 [static]
 

Definition at line 17 of file View.h.


The documentation for this class was generated from the following files:
Generated on Wed Jun 1 09:57:11 2005 for Fish Fillets - Next Generation by  doxygen 1.4.2