// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <map>
+#include <typeinfo>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Uint8 a;
/* Draw the real background */
- le_world->background->draw(le_world->displaymanager.get_viewport(),
- LAYER_BACKGROUND0);
+ le_world->background->draw(*le_world->camera, LAYER_BACKGROUND0);
if(le_current.IsTile())
{
continue;
/* to support frames: img_bsod_left[(frame / 5) % 4] */
- ViewPort viewport;
+ Camera viewport;
viewport.set_translation(Vector(pos_x, pos_y));
badguy->draw(viewport, 0);
}
Menu* object_properties_menu = new Menu();
bool loop = true;
- object_properties_menu->additem(MN_LABEL,pobj->type() + " Properties",0,0);
+ std::string type = typeid(pobj).name();
+ object_properties_menu->additem(MN_LABEL, type + " Properties",0,0);
object_properties_menu->additem(MN_HL,"",0,0);
BadGuy* pbad = dynamic_cast<BadGuy*>(pobj);
if(le_current.IsObject())
{
le_level_changed = true;
- std::string type = le_current.obj->type();
+ BadGuy* pbadguy = dynamic_cast<BadGuy*>(le_current.obj);
- if(type == "BadGuy")
+ if(pbadguy)
{
- ViewPort viewport(le_world->displaymanager.get_viewport());
+ Camera& camera = *le_world->camera;
DisplayManager dummy;
- BadGuy* pbadguy = dynamic_cast<BadGuy*>(le_current.obj);
- le_world->bad_guys.push_back(new BadGuy(dummy, pbadguy->kind, cursor_x + viewport.get_translation().x, cursor_y + viewport.get_translation().y));
+ le_world->bad_guys.push_back(
+ new BadGuy(dummy, pbadguy->kind,
+ cursor_x + camera.get_translation().x,
+ cursor_y + camera.get_translation().y));
le_world->gameobjects.push_back(le_world->bad_guys.back());
}
}
/* if there is a bad guy over there, remove it */
// XXX TODO
for(std::vector<GameObject*>::iterator it = le_world->gameobjects.begin();
- it != le_world->gameobjects.end(); ++it)
- if ((*it)->type() == "BadGuy")
+ it != le_world->gameobjects.end(); ++it) {
+ BadGuy* badguy = dynamic_cast<BadGuy*>((*it));
+ if (badguy)
{
- BadGuy* pbadguy = dynamic_cast<BadGuy*>((*it));
- if(rectcollision(cursor_base, pbadguy->base))
+ if(rectcollision(cursor_base, badguy->base))
{
delete (*it);
//le_world->bad_guys.erase(it);
break;
}
}
+ }
break;
case SQUARE:
for(std::vector<GameObject*>::iterator it = le_world->gameobjects.begin();
it != le_world->gameobjects.end(); ++it /* will be at end of loop */)
{
- if ((*it)->type() == "BadGuy")
+ MovingObject* pmobject = dynamic_cast<MovingObject*> (*it);
+ if (pmobject)
{
- MovingObject* pmobject = dynamic_cast<MovingObject*> (*it);
if(pmobject->base.x/32 >= x1 && pmobject->base.x/32 <= x2
&& pmobject->base.y/32 >= y1 && pmobject->base.y/32 <= y2)
{