Skip to content

Commit

Permalink
FULLPIPE: Implemented several high level *AtPos functions
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Sep 6, 2013
1 parent 028772d commit b209329
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 4 deletions.
32 changes: 32 additions & 0 deletions engines/fullpipe/gfx.cpp
Expand Up @@ -247,6 +247,19 @@ bool PictureObject::isPointInside(int x, int y) {
return res;
}

bool PictureObject::isPixelHitAtPos(int x, int y) {
int oldx = _picture->_x;
int oldy = _picture->_y;

_picture->_x = _ox;
_picture->_y = _oy;
bool res = _picture->isPixelHitAtPos(x, y);
_picture->_x = oldx;
_picture->_y = oldy;

return res;
}

GameObject::GameObject() {
_okeyCode = 0;
_flags = 0;
Expand Down Expand Up @@ -590,6 +603,25 @@ bool Picture::isPointInside(int x, int y) {
return false;
}

bool Picture::isPixelHitAtPos(int x, int y) {
if (x < _x || y < _y || x >= _x + _width || y >= _y + _height)
return false;

if (!_bitmap )
init();

_bitmap->_x = _x;
_bitmap->_y = _y;

return _bitmap->isPixelHitAtPos(x, y);
}

bool Bitmap::isPixelHitAtPos(int x, int y) {
debug(0, "STUB: Bitmap::isPixelHitAtPos(%d, %d)", x, y);

return false;
}

void Bitmap::putDib(int x, int y, int32 *palette) {
debug(0, "Bitmap::putDib(%d, %d)", x, y);

Expand Down
4 changes: 4 additions & 0 deletions engines/fullpipe/gfx.h
Expand Up @@ -60,6 +60,8 @@ struct Bitmap {

void drawShaded(int type, int x, int y, byte *palette);
void drawRotated(int x, int y, int angle, byte *palette);

bool isPixelHitAtPos(int x, int y);
};

class Picture : public MemoryObject {
Expand Down Expand Up @@ -103,6 +105,7 @@ class Picture : public MemoryObject {

Common::Point *getDimensions(Common::Point *p);
bool isPointInside(int x, int y);
bool isPixelHitAtPos(int x, int y);

byte *getPaletteData() { return _paletteData; }
void setPaletteData(byte *pal);
Expand Down Expand Up @@ -161,6 +164,7 @@ class PictureObject : public GameObject {

bool setPicAniInfo(PicAniInfo *picAniInfo);
bool isPointInside(int x, int y);
bool isPixelHitAtPos(int x, int y);
};

class Background : public CObject {
Expand Down
27 changes: 23 additions & 4 deletions engines/fullpipe/scene.cpp
Expand Up @@ -483,15 +483,34 @@ StaticANIObject *Scene::getStaticANIObjectAtPos(int x, int y) {
}

PictureObject *Scene::getPictureObjectAtPos(int x, int y) {
warning("STUB: Scene::getPictureObjectAtPos(%d, %d)", x, y);
PictureObject *res = 0;

return 0;
for (uint i = 0; i < _picObjList.size(); i++) {
PictureObject *p = (PictureObject *)_picObjList[i];
if ((p->_field_8 & 1) && (p->_flags & 4) &&
p->isPixelHitAtPos(x, y) &&
(!res || res->_priority >= p->_priority))
res = p;
}

return res;
}

int Scene::getPictureObjectIdAtPos(int x, int y) {
warning("STUB: Scene::getPictureObjectIdAtPos(%d, %d)", x, y);
PictureObject *resp = 0;
int res = 0;

return 0;
for (uint i = 0; i < _picObjList.size(); i++) {
PictureObject *p = (PictureObject *)_picObjList[i];
if ((p->_field_8 & 1) && (p->_flags & 4) &&
p->isPixelHitAtPos(x, y) &&
(!res || resp->_priority >= p->_priority)) {
resp = p;
res = p->_id;
}
}

return res;
}

void Scene::update(int counterdiff) {
Expand Down

0 comments on commit b209329

Please sign in to comment.