00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef TILEITEM_H
00021 #define TILEITEM_H
00022
00023 #include "graphic/surface.h"
00024
00025 const Point2i CELL_SIZE(64, 64);
00026
00027 #ifdef DEBUG
00028
00029 #endif
00030
00031 class TileItem
00032 {
00033 public:
00034 TileItem () {};
00035 virtual ~TileItem () {};
00036
00037 bool IsEmpty ();
00038 virtual unsigned char GetAlpha(const Point2i &pos) = 0;
00039 virtual void Dig(const Point2i &position, const Surface& dig) = 0;
00040 virtual void Dig(const Point2i ¢er, const uint radius) = 0;
00041 virtual void MergeSprite(const Point2i &position, Surface& spr) {};
00042 virtual Surface GetSurface() = 0;
00043 virtual void Draw(const Point2i &pos) = 0;
00044 virtual bool IsTotallyEmpty() const = 0;
00045 #ifdef DBG_TILE
00046 virtual void FillWithRGB(Uint8 r, Uint8 g, Uint8 b) {};
00047 #endif
00048 };
00049
00050 class TileItem_Empty : public TileItem
00051 {
00052 public:
00053 TileItem_Empty () {};
00054 ~TileItem_Empty () {};
00055
00056 unsigned char GetAlpha (const Point2i &pos){return 0;};
00057 void Dig(const Point2i &position, const Surface& dig){};
00058 Surface GetSurface(){return *new Surface();};
00059 void Dig(const Point2i ¢er, const uint radius) {};
00060 void Draw(const Point2i &pos);
00061 bool IsTotallyEmpty() const {return true;};
00062 };
00063
00064 class TileItem_AlphaSoftware : public TileItem
00065 {
00066 unsigned char* last_filled_pixel;
00067
00068 public:
00069 bool need_check_empty;
00070 bool need_delete;
00071
00072 TileItem_AlphaSoftware(const Point2i &size);
00073 ~TileItem_AlphaSoftware();
00074
00075 unsigned char GetAlpha(const Point2i &pos);
00076 void Dig(const Point2i &position, const Surface& dig);
00077 void Dig(const Point2i ¢er, const uint radius);
00078 void MergeSprite(const Point2i &position, Surface& spr);
00079 void Draw(const Point2i &pos);
00080
00081 bool NeedDelete() const {return need_delete; };
00082 void CheckEmpty();
00083 void ResetEmptyCheck();
00084
00085 bool IsTotallyEmpty() const {return false;};
00086
00087 private:
00088 TileItem_AlphaSoftware(const TileItem_AlphaSoftware ©);
00089 unsigned char (TileItem_AlphaSoftware::*_GetAlpha)(const Point2i &pos);
00090 unsigned char GetAlpha_Index0(const Point2i &pos);
00091 inline unsigned char GetAlpha_Index3(const Point2i &pos);
00092 inline unsigned char GetAlpha_Generic(const Point2i &pos);
00093 Surface GetSurface();
00094
00095 void Empty(const int start_x, const int end_x, unsigned char* buf, const int bpp);
00096 void Darken(const int start_x, const int end_x, unsigned char* buf, const int bpp);
00097
00098 Point2i m_size;
00099 Surface m_surface;
00100
00101 #ifdef DBG_TILE
00102 void FillWithRGB(Uint8 r, Uint8 g, Uint8 b);
00103 #endif
00104 };
00105
00106 #endif