X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=ABM2%2FPlayground.cpp;fp=ABM2%2FPlayground.cpp;h=05de6c177cc8b08dd4611efc48e77e820df789f3;hb=a4a0e436bb55c33e9f8a624f90a5512671b14559;hp=38c905f9907d117325c924dfadf071b1888c7440;hpb=9712243130639ad13f421415171df4e5fc1e4773;p=matthijs%2FABM2.git diff --git a/ABM2/Playground.cpp b/ABM2/Playground.cpp index 38c905f..05de6c1 100755 --- a/ABM2/Playground.cpp +++ b/ABM2/Playground.cpp @@ -42,7 +42,8 @@ bool Playground::Start() if ((double)rand()/RAND_MAX <= 0.9) field[i][j] = new Tile(foreground, 0, i, j); */ // put in a player - bomberman = new Bomberman(20, 66); + CMMPointer player_sprite = this->getKernel()->getSpriteManager()->getSprite(SPR_PLAYER); + bomberman = new Bomberman(player_sprite, 20, 66); if (field[0][0] != NULL) { delete field[0][0]; @@ -76,14 +77,14 @@ void Playground::Update() } } - #ifdef WIN32 bomberman->Update(); - if (CInputTask::keyDown(DIK_RIGHT)) this->move_right(); - if (CInputTask::keyDown(DIK_LEFT)) this->move_left(); - if (CInputTask::keyDown(DIK_UP)) this->move_up(); - if (CInputTask::keyDown(DIK_DOWN)) this->move_down(); + if (CInputTask::keyDown(SDLK_RIGHT)) this->move_right(); + if (CInputTask::keyDown(SDLK_LEFT)) this->move_left(); + if (CInputTask::keyDown(SDLK_UP)) this->move_up(); + if (CInputTask::keyDown(SDLK_DOWN)) this->move_down(); + #ifdef WIN32 d3dspt->End(); // end sprite drawing // do fps thingie @@ -289,31 +290,24 @@ void Playground::move_right() // Bomberman class // ============================================= -Bomberman::Bomberman(int xloc, int yloc) +Bomberman::Bomberman(const CMMPointer &sprite, int xloc, int yloc) { - #ifdef WIN32 - HRESULT res = D3DXCreateTextureFromFile(d3ddev, L"data/powkick.png", &texture); - if (res != D3D_OK) texture = NULL; - #endif // WIN32 - x = xloc; - y = yloc; + this->sprite = sprite; + this->x = xloc; + this->y = yloc; } Bomberman::~Bomberman() { - #ifdef WIN32 - if (texture != NULL) texture->Release(); - #endif // WIN32 } void Bomberman::Update() { - #ifdef WIN32 - D3DXVECTOR3 center(0.0f, 0.0f, 0.0f); // center at the upper-left corner - D3DXVECTOR3 position((FLOAT)x, (FLOAT)y, 0.0f); // position at 50, 50 with no depth - RECT rect = {0,0,40,36}; - d3dspt->Draw(texture, &rect, ¢er, &position, D3DCOLOR_XRGB(255,255,255)); - #endif // WIN32 + this->sprite->blit( + this->x, + this->y, + 1.0, 1.0, 0, 0, COLOUR_RGBA(255, 255, 255, 255) + ); } void Bomberman::move(int xloc, int yloc)