pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] CVS: Games/Pingus/src/editorobjs switch_door_obj.cxx,NONE,1


From: torangan
Subject: [Pingus-CVS] CVS: Games/Pingus/src/editorobjs switch_door_obj.cxx,NONE,1.1 switch_door_obj.hxx,NONE,1.1 switch_door_switch_obj.cxx,NONE,1.1 switch_door_switch_obj.hxx,NONE,1.1 Makefile.am,1.2,1.3
Date: 11 Sep 2002 15:27:22 -0000

Update of /usr/local/cvsroot/Games/Pingus/src/editorobjs
In directory dark:/tmp/cvs-serv15619/editorobjs

Modified Files:
        Makefile.am 
Added Files:
        switch_door_obj.cxx switch_door_obj.hxx 
        switch_door_switch_obj.cxx switch_door_switch_obj.hxx 
Log Message:
splitted SwitchDoor


--- NEW FILE: switch_door_obj.cxx ---
//  $Id: switch_door_obj.cxx,v 1.1 2002/09/11 15:27:19 torangan 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 "switch_door_obj.hxx"
#include "../editor/editor_view.hxx"
#include "../worldobjsdata/switch_door_data.hxx"

namespace EditorObjs { 

SwitchDoorObj::SwitchDoorObj (WorldObjsData::SwitchDoorData* data_)
                            : data(new WorldObjsData::SwitchDoorData(*data_))
{
}

EditorObj*
SwitchDoorObj::duplicate ()
{
  std::cout << "SwitchDoorObj::duplicate(): not implemented" << std::endl;
  return 0;
}

float
SwitchDoorObj::get_z_pos () {
  return data->door_pos.z;
}

int
SwitchDoorObj::get_width ()
{
  return data->door_box.get_width();
}

int
SwitchDoorObj::get_height ()
{
  return data->door_box.get_height();
}

/** Create this object (and child objects) with resonable defaults
    for the editor */
EditorObjLst
SwitchDoorObj::create (const CL_Vector& pos)
{
  WorldObjsData::SwitchDoorData newdata;

  newdata.door_pos    = pos;
  newdata.switch_pos  = pos;
  newdata.door_height = 15;

  return newdata.create_EditorObj();
}

void
SwitchDoorObj::save_xml (std::ostream& xml)
{
  write_xml (xml);
}

std::string 
SwitchDoorObj::status_line()
{
  char str[128];
  snprintf(str, 128, "SwitchDoor - (%f %f %f)", 
          data->door_pos.x, data->door_pos.y, data->door_pos.z);
  return str;
}

void
SwitchDoorObj::draw (EditorNS::EditorView * view)
{
  view->draw_line(data->door_pos, data->switch_pos, 1.0, 0.0, 0.0);

  view->draw(data->door_box, 
             static_cast<int>(data->door_pos.x),
             static_cast<int>(data->door_pos.y));

  for (int i = 0; i < data->door_height; ++i)
    {
      view->draw(data->door_tile, 
                 static_cast<int>(data->door_pos.x), 
                 static_cast<int>(data->door_pos.y + (i * 
data->door_tile.get_height())
                                                   + 
data->door_box.get_height()));
    }
}

void
SwitchDoorObj::make_larger ()
{
  data->door_height += 1;
}

void 
SwitchDoorObj::make_smaller ()
{
  if (data->door_height > 1)
    --data->door_height;
}

void
SwitchDoorObj::write_xml (std::ostream& xml)
{
  data->write_xml(xml);
}

CL_Vector
SwitchDoorObj::get_upper_left_corner ()
{
  return data->door_pos;
}

void 
SwitchDoorObj::set_position_offset (const CL_Vector& offset)
{
  data->door_pos += offset;
}

} // namespace EditorObjs

/* EOF */

--- NEW FILE: switch_door_obj.hxx ---
//  $Id: switch_door_obj.hxx,v 1.1 2002/09/11 15:27:19 torangan 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 HEADER_PINGUS_EDITOROBJS_SWITCH_DOOR_OBJ_HXX
#define HEADER_PINGUS_EDITOROBJS_SWITCH_DOOR_OBJ_HXX

#include "switch_door_switch_obj.hxx"

namespace WorldObjsData {
class SwitchDoorData;
} // namespace WorldObjsData

namespace EditorObjs {

class SwitchDoorObj : public RectEditorObj
{
private:
  WorldObjsData::SwitchDoorData* const data;
  
public:
  friend class SwitchDoorSwitchObj;
  
  SwitchDoorObj (WorldObjsData::SwitchDoorData* data_);
  
