Debian Codegraph @

TetrisAttack/src/CFieldSprite.h

raw
1 #ifndef _CFIELDSPRITE_
2 #define _CFIELDSPRITE_
3
4 #include "oodle.h"
5
6 //! Abstact class that defines some methods used for any sprite placed on a CPlayingField
7 class CFieldSprite : public CSprite
8 {
9 public:
10 void setOffset(CVector offset) { CFieldSprite::offset = offset; }
11 void moveBoardCords(int x, int y);
12 void moveRelBoardCords(int dX, int dY) { setPos( screenCords( boardX + dX, boardY + dY ) ); boardX += dX; boardY += dY; }
13 //void moveRelBoardCords(int dX, int dY, double vel); //! Set destination block to dX, dY in board cords with velocity of vel
14 CGotoEvent* moveRelBoardCords(int dX, int dY, double speed);
15
16 virtual void update(); //! Move sprite until it reaches dest
17
18 CFieldSprite* getClone(int x, int y);
19 int getBoardX() { return boardX; }
20 int getBoardY() { return boardY; }
21 int getBoardWidth() { return widthBoard; }
22 int getBoardHeight() { return heightBoard; }
23 int getDestType() { return dtype; }
24
25 protected:
26 CFieldSprite(const string& fileName, int x, int y, int width, int height, int fieldWidth, int fieldHeight, CVector offset, bool alpha = false);
27 CFieldSprite(CSurface *s, int x, int y, int width, int height, int fieldWidth, int fieldHeight, CVector offset);
28
29 CFieldSprite(const CFieldSprite& b, int x, int y); //! Clone constructor
30 CFieldSprite(const CFieldSprite& b, int x, int y, CVector offset); //! Clone constructor
31 CFieldSprite(const CFieldSprite& b, int x, int y, int fieldWidth, int fieldHeight, CVector offset); //! Clone constructor
32 CVector screenCords(int x, int y); //! Convert from board coordinates to screen coordiantes using the offset
33 void setDest(CVector d);
34 bool atDest(); //! Tells if the sprite is at dest (returns false if dest == ZERO_VECTOR)
35 bool isMoving() { return ( velocity != ZERO_VECTOR ); }
36 private:
37 int boardX, boardY; //! Location of object in board cords
38 int widthBoard, heightBoard; //! Width and height of object in board cords
39 int fieldHeight, fieldWidth; //! Width and height of field in number of objects
40 CVector offset; //! Vector to upper-lefthand corner of CPlayingField from (0,0) in screen cords
41 CVector dest; //! Vector to destination in *board coordinates*
42 int dtype; //!
43 };
44
45 #endif