}\r
}\r
\r
+ CMMPointer<Sprite> tile_sprite = this->getKernel()->getSpriteManager()->getSprite(SPR_TILE);\r
// put in non-destructible blocks\r
for (int i=0; i<PLAYGROUND_COLS; i++) \r
+ {\r
for (int j=0; j<PLAYGROUND_ROWS; j++)\r
+ {\r
+ int subsprite = -1;\r
switch(scheme->PlayField[j*PLAYGROUND_NUMFIELD_X+i]) {\r
case BRICK:\r
- //field[i][j] = new Item(foreground, 0, FIELD_UNIT_WIDTH, FIELD_UNIT_HEIGHT, i, j);\r
+ subsprite = SPR_SUB_BRICK;\r
break;\r
case SOLID:\r
- #ifdef WIN32\r
- field[i][j] = new Item(foreground, 1, FIELD_UNIT_WIDTH, FIELD_UNIT_HEIGHT, i, j);\r
- #endif // WIN32\r
+ subsprite = SPR_SUB_SOLID;\r
break;\r
}\r
+ if (subsprite != -1)\r
+ field[i][j] = new Tile(tile_sprite, subsprite, i, j);\r
+ }\r
+ }\r
/*\r
// put in desctructible blocks with chance 90%\r
for (int i=0; i<PLAYGROUND_COLS; i+=2) \r
for (int j=0; j<PLAYGROUND_ROWS; ++j)\r
- if ((double)rand()/RAND_MAX <= 0.9) field[i][j] = new Item(foreground, 0, i, j);\r
+ if ((double)rand()/RAND_MAX <= 0.9) field[i][j] = new Tile(foreground, 0, i, j);\r
for (int i=1; i<PLAYGROUND_COLS; i+=2) \r
for (int j=0; j<PLAYGROUND_ROWS; j+=2)\r
- if ((double)rand()/RAND_MAX <= 0.9) field[i][j] = new Item(foreground, 0, i, j);\r
+ if ((double)rand()/RAND_MAX <= 0.9) field[i][j] = new Tile(foreground, 0, i, j);\r
*/ \r
// put in a player\r
bomberman = new Bomberman(20, 66);\r
CMMPointer<Sprite> s = this->getKernel()->getSpriteManager()->getSprite(SPR_FIELD);\r
\r
s->blit(0, 0, 1.0, 1.0, 0, 0, COLOUR_RGBA(0, 0, 255, 255));\r
- #ifdef WIN32\r
- if(CInputTask::keyDown(DIK_ESCAPE))CKernel::GetSingleton().KillAllTasks();\r
-\r
- d3dspt->Begin(NULL); // begin sprite drawing\r
-\r
- // draw the sprite\r
- D3DXVECTOR3 center(0.0f, 0.0f, 0.0f); // center at the upper-left corner\r
- D3DXVECTOR3 position(0.0f, 0.0f, 0.0f); // position at 50, 50 with no depth\r
- d3dspt->Draw(background, NULL, NULL, NULL, D3DCOLOR_XRGB(255, 255, 255));\r
-\r
for (int i=0; i<PLAYGROUND_COLS; ++i) \r
{\r
for (int j=0; j<PLAYGROUND_ROWS; ++j)\r
}\r
}\r
\r
+ #ifdef WIN32\r
bomberman->Update();\r
if (CInputTask::keyDown(DIK_RIGHT)) this->move_right();\r
if (CInputTask::keyDown(DIK_LEFT)) this->move_left();\r
}\r
\r
// =============================================\r
-// Item class\r
+// Tile class\r
// =============================================\r
\r
-#ifdef WIN32\r
-Item:: Item(LPDIRECT3DTEXTURE9 t, int texnr, int subwidth, int subheight, int colnr, int rownr)\r
+Tile::Tile(const CMMPointer<Sprite> &sprite, int subsprite, int col, int row)\r
{\r
- texture = t;\r
- col = colnr;\r
- row = rownr;\r
- tex_num = texnr;\r
- subitem_height = subheight;\r
- subitem_width = subwidth;\r
+ this->sprite = sprite;\r
+ this->col = col;\r
+ this->row = row;\r
+ this->subsprite = subsprite;\r
}\r
-#endif // WIN32\r
\r
-Item::~Item()\r
+Tile::~Tile()\r
{\r
}\r
-\r
-#ifdef WIN32\r
-void Item::Draw()\r
+void Tile::Draw()\r
{\r
+#ifdef WIN32\r
D3DXVECTOR3 center(0.0f, 0.0f, 0.0f); // center at the upper-left corner\r
D3DXVECTOR3 position((FLOAT)PLAYGROUND_BORDER_LEFT+subitem_width*col, (FLOAT)PLAYGROUND_BORDER_TOP+subitem_height*row, 0.0f); // position at 50, 50 with no depth\r
RECT rect = {tex_num*subitem_width,0,(tex_num+1)*subitem_width,subitem_height};\r
d3dspt->Draw(texture, &rect, ¢er, &position, D3DCOLOR_ARGB(255, 255,255,255));\r
+#endif // WIN32\r
}\r
\r
-#endif // WIN32\r
#endif // WIN32\r
};\r
\r
-class Item\r
+class Tile\r
{\r
public:\r
-#ifdef WIN32\r
- Item(LPDIRECT3DTEXTURE9 t, int texnr, int subwidth, int subheight, int colnr, int rownr);\r
-#endif // WIN32\r
- ~Item();\r
+ Tile(const CMMPointer<Sprite> &sprite, int subsprite, int col, int row);\r
+ ~Tile();\r
void Draw();\r
- int col, row, tex_num, subitem_height, subitem_width;\r
private:\r
-#ifdef WIN32\r
- LPDIRECT3DTEXTURE9 texture;\r
-#endif // WIN32\r
+ CMMPointer<Sprite> sprite;\r
+ int col, row, subsprite;\r
};\r
\r
class Playground : public ITask\r
#endif // WIN32\r
\r
Bomberman *bomberman;\r
- Item *field[PLAYGROUND_COLS][PLAYGROUND_ROWS];\r
+ Tile *field[PLAYGROUND_COLS][PLAYGROUND_ROWS];\r
\r
void move_up();\r
void move_down();\r