  /** Create this object (and child objects) with reasonable defaults
      for the editor */
  static EditorObjLst create (const CL_Vector& pos);

  EditorObj* duplicate();
  float get_z_pos ();

  int get_width  ();
  int get_height ();

  void make_larger ();
  void make_smaller ();
  void write_xml (std::ostream& xml);
  CL_Vector get_upper_left_corner ();

  void set_position_offset(const CL_Vector &);

  void draw (EditorNS::EditorView* view);
  void save_xml (std::ostream& xml);
  std::string status_line ();
  
private:
  SwitchDoorObj (const SwitchDoorObj&);
  SwitchDoorObj operator= (const SwitchDoorObj&);
};

} // namespace EditorObjs

#endif

/* EOF */

--- NEW FILE: switch_door_switch_obj.cxx ---
//  $Id: switch_door_switch_obj.cxx,v 1.1 2002/09/11 15:27:19 torangan 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 "switch_door_obj.hxx"
#include "../worldobjsdata/switch_door_data.hxx"

namespace EditorObjs { 

SwitchDoorSwitchObj::SwitchDoorSwitchObj (SwitchDoorObj* data)
                                        : SpriteEditorObj ("switchdoor_switch", 
"worldobjs"),
                                          door (data)
{
  pos_ref = &door->data->switch_pos;
}

std::string 
SwitchDoorSwitchObj::status_line ()
{
  return "--- SwitchDoorSwitchObj ---";
}

EditorObj*
SwitchDoorSwitchObj::duplicate ()
{ 
  return door->duplicate (); 
}

} // namespace EditorObjs

/* EOF */

--- NEW FILE: switch_door_switch_obj.hxx ---
//  $Id: switch_door_switch_obj.hxx,v 1.1 2002/09/11 15:27:19 torangan 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 HEADER_PINGUS_EDITOROBJS_SWITCH_DOOR_SWITCH_OBJ_HXX
#define HEADER_PINGUS_EDITOROBJS_SWITCH_DOOR_SWITCH_OBJ_HXX

#include "../editor/sprite_editorobj.hxx"

namespace EditorObjs {

class SwitchDoorObj;

/** A dummy object to represent the switch for a switchdoor, all real
    work is done inside EditorSwitchDoorObj */
class SwitchDoorSwitchObj : public SpriteEditorObj
{
private:
  SwitchDoorObj* door;
  
public:
  SwitchDoorSwitchObj (SwitchDoorObj* data);
  
  EditorObj* duplicate ();

  void write_xml (std::ostream&) {}
  std::string status_line ();
  
private:
  SwitchDoorSwitchObj (const SwitchDoorSwitchObj&);
  SwitchDoorSwitchObj operator= (const SwitchDoorSwitchObj&);
};

} // namespace EditorObjs

#endif

/* EOF */

Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editorobjs/Makefile.am,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Makefile.am 9 Sep 2002 16:13:44 -0000       1.2
+++ Makefile.am 11 Sep 2002 15:27:19 -0000      1.3
@@ -18,14 +18,16 @@
 noinst_LIBRARIES = libpingus_editorobjs.a
 
 libpingus_editorobjs_a_SOURCES = \
-       bumper_obj.cxx            bumper_obj.hxx \
-       fake_exit_obj.cxx         fake_exit_obj.hxx \
-       guillotine_obj.cxx        guillotine_obj.hxx \
-       hammer_obj.cxx            hammer_obj.hxx \
-       laser_exit_obj.cxx        laser_exit_obj.hxx \
-       smasher_obj.cxx           smasher_obj.hxx \
-       spike_obj.cxx             spike_obj.hxx \
-       teleporter_obj.cxx        teleporter_obj.hxx \
-       teleporter_target_obj.cxx teleporter_target_obj.cxx
+       bumper_obj.cxx             bumper_obj.hxx \
+       fake_exit_obj.cxx          fake_exit_obj.hxx \
+       guillotine_obj.cxx         guillotine_obj.hxx \
+       hammer_obj.cxx             hammer_obj.hxx \
+       laser_exit_obj.cxx         laser_exit_obj.hxx \
+       smasher_obj.cxx            smasher_obj.hxx \
+       spike_obj.cxx              spike_obj.hxx \
+       switch_door_obj.cxx        switch_door_obj.hxx \
+        switch_door_switch_obj.cxx switch_door_switch_obj.hxx \
+       teleporter_obj.cxx         teleporter_obj.hxx \
+       teleporter_target_obj.cxx  teleporter_target_obj.cxx
 
 # EOF #





reply via email to

[Prev in Thread] Current Thread [Next in Thread]