From 6b71d177925ff21787fb792dc05ac048eadbbca3 Mon Sep 17 00:00:00 2001 From: johndoe123 Date: Tue, 5 Jul 2011 14:46:10 +0000 Subject: NEVERHOOD: Start with the CollisionMan class --- engines/neverhood/collisionman.cpp | 67 ++++++++++++++++++++++++++++++++++++++ engines/neverhood/collisionman.h | 53 ++++++++++++++++++++++++++++++ engines/neverhood/module.mk | 1 + engines/neverhood/neverhood.cpp | 4 +++ engines/neverhood/neverhood.h | 2 ++ 5 files changed, 127 insertions(+) create mode 100644 engines/neverhood/collisionman.cpp create mode 100644 engines/neverhood/collisionman.h diff --git a/engines/neverhood/collisionman.cpp b/engines/neverhood/collisionman.cpp new file mode 100644 index 0000000000..cc40a47f1e --- /dev/null +++ b/engines/neverhood/collisionman.cpp @@ -0,0 +1,67 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "neverhood/collisionman.h" + +namespace Neverhood { + +CollisionMan::CollisionMan(NeverhoodEngine *vm) + : _vm(vm), _hitRects(NULL) { +} + +CollisionMan::~CollisionMan() { +} + +void CollisionMan::setHitRects(uint32 id) { + setHitRects(_vm->_staticData->getHitRectList(id)); +} + +void CollisionMan::setHitRects(HitRectList *hitRects) { + _hitRects = hitRects; +} + +HitRect *CollisionMan::findHitRectAtPos(int16 x, int16 y) { + // TODO + return NULL; +} + +void CollisionMan::addSprite(Sprite *sprite) { + _sprites.push_back(sprite); +} + +void CollisionMan::removeSprite(Sprite *sprite) { + // TODO +} + +void CollisionMan::clearSprites() { + _sprites.clear(); +} + +void CollisionMan::save() { + // TODO +} + +void CollisionMan::restore() { + // TODO +} + +} // End of namespace Neverhood diff --git a/engines/neverhood/collisionman.h b/engines/neverhood/collisionman.h new file mode 100644 index 0000000000..cfa248ab4b --- /dev/null +++ b/engines/neverhood/collisionman.h @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef NEVERHOOD_COLLISIONMAN_H +#define NEVERHOOD_COLLISIONMAN_H + +#include "neverhood/neverhood.h" +#include "neverhood/sprite.h" +#include "neverhood/staticdata.h" + +namespace Neverhood { + +class CollisionMan { +public: + CollisionMan(NeverhoodEngine *vm); + ~CollisionMan(); + void setHitRects(uint32 id); + void setHitRects(HitRectList *hitRects); + HitRect *findHitRectAtPos(int16 x, int16 y); + void addSprite(Sprite *sprite); + void removeSprite(Sprite *sprite); + void clearSprites(); + void save(); + void restore(); +protected: + NeverhoodEngine *_vm; + HitRectList *_hitRects; + Common::Array _sprites; +}; + + +} // End of namespace Neverhood + +#endif /* NEVERHOOD_COLLISIONMAN_H */ diff --git a/engines/neverhood/module.mk b/engines/neverhood/module.mk index 8a25e25bab..f139268c36 100644 --- a/engines/neverhood/module.mk +++ b/engines/neverhood/module.mk @@ -3,6 +3,7 @@ MODULE := engines/neverhood MODULE_OBJS = \ background.o \ blbarchive.o \ + collisionman.o \ detection.o \ entity.o \ gamemodule.o \ diff --git a/engines/neverhood/neverhood.cpp b/engines/neverhood/neverhood.cpp index 24033f0fd1..8b74b6620e 100644 --- a/engines/neverhood/neverhood.cpp +++ b/engines/neverhood/neverhood.cpp @@ -28,6 +28,7 @@ #include "engines/util.h" #include "neverhood/neverhood.h" #include "neverhood/blbarchive.h" +#include "neverhood/collisionman.h" #include "neverhood/gamemodule.h" #include "neverhood/graphics.h" #include "neverhood/resourceman.h" @@ -128,6 +129,7 @@ Common::Error NeverhoodEngine::run() { } #endif + _collisionMan = new CollisionMan(this); _gameModule = new GameModule(this); // Preliminary main loop, needs some more work but works for testing @@ -180,6 +182,8 @@ Common::Error NeverhoodEngine::run() { } delete _gameModule; + delete _collisionMan; + delete _res; delete _screen; diff --git a/engines/neverhood/neverhood.h b/engines/neverhood/neverhood.h index b2ba5f7ff0..4a07d6a1be 100644 --- a/engines/neverhood/neverhood.h +++ b/engines/neverhood/neverhood.h @@ -39,6 +39,7 @@ enum NeverhoodGameFeatures { struct NeverhoodGameDescription; +class CollisionMan; class GameModule; class ResourceMan; class Screen; @@ -76,6 +77,7 @@ public: ResourceMan *_res; GameModule *_gameModule; StaticData *_staticData; + CollisionMan *_collisionMan; public: -- cgit v1.2.3