X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2FABM2.git;a=blobdiff_plain;f=ABM2%2FPlayground.cpp;fp=ABM2%2FPlayground.cpp;h=27f1f72ee591df6d8e244bdddfd71116348ce17a;hp=41c8b4b55fd81e407adec9a2e3202dc2f2fbdb0d;hb=4ab7ea7617b0c8cb1ab19bea1d439b3d1bb9839c;hpb=c100d6f67b06abb348319e277a66b6b7ab0c4bd5 diff --git a/ABM2/Playground.cpp b/ABM2/Playground.cpp index 41c8b4b..27f1f72 100755 --- a/ABM2/Playground.cpp +++ b/ABM2/Playground.cpp @@ -79,27 +79,33 @@ bool Playground::Start() } } + CMMPointer tile_sprite = this->getKernel()->getSpriteManager()->getSprite(SPR_TILE); // put in non-destructible blocks for (int i=0; iPlayField[j*PLAYGROUND_NUMFIELD_X+i]) { case BRICK: - //field[i][j] = new Item(foreground, 0, FIELD_UNIT_WIDTH, FIELD_UNIT_HEIGHT, i, j); + subsprite = SPR_SUB_BRICK; break; case SOLID: - #ifdef WIN32 - field[i][j] = new Item(foreground, 1, FIELD_UNIT_WIDTH, FIELD_UNIT_HEIGHT, i, j); - #endif // WIN32 + subsprite = SPR_SUB_SOLID; break; } + if (subsprite != -1) + field[i][j] = new Tile(tile_sprite, subsprite, i, j); + } + } /* // put in desctructible blocks with chance 90% for (int i=0; i s = this->getKernel()->getSpriteManager()->getSprite(SPR_FIELD); s->blit(0, 0, 1.0, 1.0, 0, 0, COLOUR_RGBA(0, 0, 255, 255)); - #ifdef WIN32 - if(CInputTask::keyDown(DIK_ESCAPE))CKernel::GetSingleton().KillAllTasks(); - - d3dspt->Begin(NULL); // begin sprite drawing - - // draw the sprite - D3DXVECTOR3 center(0.0f, 0.0f, 0.0f); // center at the upper-left corner - D3DXVECTOR3 position(0.0f, 0.0f, 0.0f); // position at 50, 50 with no depth - d3dspt->Draw(background, NULL, NULL, NULL, D3DCOLOR_XRGB(255, 255, 255)); - for (int i=0; iUpdate(); if (CInputTask::keyDown(DIK_RIGHT)) this->move_right(); if (CInputTask::keyDown(DIK_LEFT)) this->move_left(); @@ -494,32 +491,27 @@ void Bomberman::move_to_direction(TMoveDirection dir) } // ============================================= -// Item class +// Tile class // ============================================= -#ifdef WIN32 -Item:: Item(LPDIRECT3DTEXTURE9 t, int texnr, int subwidth, int subheight, int colnr, int rownr) +Tile::Tile(const CMMPointer &sprite, int subsprite, int col, int row) { - texture = t; - col = colnr; - row = rownr; - tex_num = texnr; - subitem_height = subheight; - subitem_width = subwidth; + this->sprite = sprite; + this->col = col; + this->row = row; + this->subsprite = subsprite; } -#endif // WIN32 -Item::~Item() +Tile::~Tile() { } - -#ifdef WIN32 -void Item::Draw() +void Tile::Draw() { +#ifdef WIN32 D3DXVECTOR3 center(0.0f, 0.0f, 0.0f); // center at the upper-left corner 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 RECT rect = {tex_num*subitem_width,0,(tex_num+1)*subitem_width,subitem_height}; d3dspt->Draw(texture, &rect, ¢er, &position, D3DCOLOR_ARGB(255, 255,255,255)); +#endif // WIN32 } -#endif // WIN32