[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src/worldobjs conveyor_belt.cxx,NONE,1.1
From: |
grumbel |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src/worldobjs conveyor_belt.cxx,NONE,1.1 conveyor_belt.hxx,NONE,1.1 ice_block.cxx,NONE,1.1 ice_block.hxx,NONE,1.1 info_box.cxx,NONE,1.1 info_box.hxx,NONE,1.1 switch_door.cxx,NONE,1.1 switch_door.hxx,NONE,1.1 teleporter.cxx,NONE,1.1 teleporter.hxx,NONE,1.1 Makefile.am,1.5,1.6 ConveyorBelt.hh,1.23,NONE IceBlock.hh,1.24,NONE InfoBox.hh,1.8,NONE SwitchDoor.hh,1.24,NONE Teleporter.cc,1.40,NONE |
Date: |
12 Jun 2002 19:03:12 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src/worldobjs
In directory dark:/tmp/cvs-serv12687
Modified Files:
Makefile.am
Added Files:
conveyor_belt.cxx conveyor_belt.hxx ice_block.cxx
ice_block.hxx info_box.cxx info_box.hxx switch_door.cxx
switch_door.hxx teleporter.cxx teleporter.hxx
Removed Files:
ConveyorBelt.hh IceBlock.hh InfoBox.hh SwitchDoor.hh
Teleporter.cc
Log Message:
The big rename...
--- NEW FILE: conveyor_belt.cxx ---
// $Id: conveyor_belt.cxx,v 1.1 2002/06/12 19:03:10 grumbel Exp $
//
// Pingus - A free Lemmings clone
// Copyright (C) 2000 Ingo Ruhnke <address@hidden>
//
// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <fstream>
#include "../col_map.hxx"
#include "../editor/editor_view.hxx"
#include "../world.hxx"
#include "../pingu_holder.hxx"
#include "../pingus_resource.hxx"
#include "../xml_helper.hxx"
#include "conveyor_belt.hxx"
#include "../pingu.hxx"
#include "../boost/smart_ptr.hpp"
ConveyorBeltData::ConveyorBeltData ()
{
width = 5;
speed = 2;
}
/** Writte the content of this object formated as xml to the given
stream */
void
ConveyorBeltData::write_xml(std::ofstream* xml)
{
(*xml) << " <worldobj type=\"conveyorbelt\">";
XMLhelper::write_vector_xml (xml, pos);
(*xml) << " <width>" << width << "</width>\n"
<< " <speed>" << speed << "</speed>\n"
<< " </worldobj>\n" << std::endl;
}
ConveyorBeltData::ConveyorBeltData (xmlDocPtr doc, xmlNodePtr cur)
{
cur = cur->children;
while (cur != NULL)
{
if (xmlIsBlankNode(cur))
{
cur = cur->next;
continue;
}
else if (strcmp((char*)cur->name, "position") == 0)
{
pos = XMLhelper::parse_vector (doc, cur);
}
else if (strcmp((char*)cur->name, "width") == 0)
{
width = XMLhelper::parse_int (doc, cur);
}
else if (strcmp((char*)cur->name, "speed") == 0)
{
speed = XMLhelper::parse_int (doc, cur);
}
else
std::cout << "ConveyorBeltData::create (): Unhandled " << cur->name <<
std::endl;
cur = cur->next;
}
}
WorldObj*
ConveyorBeltData::create_WorldObj ()
{
return new ConveyorBelt (this);
}
std::list<boost::shared_ptr<EditorObj> >
ConveyorBeltData::create_EditorObj ()
{
EditorObjLst lst;
lst.push_back(boost::shared_ptr<EditorObj> (new EditorConveyorBeltObj
(*this)));
return lst;
}
/***********************/
/* ConveyorBelt */
/***********************/
ConveyorBelt::ConveyorBelt (WorldObjData* data)
{
left_sur = PingusResource::load_surface ("conveyorbelt_left", "worldobjs");
right_sur = PingusResource::load_surface ("conveyorbelt_right", "worldobjs");
middle_sur = PingusResource::load_surface ("conveyorbelt_middle",
"worldobjs");
ConveyorBeltData* obj = dynamic_cast<ConveyorBeltData*>(data);
pos = obj->pos;
speed = obj->speed;
width = obj->width;
counter = 0;
}
void
ConveyorBelt::draw_offset (int x_of, int y_of, float /*s*/)
{
left_sur.put_screen (int(pos.x + x_of), int(pos.y + y_of), int(counter));
for (int i=0; i < width; i++)
middle_sur.put_screen (int(pos.x + left_sur.get_width () +
i*middle_sur.get_width () + x_of),
int(pos.y + y_of),
int(counter));
right_sur.put_screen (int(pos.x + left_sur.get_width () +
width*middle_sur.get_width () + x_of),
int(pos.y + y_of), int(counter));
}
void
ConveyorBelt::draw_colmap ()
{
CL_Surface sur(PingusResource::load_surface("conveyorbelt_cmap",
"worldobjs"));
for (int i=0; i < (width+2); i++)
world->get_colmap()->put(sur, int(pos.x) + (15*i), int(pos.y),
GroundpieceData::GP_SOLID);
}
void
ConveyorBelt::update(float delta)
{
counter += speed * delta;
if (counter >= 14.0f)
counter = 0.0f;
else if (counter < 0.0f)
counter = middle_sur.get_num_frames () - 1;
PinguHolder* holder = world->get_pingu_p();
for (PinguIter pingu = holder->begin (); pingu != holder->end (); ++pingu)
{
if ((*pingu)->get_x() > pos.x
&& (*pingu)->get_x() < pos.x + 15*(width+2)
&& (*pingu)->get_y() > pos.y - 2
&& (*pingu)->get_y() < pos.y + 10)
{
CL_Vector pos = (*pingu)->get_pos ();
pos.x -= speed * delta;
(*pingu)->set_pos (pos);
}
}
}
/*************************/
/* EditorConveyorBeltObj */
/*************************/
EditorConveyorBeltObj::EditorConveyorBeltObj (const ConveyorBeltData& data)
: ConveyorBeltData (data)
{
left_sur = PingusResource::load_surface ("conveyorbelt_left", "worldobjs");
right_sur = PingusResource::load_surface ("conveyorbelt_right", "worldobjs");
middle_sur = PingusResource::load_surface ("conveyorbelt_middle",
"worldobjs");
counter = 0.0f;
}
boost::shared_ptr<EditorObj>
EditorConveyorBeltObj::duplicate()
{
return boost::shared_ptr<EditorObj>(new EditorConveyorBeltObj
(static_cast<ConveyorBeltData> (*this)));
}
void
EditorConveyorBeltObj::draw (EditorView * view)
{
view->draw (left_sur, pos, int(counter));
for (int i=0; i < ConveyorBeltData::width; i++)
view->draw (middle_sur, int(pos.x) + left_sur.get_width () +
i*middle_sur.get_width (),
int(pos.y),
int(counter));
view->draw (right_sur,
int(pos.x) + left_sur.get_width () +
ConveyorBeltData::width*middle_sur.get_width (),
int(pos.y), int(counter));
counter += speed;
if (counter > 14)
counter = 0;
else if (counter < 0)
counter = middle_sur.get_num_frames () - 1;
}
void
EditorConveyorBeltObj::draw_scroll_map(int /*x_pos*/, int /*y_pos*/, int
/*arg_width*/, int /*arg_height*/)
{
// not supported
}
std::list<boost::shared_ptr<EditorObj> >
EditorConveyorBeltObj::create (const CL_Vector& pos)
{
ConveyorBeltData data;
data.pos = pos;
return data.create_EditorObj ();
}
std::string
EditorConveyorBeltObj::status_line()
{
char str[1024];
sprintf (str, "ConveyorBelt - (%f, %f, %f) Speed: %f", pos.x, pos.y, pos.z,
speed);
return str;
}
int
EditorConveyorBeltObj::get_width ()
{
return left_sur.get_width() + right_sur.get_width() + width *
middle_sur.get_width ();
}
int
EditorConveyorBeltObj::get_height ()
{
return middle_sur.get_height ();
}
void
EditorConveyorBeltObj::set_position_offset(const CL_Vector& offset)
{
pos += offset;
}
void
EditorConveyorBeltObj::make_larger ()
{
ConveyorBeltData::width += 1;
}
void
EditorConveyorBeltObj::make_smaller ()
{
ConveyorBeltData::width -= 1;
if (ConveyorBeltData::width < 0)
ConveyorBeltData::width = 0;
}
/* EOF */
--- NEW FILE: conveyor_belt.hxx ---
// $Id: conveyor_belt.hxx,v 1.1 2002/06/12 19:03:10 grumbel Exp $
//
// Pingus - A free Lemmings clone
// Copyright (C) 2000 Ingo Ruhnke <address@hidden>
//
// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef CONVEYORBELT_HH
#define CONVEYORBELT_HH
#include "../worldobj.hxx"
#include "../worldobj_data.hxx"
#include "../editor/rect_editorobj.hxx"
class ConveyorBeltData : public WorldObjData
{
public:
CL_Vector pos;
int width;
double speed;
ConveyorBeltData ();
ConveyorBeltData (xmlDocPtr doc, xmlNodePtr cur);
/** Write the content of this object formatted as xml to the given
stream */
void write_xml(std::ofstream* xml);
///
/** Create an WorldObj from the given data object */
WorldObj* create_WorldObj ();
/** Create an EditorObj from the given data object */
std::list<boost::shared_ptr<EditorObj> > create_EditorObj ();
};
class ConveyorBelt : private ConveyorBeltData,
public WorldObj
{
private:
CL_Surface left_sur;
CL_Surface right_sur;
CL_Surface middle_sur;
float counter;
public:
ConveyorBelt (WorldObjData*);
void draw_offset (int x_of, int y_of, float s = 1.0);
void draw_colmap();
void update(float delta);
float get_z_pos() const { return pos.z; }
};
class EditorConveyorBeltObj : public RectEditorObj,
public ConveyorBeltData
{
private:
CL_Surface left_sur;
CL_Surface right_sur;
CL_Surface middle_sur;
float counter;
public:
EditorConveyorBeltObj (const ConveyorBeltData&);
boost::shared_ptr<EditorObj> duplicate();
void draw (EditorView * view);
void draw_scroll_map(int x_pos, int y_pos, int arg_width, int arg_height);
int get_width ();
int get_height ();
float get_z_pos () { return pos.z; }
void set_position_offset(const CL_Vector &);
/// The saving will be done in EditorTeleporterObj::save_xml
static std::list<boost::shared_ptr<EditorObj> > create (WorldObjData* obj);
/** Create the object with reasonable defaults */
static std::list<boost::shared_ptr<EditorObj> > create (const CL_Vector& pos);
CL_Vector get_upper_left_corner() { return pos; }
void write_xml (std::ofstream* xml) { ConveyorBeltData::write_xml (xml); }
std::string status_line();
void make_larger ();
void make_smaller ();
};
#endif
/* EOF */
--- NEW FILE: ice_block.cxx ---
// $Id: ice_block.cxx,v 1.1 2002/06/12 19:03:10 grumbel Exp $
//
// Pingus - A free Lemmings clone
// Copyright (C) 2000 Ingo Ruhnke <address@hidden>
//
// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <fstream>
#include "../col_map.hxx"
#include "../world.hxx"
#include "../pingu_holder.hxx"
#include "../pingus_resource.hxx"
#include "../xml_helper.hxx"
#include "../pingu_map.hxx"
#include "../game_time.hxx"
#include "ice_block.hxx"
#include "../pingu.hxx"
#include "../boost/smart_ptr.hpp"
IceBlockData::IceBlockData ()
{
width = 1;
}
void
IceBlockData::write_xml(std::ofstream* xml)
{
(*xml) << " <worldobj type=\"iceblock\">";
XMLhelper::write_vector_xml (xml, pos);
(*xml) << " <width>" << width << "</width>\n"
<< " </worldobj>\n" << std::endl;
}
///
IceBlockData::IceBlockData (xmlDocPtr doc, xmlNodePtr cur)
{
cur = cur->children;
while (cur != NULL)
{
if (xmlIsBlankNode(cur))
{
cur = cur->next;
continue;
}
else if (strcmp((char*)cur->name, "position") == 0)
{
pos = XMLhelper::parse_vector (doc, cur);
}
else if (strcmp((char*)cur->name, "width") == 0)
{
width = XMLhelper::parse_int (doc, cur);
}
else
std::cout << "IceBlockData::creata (): Unhandled " << cur->name <<
std::endl;
cur = cur->next;
}
}
WorldObj*
IceBlockData::create_WorldObj ()
{
return new IceBlock (*this);
}
std::list<boost::shared_ptr<EditorObj> >
IceBlockData::create_EditorObj ()
{
EditorObjLst lst;
lst.push_back(boost::shared_ptr<EditorObj> (new EditorIceBlockObj (*this)));
return lst;
}
IceBlock::IceBlock (const IceBlockData& data)
{
pos = data.pos;
width = data.width;
block_sur = PingusResource::load_surface ("iceblock", "worldobjs");
thickness = 1.0;
is_finished = false;
last_contact = 0;
}
///
void
IceBlock::draw_colmap()
{
CL_Surface surf (PingusResource::load_surface("iceblock_cmap", "worldobjs"));
world->get_colmap()->put(surf, (int)pos.x, (int)pos.y,
GroundpieceData::GP_GROUND);
}
///
void
IceBlock::draw_offset(int x_of, int y_of, float /*s*/)
{
if (is_finished)
return;
block_sur.put_screen (int(pos.x + x_of), int(pos.y + y_of),
(int)((1.0 - thickness) * (block_sur.get_num_frames ()
- 1)));
}
///
void
IceBlock::update(float /*delta*/)
{
if (is_finished)
return;
PinguHolder* holder = world->get_pingu_p();
for (PinguIter pingu = holder->begin (); pingu != holder->end (); pingu++)
{
if ((*pingu)->get_x() > pos.x && (*pingu)->get_x() < pos.x +
block_sur.get_width()
&& (*pingu)->get_y() > pos.y - 4 && (*pingu)->get_y() < pos.y +
block_sur.get_height())
{
last_contact = GameTime::get_time ();
}
}
if (last_contact && last_contact + 1000 > GameTime::get_time ())
{
//std::cout << "IceBlock: Catched Pingu: " << thickness << std::endl;
thickness -= 0.01f;
if (thickness < 0.0)
{
is_finished = true;
thickness = 0.0;
CL_Surface surf(PingusResource::load_surface("iceblock_cmap",
"worldobjs"));
world->get_colmap()->remove(surf, (int)pos.x, (int)pos.y);
world->get_gfx_map()->remove(surf, (int)pos.x, (int)pos.y);
return;
}
}
}
EditorIceBlockObj::EditorIceBlockObj (const IceBlockData& data)
: SpriteEditorObj ("iceblock", "worldobjs", pos)
{
pos = data.pos;
IceBlockData::width = data.width;
}
/** Create the object with resonable defaults */
std::list<boost::shared_ptr<EditorObj> >
EditorIceBlockObj::create (const CL_Vector& pos)
{
IceBlockData data;
data.pos = pos;
return data.create_EditorObj ();
}
std::string
EditorIceBlockObj::status_line()
{
char str[1024];
sprintf (str, "IceBlock - %f %f %f", pos.x, pos.y, pos.z);
return str;
}
boost::shared_ptr<EditorObj>
EditorIceBlockObj::duplicate()
{
std::cout << "EditorIceBlockObj::duplicate(): Not implemented" << std::endl;
return boost::shared_ptr<EditorObj> ();
}
/* EOF */
--- NEW FILE: ice_block.hxx ---
// $Id: ice_block.hxx,v 1.1 2002/06/12 19:03:10 grumbel Exp $
//
// Pingus - A free Lemmings clone
// Copyright (C) 2000 Ingo Ruhnke <address@hidden>
//
// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef ICEBLOCK_HH
#define ICEBLOCK_HH
#include "../worldobj_data.hxx"
#include "../editor/sprite_editorobj.hxx"
class WorldObj;
namespace boost {
template <class T> class shared_ptr;
}
class IceBlockData : public WorldObjData
{
public:
/// The upper/left position of the iceblock's
CL_Vector pos;
/** The number of iceblocks, only complete blocks are supported */
int width;
int last_contact;
IceBlockData ();
IceBlockData (xmlDocPtr doc, xmlNodePtr cur);
/** Write the content of this object formatted as xml to the given
stream */
void write_xml(std::ofstream* xml);
/** Create an WorldObj from the given data object */
WorldObj* create_WorldObj ();
/** Create an EditorObj from the given data object */
std::list<boost::shared_ptr<EditorObj> > create_EditorObj ();
};
class IceBlock : public IceBlockData,
public WorldObj
{
private:
CL_Surface block_sur;
float thickness;
bool is_finished;
public:
IceBlock (const IceBlockData& data);
float get_z_pos() const { return 100; }
void draw_colmap();
void draw_offset(int x, int y, float s = 1.0);
void update(float delta);
};
class EditorIceBlockObj : public IceBlockData,
public SpriteEditorObj
{
private:
public:
EditorIceBlockObj (const IceBlockData& data);
/** Create the object with resonable defaults */
static std::list<boost::shared_ptr<EditorObj> > create (const CL_Vector& pos);
void write_xml(std::ofstream* xml) { IceBlockData::write_xml (xml); }
boost::shared_ptr<EditorObj> duplicate();
std::string status_line();
};
#endif
/* EOF */
--- NEW FILE: info_box.cxx ---
// $Id: info_box.cxx,v 1.1 2002/06/12 19:03:10 grumbel Exp $
//
// Pingus - A free Lemmings clone
// Copyright (C) 2000 Ingo Ruhnke <address@hidden>
//
// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <fstream>
#include <ClanLib/Display/Font/font.h>
#include <ClanLib/Display/Display/display.h>
#include "../pingu_holder.hxx"
#include "../world.hxx"
#include "../pingus_resource.hxx"
#include "../xml_helper.hxx"
#include "info_box.hxx"
#include "../pingu.hxx"
#include "../boost/smart_ptr.hpp"
InfoBoxData::InfoBoxData ()
{
}
InfoBoxData::~InfoBoxData ()
{
}
WorldObj*
InfoBoxData::create_WorldObj()
{
return new InfoBox (*this);
}
EditorObjLst
InfoBoxData::create_EditorObj()
{
EditorObjLst lst;
lst.push_back (boost::shared_ptr<EditorObj>(new EditorInfoBox (*this)));
return lst;
}
InfoBoxData::InfoBoxData (xmlDocPtr doc, xmlNodePtr cur)
{
cur = cur->children;
while (cur != NULL)
{
if (xmlIsBlankNode(cur))
{
cur = cur->next;
continue;
}
else if (strcmp((char*)cur->name, "position") == 0)
{
pos = XMLhelper::parse_vector (doc, cur);
}
else if (strcmp((char*)cur->name, "info-text") == 0)
{
info_text = XMLhelper::parse_string (doc, cur);
}
else
std::cout << "InfoBox::creata (): Unhandled " << cur->name << std::endl;
cur = cur->next;
}
}
void
InfoBoxData::write_xml(std::ofstream* xml)
{
(*xml) << " <worldobj type=\"infobox\">\n";
XMLhelper::write_vector_xml (xml, pos);
(*xml) << " <info-text>" << info_text << "</info-text>\n"
<< " </worldobj>\n" << std::endl;
}
InfoBox::InfoBox (const InfoBoxData& data)
: InfoBoxData (data),
sprite ("infobox", "worldobjs"),
is_open (false)
{
sprite.set_align_center_bottom ();
font = PingusResource::load_font("Fonts/pingus_small", "fonts");
}
void
InfoBox::draw_offset (int x, int y, float /*s*/)
{
int x_pos = int(pos.x) + x;
int y_pos = int(pos.y) + y - 100;
if (is_open)
{
int width = font->get_text_width (info_text.c_str ());
int border = 6;
CL_Display::draw_line (int(pos.x + x), int(pos.y + y),
x_pos, y_pos, 0.0f, 1.0f, 0.0f, 1.0f);
sprite.put_screen (pos + CL_Vector (x, y));
CL_Display::fill_rect (x_pos - width/2 - border, y_pos - border,
x_pos + width/2 + border, y_pos + font->get_height
() + border,
0.0, 0.0, 0.0, 1.0);
font->print_center (x_pos, y_pos, info_text.c_str ());
}
else
{
sprite.put_screen (pos + CL_Vector (x, y));
}
}
void
InfoBox::update (float delta)
{
sprite.update (delta);
PinguHolder* holder = world->get_pingu_p();
for (PinguIter pingu = holder->begin (); pingu != holder->end (); ++pingu)
{
if ((*pingu)->is_inside (int(pos.x - 16), int(pos.y - 32),
int(pos.x + 16), int(pos.y)))
{
is_open = true;
}
}
}
EditorInfoBox::EditorInfoBox(const InfoBoxData& data)
: InfoBoxData (data),
SpriteEditorObj ("infobox", "worldobjs", pos)
{
sprite.set_align_center_bottom ();
}
std::list<boost::shared_ptr<EditorObj> >
EditorInfoBox::create (const CL_Vector& pos)
{
std::list<boost::shared_ptr<EditorObj> > lst;
InfoBoxData data;
data.pos = pos;
lst.push_back (boost::shared_ptr<EditorObj>(new EditorInfoBox (data)));
return lst;
}
boost::shared_ptr<EditorObj>
EditorInfoBox::duplicate()
{
return boost::shared_ptr<EditorObj>(new EditorInfoBox (*this));
}
std::string
EditorInfoBox::status_line ()
{
return "InfoBox";
}
/* EOF */
--- NEW FILE: info_box.hxx ---
// $Id: info_box.hxx,v 1.1 2002/06/12 19:03:10 grumbel Exp $
//
// Pingus - A free Lemmings clone
// Copyright (C) 2000 Ingo Ruhnke <address@hidden>
//
// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef INFOBOX_HH
#define INFOBOX_HH
#include "../worldobj.hxx"
#include "../worldobj_data.hxx"
#include "../editor/sprite_editorobj.hxx"
class CL_Font;
class CL_Vector;
class _xmlDoc; typedef _xmlDoc* xmlDocPtr;
class _xmlNode; typedef _xmlNode* xmlNodePtr;
class InfoBoxData : public WorldObjData
{
public:
InfoBoxData ();
InfoBoxData (xmlDocPtr doc, xmlNodePtr cur);
~InfoBoxData ();
std::string info_text;
CL_Vector pos;
CL_Vector text_pos;
void write_xml(std::ofstream* xml);
WorldObj* create_WorldObj();
EditorObjLst create_EditorObj();
};
class InfoBox : public InfoBoxData,
public WorldObj
{
private:
Sprite sprite;
CL_Font* font;
bool is_open;
public:
InfoBox (const InfoBoxData& data);
void draw_offset (int x, int y, float s = 1.0);
void update (float delta);
float get_z_pos() const { return pos.z; }
};
class EditorInfoBox : public InfoBoxData,
public SpriteEditorObj
{
public:
EditorInfoBox (const InfoBoxData& data);
static std::list<boost::shared_ptr<EditorObj> > create (const CL_Vector& pos);
void write_xml(std::ofstream* xml) { InfoBoxData::write_xml (xml); }
boost::shared_ptr<EditorObj> duplicate();
std::string status_line ();
};
#endif
/* EOF */
--- NEW FILE: switch_door.cxx ---
// $Id: switch_door.cxx,v 1.1 2002/06/12 19:03:10 grumbel Exp $
//
// Pingus - A free Lemmings clone
// Copyright (C) 2000 Ingo Ruhnke <address@hidden>
//
// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <fstream>
#include "../col_map.hxx"
#include "../world.hxx"
#include "../pingu_holder.hxx"
#include "../pingus_resource.hxx"
#include "../editor/editor_view.hxx"
#include "../xml_helper.hxx"
#include "switch_door.hxx"
#include "../pingu.hxx"
#include "../boost/smart_ptr.hpp"
SwitchDoorData::SwitchDoorData ()
{
door_height = 10;
}
SwitchDoorData::SwitchDoorData (xmlDocPtr doc, xmlNodePtr cur)
{
cur = cur->children;
while (cur != NULL)
{
if (xmlIsBlankNode(cur)) {
cur = cur->next;
continue;
}
if (strcmp((char*)cur->name, "switch") == 0)
{
xmlNodePtr subcur = cur->children;
while (subcur != NULL)
{
if (xmlIsBlankNode(subcur)) {
subcur = subcur->next;
continue;
}
if (strcmp((char*)subcur->name, "position") == 0)
{
switch_pos = XMLhelper::parse_vector (doc, subcur);
}
else
std::cout << "SwitchDoorData: switch: Unhandled " <<
subcur->name << std::endl;
subcur = subcur->next;
}
}
else if (strcmp((char*)cur->name, "door") == 0)
{
xmlNodePtr subcur = cur->children;
while (subcur != NULL)
{
if (xmlIsBlankNode(subcur)) {
subcur = subcur->next;
continue;
}
if (strcmp((char*)subcur->name, "position") == 0)
{
door_pos = XMLhelper::parse_vector (doc, subcur);
}
else if (strcmp((char*)subcur->name, "height") == 0)
{
door_height = XMLhelper::parse_int (doc, subcur);
}
else
std::cout << "SwitchDoor::door: Unhandled " << subcur->name <<
std::endl;
subcur = subcur->next;
}
}
cur = cur->next;
}
}
void
SwitchDoorData::write_xml(std::ofstream* xml)
{
(*xml) << " <worldobj type=\"switchdoor\">\n";
(*xml) << " <switch>\n";
XMLhelper::write_vector_xml (xml, switch_pos);
(*xml) << " </switch>\n"
<< " <door>\n"
<< " <height>\n" << door_height << "</height>\n";
XMLhelper::write_vector_xml (xml, door_pos);
(*xml) << " </door>\n"
<< " </worldobj>\n" << std::endl;
}
/** Create an WorldObj from the given data object */
WorldObj*
SwitchDoorData::create_WorldObj ()
{
return new SwitchDoor (*this);
}
/** Create an EditorObj from the given data object */
std::list<boost::shared_ptr<EditorObj> >
SwitchDoorData::create_EditorObj ()
{
EditorObjLst lst;
EditorSwitchDoorObj* obj = new EditorSwitchDoorObj (*this);
lst.push_back(boost::shared_ptr<EditorObj> (obj));
lst.push_back(boost::shared_ptr<EditorObj> (new EditorSwitchDoorSwitchObj
(obj)));
return lst;
}
////////////////
// SwitchDoor //
////////////////
SwitchDoor::SwitchDoor (const SwitchDoorData& data)
: SwitchDoorData (data)
{
door_box = PingusResource::load_surface("switchdoor_box", "worldobjs");
door_tile = PingusResource::load_surface("switchdoor_tile", "worldobjs");
door_tile_cmap = PingusResource::load_surface("switchdoor_tile_cmap",
"worldobjs");
switch_sur = PingusResource::load_surface("switchdoor_switch", "worldobjs");
is_opening = false;
current_door_height = door_height;
}
void
SwitchDoor::draw_colmap()
{
world->get_colmap ()->put (door_box, int(door_pos.x), int(door_pos.y),
GroundpieceData::GP_SOLID);
for (int i=0; i < door_height; i++)
world->get_colmap ()->put (door_tile_cmap,
int(door_pos.x) + 1,
int(door_pos.y) + i * door_tile.get_height () +
door_box.get_height (),
GroundpieceData::GP_SOLID);
}
void
SwitchDoor::draw_offset(int x_of, int y_of, float /*s*/)
{
door_box.put_screen (int(door_pos.x) + x_of, int(door_pos.y) + y_of);
for (int i=0; i < current_door_height; i++)
door_tile.put_screen (int(door_pos.x) + x_of + 1,
int(door_pos.y) + y_of
+ i * door_tile.get_height ()
+ door_box.get_height ());
switch_sur.put_screen (int(switch_pos.x) + x_of, int(switch_pos.y) + y_of);
}
void
SwitchDoor::update(float /*delta*/)
{
if (current_door_height > 0)
{
if (!is_opening)
{
// Check if a pingu is passing the switch
PinguHolder* holder = world->get_pingu_p();
for (PinguIter pingu = holder->begin (); pingu != holder->end ();
pingu++)
{
if ((*pingu)->get_x() > switch_pos.x
&& (*pingu)->get_x() < switch_pos.x + (int)
switch_sur.get_width ()
&& (*pingu)->get_y() > switch_pos.y
&& (*pingu)->get_y() < switch_pos.y + (int)
switch_sur.get_height ())
{
is_opening = true;
}
}
}
else
{
// Open the door
current_door_height -= 1;
// If the door is opend enough, so that a pingus fits under
// it, we remove the door from the colmap
if (current_door_height + 10 < door_height)
{
world->get_colmap ()->put (door_box, int(door_pos.x),
int(door_pos.y), GroundpieceData::GP_NOTHING);
for (int i=0; i < door_height; i++)
world->get_colmap ()->put (door_tile_cmap,
int(door_pos.x) + 1,
int(door_pos.y) + i *
door_tile.get_height () + door_box.get_height (),
GroundpieceData::GP_NOTHING);
}
}
}
}
///////////////////////////////
// EditorSwitchDoorSwitchObj //
///////////////////////////////
EditorSwitchDoorSwitchObj::EditorSwitchDoorSwitchObj (EditorSwitchDoorObj* data)
: SpriteEditorObj ("switchdoor_switch", "worldobjs", data->switch_pos),
door (data)
{
}
std::string
EditorSwitchDoorSwitchObj::status_line()
{
return "--- EditorSwitchDoorSwitchObj ---";
}
boost::shared_ptr<EditorObj>
EditorSwitchDoorSwitchObj::duplicate()
{
return door->duplicate ();
}
/////////////////////////
// EditorSwitchDoorObj //
/////////////////////////
EditorSwitchDoorObj::EditorSwitchDoorObj (const SwitchDoorData& data)
: SwitchDoorData (data)
{
door_box = PingusResource::load_surface("switchdoor_box", "worldobjs");
door_tile = PingusResource::load_surface("switchdoor_tile", "worldobjs");
}
boost::shared_ptr<EditorObj>
EditorSwitchDoorObj::duplicate()
{
std::cout << "EditorSwitchDoorObj::duplicate(): not implemented" << std::endl;
return boost::shared_ptr<EditorObj> ();
}
/** Create this object (and child objects) with resonable defaults
for the editor */
std::list<boost::shared_ptr<EditorObj> >
EditorSwitchDoorObj::create (const CL_Vector& pos)
{
SwitchDoorData data;
data.door_pos = pos;
data.switch_pos = pos;
data.door_height = 15;
return data.create_EditorObj ();
}
void
EditorSwitchDoorObj::save_xml (std::ofstream* xml)
{
write_xml (xml);
}
std::string
EditorSwitchDoorObj::status_line()
{
char str[1024];
sprintf (str, "SwitchDoor - (%f %f %f)",
door_pos.x, door_pos.y, door_pos.z);
return str;
}
void
EditorSwitchDoorObj::draw (EditorView * view)
{
view->draw_line (door_pos, switch_pos, 1.0, 0.0, 0.0);
view->draw (door_box, int(door_pos.x), int(door_pos.y));
for (int i = 0; i < door_height; i++)
{
view->draw (door_tile,
int(door_pos.x + 1),
int(door_pos.y + (i * door_tile.get_height ())
+ door_box.get_height ()));
}
}
void
EditorSwitchDoorObj::make_larger ()
{
door_height += 1;
}
void
EditorSwitchDoorObj::make_smaller ()
{
if (door_height > 1)
door_height -= 1;
}
void
EditorSwitchDoorObj::set_position_offset(const CL_Vector& offset)
{
door_pos += offset;
}
/* EOF */
--- NEW FILE: switch_door.hxx ---
// $Id: switch_door.hxx,v 1.1 2002/06/12 19:03:10 grumbel Exp $
//
// Pingus - A free Lemmings clone
// Copyright (C) 2000 Ingo Ruhnke <address@hidden>
//
// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SWITCHDOOR_HH
#define SWITCHDOOR_HH
#include "../worldobj.hxx"
#include "../worldobj_data.hxx"
#include "../editor/sprite_editorobj.hxx"
class _xmlDoc; typedef _xmlDoc* xmlDocPtr;
class _xmlNode; typedef _xmlNode* xmlNodePtr;
/** A variable height door which can block the way and which can be
opened by a switch */
class SwitchDoorData : public WorldObjData
{
private:
public:
/// The upper/middle pos of the door
CL_Vector door_pos;
/// The bottom/middle pos of the switch
CL_Vector switch_pos;
// The height of the door in graphic tiles
int door_height;
SwitchDoorData ();
SwitchDoorData (xmlDocPtr doc, xmlNodePtr cur);
/** Write the content of this object formatted as xml to the given
stream */
void write_xml(std::ofstream* xml);
/** Create an WorldObj from the given data object */
WorldObj* create_WorldObj ();
/** Create an EditorObj from the given data object */
std::list<boost::shared_ptr<EditorObj> > create_EditorObj ();
};
/** A door and a switch, if a pingu is passing the switch, the door
will open. */
class SwitchDoor : public SwitchDoorData,
public WorldObj
{
private:
CL_Surface door_box;
CL_Surface door_tile;
CL_Surface door_tile_cmap;
CL_Surface switch_sur;
/** True if the door is opening */
bool is_opening;
/** The current height of the door, it might decrease when the door
is opening, it will be zero when the door is fully opened */
int current_door_height;
public:
SwitchDoor (const SwitchDoorData&);
void draw_colmap();
void draw_offset(int x, int y, float s = 1.0);
void update(float delta);
/// The switch and the door should stay above the pingus
float get_z_pos() const { return 100; }
};
class EditorSwitchDoorObj;
/** A dummy object to represent the switch for a switchdoor, all real
work is done inside EditorSwitchDoorObj */
class EditorSwitchDoorSwitchObj : public SpriteEditorObj
{
private:
EditorSwitchDoorObj* door;
public:
EditorSwitchDoorSwitchObj (EditorSwitchDoorObj* data);
boost::shared_ptr<EditorObj> duplicate();
void write_xml (std::ofstream* /*xml*/) {}
std::string status_line();
};
class EditorSwitchDoorObj : public SwitchDoorData,
public RectEditorObj
{
private:
CL_Surface door_box;
CL_Surface door_tile;
public:
friend class EditorSwitchDoorSwitchObj;
EditorSwitchDoorObj (const SwitchDoorData&);
/** Create this object (and child objects) with reasonable defaults
for the editor */
static std::list<boost::shared_ptr<EditorObj> > create (const CL_Vector& pos);
boost::shared_ptr<EditorObj> duplicate();
float get_z_pos() { return door_pos.z; }
int get_width() { return door_box.get_width (); }
int get_height() { return door_box.get_height (); }
void make_larger ();
void make_smaller ();
void write_xml (std::ofstream* xml) { SwitchDoorData::write_xml (xml); }
CL_Vector get_upper_left_corner() { return door_pos; }
void set_position_offset(const CL_Vector &);
void draw (EditorView * view);
void save_xml (std::ofstream* xml);
std::string status_line();
};
#endif
/* EOF */
--- NEW FILE: teleporter.cxx ---
// $Id: teleporter.cxx,v 1.1 2002/06/12 19:03:10 grumbel Exp $
//
// Pingus - A free Lemmings clone
// Copyright (C) 2000 Ingo Ruhnke <address@hidden>
//
// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <fstream>
#include "../world.hxx"
#include "../pingus_resource.hxx"
#include "../pingu_holder.hxx"
#include "../xml_helper.hxx"
#include "../editor/editor_view.hxx"
#include "teleporter.hxx"
#include "../pingu.hxx"
TeleporterData::TeleporterData (const TeleporterData& data) : WorldObjData(data)
{
pos = data.pos;
target_pos = data.target_pos;
}
void
TeleporterData::write_xml(std::ofstream* xml)
{
(*xml) << " <worldobj type=\"teleporter\">";
XMLhelper::write_vector_xml (xml, pos);
(*xml) << " <target>" << std::endl;
XMLhelper::write_vector_xml (xml, target_pos);
(*xml) << " </target>" << std::endl;
(*xml) << " </worldobj>" << std::endl;
}
TeleporterData::TeleporterData (xmlDocPtr doc, xmlNodePtr cur)
{
cur = cur->children;
while (cur != NULL)
{
if (xmlIsBlankNode(cur))
{
cur = cur->next;
continue;
}
if (strcmp((char*)cur->name, "position") == 0)
{
pos = XMLhelper::parse_vector (doc, cur);
}
else if (strcmp((char*)cur->name, "target") == 0)
{
xmlNodePtr ncur = cur->children;
if (xmlIsBlankNode(ncur)) ncur = ncur->next;
if (ncur != NULL)
target_pos = XMLhelper::parse_vector (doc, ncur);
else
std::cout << "TeleporterData::create (): <target> is empty" <<
std::endl;
}
else
{
std::cout << "TeleportData::create (): Unhandled " << cur->name <<
std::endl;
}
cur = cur->next;
}
}
WorldObj*
TeleporterData::create_WorldObj ()
{
return new Teleporter (*this);
}
std::list<boost::shared_ptr<EditorObj> >
TeleporterData::create_EditorObj ()
{
std::cout << "TeleportData::create_EditorObj () " << std::endl;
std::list<boost::shared_ptr<EditorObj> > objs;
EditorTeleporterObj* teleporter = new EditorTeleporterObj (*this);
EditorTeleporterTargetObj* teleporter_target = new EditorTeleporterTargetObj
(teleporter);
objs.push_back (boost::shared_ptr<EditorObj> (teleporter));
objs.push_back (boost::shared_ptr<EditorObj> (teleporter_target));
std::cout << "TeleportData::create_EditorObj (): done" << std::endl;
return objs;
}
/**************/
/* Teleporter */
/**************/
Teleporter::Teleporter (const TeleporterData& data)
: sprite ("teleporter", "worldobjs", 20.0f, Sprite::NONE, Sprite::ONCE),
target_sprite ("teleportertarget", "worldobjs", 20.0f, Sprite::NONE,
Sprite::ONCE)
{
sprite.set_align_center_bottom ();
target_sprite.set_align_center ();
//FIXME: we need a Sprite::set_frame()
pos = data.pos;
target_pos = data.target_pos;
std::cout << "Teleporter: pos: " << pos.x << " " << pos.y << " " << pos.z <<
std::endl;
}
void
Teleporter::draw_offset (int x_of, int y_of, float /*s*/)
{
//std::cout << "Teleporter::draw_offset ()" << std::endl;
//view->draw (sur, pos);
sprite.put_screen (pos + CL_Vector(x_of, y_of));
target_sprite.put_screen (target_pos + CL_Vector(x_of, y_of));
}
void
Teleporter::update (float delta)
{
sprite.update (delta);
target_sprite.update (delta);
PinguHolder* holder = world->get_pingu_p();
for (PinguIter pingu = holder->begin (); pingu != holder->end (); pingu++)
{
if ((*pingu)->get_x() > pos.x - 3 && (*pingu)->get_x() < pos.x + 3
&& (*pingu)->get_y() < pos.y && (*pingu)->get_y() > pos.y - 52)
{
(*pingu)->set_pos (int(target_pos.x), int(target_pos.y));
sprite.reset ();
target_sprite.reset ();
}
}
}
/********************/
/* EditorTeleporter */
/********************/
EditorTeleporterObj::EditorTeleporterObj (const TeleporterData& data)
: SpriteEditorObj ("teleporter", "worldobjs", pos)
{
sprite.set_align_center_bottom ();
pos = data.pos;
target_pos = data.target_pos;
}
boost::shared_ptr<EditorObj>
EditorTeleporterObj::duplicate()
{
std::cout << "EditorTeleporterObj::duplicate(): not implemented" << std::endl;
return boost::shared_ptr<EditorObj> ();
}
std::list<boost::shared_ptr<EditorObj> >
EditorTeleporterObj::create (const TeleporterData& data)
{
std::list<boost::shared_ptr<EditorObj> > objs;
EditorTeleporterObj* teleporter=new EditorTeleporterObj (data);
EditorTeleporterTargetObj* teleporter_target=new EditorTeleporterTargetObj
(teleporter);
objs.push_back (boost::shared_ptr<EditorObj>(teleporter));
objs.push_back (boost::shared_ptr<EditorObj>(teleporter_target));
return objs;
}
std::list<boost::shared_ptr<EditorObj> >
EditorTeleporterObj::create (const CL_Vector& pos)
{
TeleporterData data;
std::cout << "EditorTeleporterObj: creating..." << std::endl;
data.pos = pos;
data.target_pos.x = pos.x + 50;
data.target_pos.y = pos.y + 50;
return data.create_EditorObj ();
}
void
EditorTeleporterObj::draw (EditorView * view)
{
//std::cout << "Drawing line" << std::endl;
view->draw_line (int(pos.x),
int(pos.y),
int(target_pos.x),
int(target_pos.y),
0.0, 1.0, 0.0, 0.5);
SpriteEditorObj::draw (view);
}
void
EditorTeleporterObj::save_xml (std::ofstream* xml)
{
// Before we write down the xml stuff, we need to get the positions
// of the objects
// TeleporterData::target_pos = target->get_position ();
this->write_xml (xml);
}
std::string
EditorTeleporterObj::status_line()
{
// FIXME: replace with string streams
char str[1024];
sprintf (str, "Teleporter - %f %f %f",
pos.x, pos.y, pos.z);
return str;
}
/*****************************/
/* EditorTeleporterTargetObj */
/*****************************/
EditorTeleporterTargetObj::EditorTeleporterTargetObj (EditorTeleporterObj*
arg_teleporter)
: SpriteEditorObj ("teleporter2", "worldobjs",
arg_teleporter->get_target_pos_ref ()),
teleporter (arg_teleporter)
{
sprite.set_align_center();
}
std::string
EditorTeleporterTargetObj::status_line()
{
char str[1024];
sprintf (str, "TeleporterTarget - %f %f %f",
pos_ref.x, pos_ref.y, pos_ref.z);
return str;
}
/* EOF */
--- NEW FILE: teleporter.hxx ---
// $Id: teleporter.hxx,v 1.1 2002/06/12 19:03:10 grumbel Exp $
//
// Pingus - A free Lemmings clone
// Copyright (C) 2000 Ingo Ruhnke <address@hidden>
//
// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef TELEPORTER_HH
#define TELEPORTER_HH
#include "../worldobj.hxx"
#include "../worldobj_data.hxx"
#include "../editor/sprite_editorobj.hxx"
#include "../boost/smart_ptr.hpp"
class EditorTeleporterObj;
class _xmlDoc; typedef _xmlDoc* xmlDocPtr;
class _xmlNode; typedef _xmlNode* xmlNodePtr;
namespace boost {
template <class T> class shared_ptr;
}
class TeleporterData : public WorldObjData
{
public:
CL_Vector pos;
CL_Vector target_pos;
TeleporterData () {}
TeleporterData (xmlDocPtr doc, xmlNodePtr cur);
TeleporterData (const TeleporterData& data);
/** Write the content of this object formatted as xml to the given
stream */
void write_xml(std::ofstream* xml);
/** Create an WorldObj from the given data object */
WorldObj* create_WorldObj ();
/** Create an EditorObj from the given data object */
std::list<boost::shared_ptr<EditorObj> > create_EditorObj ();
};
class Teleporter : private TeleporterData,
public WorldObj
{
private:
Sprite sprite;
Sprite target_sprite;
public:
Teleporter (const TeleporterData& data);
int get_z_pos() { return 0; }
void draw_offset (int x, int y, float s = 1.0);
void update(float delta);
float get_z_pos() const { return (int) pos.z; }
};
class EditorTeleporterTargetObj;
class EditorTeleporterObj : public SpriteEditorObj,
public TeleporterData
{
private:
EditorTeleporterTargetObj* target;
public:
EditorTeleporterObj (const TeleporterData& data);
CL_Vector& get_target_pos_ref () { return target_pos; }
boost::shared_ptr<EditorObj> duplicate();
static std::list<boost::shared_ptr<EditorObj> > create (const TeleporterData&
data);
void write_xml(std::ofstream* xml) { TeleporterData::write_xml(xml); }
/** Create this object (and child objects) with reasonable defaults
for the editor */
static std::list<boost::shared_ptr<EditorObj> > create (const CL_Vector& pos);
void draw (EditorView * view);
void save_xml (std::ofstream* xml);
std::string status_line();
};
/** A pseudo object to represent the teleporter target; all the
data itself is handled inside the EditorTeleporterObj, but we
need this helper object to be able to show and move the
teleporter target inside the editor */
class EditorTeleporterTargetObj : public SpriteEditorObj
{
private:
EditorTeleporterObj* teleporter;
public:
/// Basic constructor
EditorTeleporterTargetObj (EditorTeleporterObj* obj);
virtual ~EditorTeleporterTargetObj () {}
boost::shared_ptr<EditorObj> duplicate() { return teleporter->duplicate (); }
/// The saving will be done in EditorTeleporterObj::save_xml
void write_xml (std::ofstream* /*xml*/) {}
std::string status_line();
};
#endif
/* EOF */
Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldobjs/Makefile.am,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Makefile.am 30 Nov 2001 20:22:21 -0000 1.5
+++ Makefile.am 12 Jun 2002 19:03:10 -0000 1.6
@@ -20,10 +20,10 @@
noinst_LIBRARIES = libpingus_worldobjs.a
libpingus_worldobjs_a_SOURCES = \
- Teleporter.cc Teleporter.hh \
- IceBlock.cc IceBlock.hh \
- ConveyorBelt.cc ConveyorBelt.hh \
- SwitchDoor.cc SwitchDoor.hh \
- InfoBox.cc InfoBox.hh
+ teleporter.cxx teleporter.hxx \
+ ice_block.cxx ice_block.hxx \
+ conveyor_belt.cxx conveyor_belt.hxx \
+ switch_door.cxx switch_door.hxx \
+ info_box.cxx info_box.hxx
## EOF ##
--- ConveyorBelt.hh DELETED ---
--- IceBlock.hh DELETED ---
--- InfoBox.hh DELETED ---
--- SwitchDoor.hh DELETED ---
--- Teleporter.cc DELETED ---
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src/worldobjs conveyor_belt.cxx,NONE,1.1 conveyor_belt.hxx,NONE,1.1 ice_block.cxx,NONE,1.1 ice_block.hxx,NONE,1.1 info_box.cxx,NONE,1.1 info_box.hxx,NONE,1.1 switch_door.cxx,NONE,1.1 switch_door.hxx,NONE,1.1 teleporter.cxx,NONE,1.1 teleporter.hxx,NONE,1.1 Makefile.am,1.5,1.6 ConveyorBelt.hh,1.23,NONE IceBlock.hh,1.24,NONE InfoBox.hh,1.8,NONE SwitchDoor.hh,1.24,NONE Teleporter.cc,1.40,NONE,
grumbel <=
- Prev by Date:
[Pingus-CVS] CVS: Games/Pingus/src/entrances cloud.cxx,NONE,1.1 cloud.hxx,NONE,1.1 woodthing.cxx,NONE,1.1 woodthing.hxx,NONE,1.1 Makefile.am,1.3,1.4 Cloud.cc,1.12,NONE Cloud.hh,1.8,NONE WoodThing.cc,1.15,NONE WoodThing.hh,1.8,NONE
- Next by Date:
[Pingus-CVS] CVS: Games/Pingus/src/worldmap graph.cxx,NONE,1.1 graph.hxx,NONE,1.1 manager.cxx,NONE,1.1 manager.hxx,NONE,1.1 node.cxx,NONE,1.1 node.hxx,NONE,1.1 node_data.cxx,NONE,1.1 node_data.hxx,NONE,1.1 pingus.cxx,NONE,1.1 pingus.hxx,NONE,1.1 stat.cxx,NONE,1.1 stat.hxx,NONE,1.1 worldmap.cxx,NONE,1.1 worldmap.hxx,NONE,1.1 Makefile.am,1.3,1.4 PingusWorldMap.cc,1.41,NONE PingusWorldMap.hh,1.28,NONE PingusWorldMapGraph.cc,1.34,NONE PingusWorldMapGraph.hh,1.24,NONE PingusWorldMapManager.cc,1.25,NONE PingusWorldMapManager.hh,1.11,NONE PingusWorldMapNode.cc,1.6,NONE PingusWorldMapNode.hh,1.5,NONE PingusWorldMapNodeData.cc,1.5,NONE PingusWorldMapNodeData.hh,1.5,NONE PingusWorldMapPingus.cc,1.16,NONE PingusWorldMapPingus.hh,1.14,NONE PingusWorldMapStat.cc,1.8,NONE PingusWorldMapStat.hh,1.8,NONE
- Previous by thread:
[Pingus-CVS] CVS: Games/Pingus/src/entrances cloud.cxx,NONE,1.1 cloud.hxx,NONE,1.1 woodthing.cxx,NONE,1.1 woodthing.hxx,NONE,1.1 Makefile.am,1.3,1.4 Cloud.cc,1.12,NONE Cloud.hh,1.8,NONE WoodThing.cc,1.15,NONE WoodThing.hh,1.8,NONE
- Next by thread:
[Pingus-CVS] CVS: Games/Pingus/src/worldmap graph.cxx,NONE,1.1 graph.hxx,NONE,1.1 manager.cxx,NONE,1.1 manager.hxx,NONE,1.1 node.cxx,NONE,1.1 node.hxx,NONE,1.1 node_data.cxx,NONE,1.1 node_data.hxx,NONE,1.1 pingus.cxx,NONE,1.1 pingus.hxx,NONE,1.1 stat.cxx,NONE,1.1 stat.hxx,NONE,1.1 worldmap.cxx,NONE,1.1 worldmap.hxx,NONE,1.1 Makefile.am,1.3,1.4 PingusWorldMap.cc,1.41,NONE PingusWorldMap.hh,1.28,NONE PingusWorldMapGraph.cc,1.34,NONE PingusWorldMapGraph.hh,1.24,NONE PingusWorldMapManager.cc,1.25,NONE PingusWorldMapManager.hh,1.11,NONE PingusWorldMapNode.cc,1.6,NONE PingusWorldMapNode.hh,1.5,NONE PingusWorldMapNodeData.cc,1.5,NONE PingusWorldMapNodeData.hh,1.5,NONE PingusWorldMapPingus.cc,1.16,NONE PingusWorldMapPingus.hh,1.14,NONE PingusWorldMapStat.cc,1.8,NONE PingusWorldMapStat.hh,1.8,NONE
- Index(es):