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 liquid_obj.cxx,NONE,1.1 li


From: torangan
Subject: [Pingus-CVS] CVS: Games/Pingus/src/editorobjs liquid_obj.cxx,NONE,1.1 liquid_obj.hxx,NONE,1.1 Makefile.am,1.10,1.11
Date: 25 Sep 2002 17:21:41 -0000

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

Modified Files:
        Makefile.am 
Added Files:
        liquid_obj.cxx liquid_obj.hxx 
Log Message:
splitted Liquid


--- NEW FILE: liquid_obj.cxx ---
//  $Id: liquid_obj.cxx,v 1.1 2002/09/25 17:21:38 torangan Exp $
//
//  Pingus - A free Lemmings clone
//  Copyright (C) 1999 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 "../worldobjsdata/liquid_data.hxx"
#include "../editor/editor_view.hxx"
#include "liquid_obj.hxx"

namespace EditorObjs {

LiquidObj::LiquidObj (WorldObjsData::LiquidData* data_)
  : SpriteEditorObj(data_->desc.res_name, data_->desc.datafile),
    data(new WorldObjsData::LiquidData(*data_))
{
  if (data->old_width_handling)
    {
      data->width = (data->width + sprite.get_width()) / sprite.get_width();
      data->old_width_handling = false;
    }

  pos_ref = &data->pos;
}

LiquidObj::~LiquidObj ()
{
  delete data;
}

EditorObj*
LiquidObj::duplicate ()
{
  return new LiquidObj(data);
}

void
LiquidObj::draw (EditorNS::EditorView* view)
{
  for (int i = 0; i < data->width; ++i)
    view->draw(sprite, data->pos + CL_Vector(i * sprite.get_width(), 0));
}

void
LiquidObj::draw_mark (EditorNS::EditorView* view) 
{
  view->draw_rect(static_cast<int>(data->pos.x),
                  static_cast<int>(data->pos.y),
                  static_cast<int>(data->pos.x + sprite.get_width () * 
data->width),
                  static_cast<int>(data->pos.y + sprite.get_height()),
                  1.0, 1.0, 1.0, 0.0);
}

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

std::string  
LiquidObj::status_line ()
{
  char str[32];
  snprintf(str, 32, "%4.2f:%4.2f:%3.2f:%2d",
           data->pos.x, data->pos.y, data->pos.z, data->speed);
  return str;
}

int
LiquidObj::get_width ()
{
  return sprite.get_width() * data->width;
}

void 
LiquidObj::make_larger ()
{
  ++data->width;
}

void 
LiquidObj::make_smaller ()
{
  if (data->width > 1)
    --data->width;
}

} // namespace EditorObjs

/* EOF */

--- NEW FILE: liquid_obj.hxx ---
//  $Id: liquid_obj.hxx,v 1.1 2002/09/25 17:21:38 torangan Exp $
//
//  Pingus - A free Lemmings clone
//  Copyright (C) 1999 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_LIQUID_OBJ_HXX
#define HEADER_PINGUS_EDITOROBJS_LIQUID_OBJ_HXX

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

namespace WorldObjsData {
class LiquidData;
}

namespace EditorObjs {

class LiquidObj : public SpriteEditorObj
{
private:
  WorldObjsData::LiquidData* const data;
  
public:
  LiquidObj (WorldObjsData::LiquidData* data_);
 ~LiquidObj ();

  EditorObj* duplicate ();
  
  void draw      (EditorNS::EditorView * view);
  void draw_mark (EditorNS::EditorView * view);
  
  void write_xml (std::ostream& xml);
  
  std::string status_line ();

  int get_width ();

  void make_larger  ();
  void make_smaller ();
  
private:
  LiquidObj (const LiquidObj&);
  LiquidObj operator= (const LiquidObj&);
};

} // namespace EditorObjs

#endif

/* EOF */

Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editorobjs/Makefile.am,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- Makefile.am 21 Sep 2002 16:52:40 -0000      1.10
+++ Makefile.am 25 Sep 2002 17:21:38 -0000      1.11
@@ -27,6 +27,7 @@
        ice_block_obj.cxx               ice_block_obj.hxx \
        info_box_obj.cxx                info_box_obj.hxx \
        laser_exit_obj.cxx              laser_exit_obj.hxx \
+       liquid_obj.cxx                  liquid_obj.hxx \
         prefab_obj.hxx                  prefab_obj.cxx \
        smasher_obj.cxx                 smasher_obj.hxx \
        solid_color_background_obj.cxx  solid_color_background_obj.hxx \





reply via email to

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