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> player_sprite = this->getKernel()->getSpriteManager()->getSprite(SPR_PLAYER);\r
+ bomberman = new Bomberman(player_sprite, 20, 66);\r
if (field[0][0] != NULL)\r
{\r
delete field[0][0];\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
- if (CInputTask::keyDown(DIK_UP)) this->move_up();\r
- if (CInputTask::keyDown(DIK_DOWN)) this->move_down();\r
+ if (CInputTask::keyDown(SDLK_RIGHT)) this->move_right();\r
+ if (CInputTask::keyDown(SDLK_LEFT)) this->move_left();\r
+ if (CInputTask::keyDown(SDLK_UP)) this->move_up();\r
+ if (CInputTask::keyDown(SDLK_DOWN)) this->move_down();\r
\r
\r
+ #ifdef WIN32\r
d3dspt->End(); // end sprite drawing\r
\r
// do fps thingie\r
// Bomberman class\r
// =============================================\r
\r
-Bomberman::Bomberman(int xloc, int yloc)\r
+Bomberman::Bomberman(const CMMPointer<Sprite> &sprite, int xloc, int yloc)\r
{\r
- #ifdef WIN32\r
- HRESULT res = D3DXCreateTextureFromFile(d3ddev, L"data/powkick.png", &texture);\r
- if (res != D3D_OK) texture = NULL;\r
- #endif // WIN32\r
- x = xloc;\r
- y = yloc;\r
+ this->sprite = sprite;\r
+ this->x = xloc;\r
+ this->y = yloc;\r
}\r
\r
Bomberman::~Bomberman()\r
{\r
- #ifdef WIN32\r
- if (texture != NULL) texture->Release();\r
- #endif // WIN32\r
}\r
\r
void Bomberman::Update()\r
{\r
- #ifdef WIN32\r
- D3DXVECTOR3 center(0.0f, 0.0f, 0.0f); // center at the upper-left corner\r
- D3DXVECTOR3 position((FLOAT)x, (FLOAT)y, 0.0f); // position at 50, 50 with no depth\r
- RECT rect = {0,0,40,36};\r
- d3dspt->Draw(texture, &rect, ¢er, &position, D3DCOLOR_XRGB(255,255,255));\r
- #endif // WIN32\r
+ this->sprite->blit(\r
+ this->x,\r
+ this->y,\r
+ 1.0, 1.0, 0, 0, COLOUR_RGBA(255, 255, 255, 255)\r
+ );\r
}\r
\r
void Bomberman::move(int xloc, int yloc)\r
#define SCREEN_HEIGHT 480\r
\r
SpriteData defaultSprites[] = {\r
- {SPR_FIELD, "Data/FIELD0.png", SCREEN_WIDTH, SCREEN_HEIGHT},\r
- {SPR_TILE, "Data/Tiles0.png", FIELD_UNIT_WIDTH, FIELD_UNIT_HEIGHT},\r
+ {SPR_FIELD, "Data/FIELD0.png", SCREEN_WIDTH, SCREEN_HEIGHT},\r
+ {SPR_TILE, "Data/Tiles0.png", FIELD_UNIT_WIDTH, FIELD_UNIT_HEIGHT},\r
+ {SPR_PLAYER, "Data/POWBOMB.png", FIELD_UNIT_WIDTH, FIELD_UNIT_HEIGHT},\r
{SPR_NONE, NULL, 0, 0}\r
};\r
\r