pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] CVS: Games/Pingus/src display_graphic_context.cxx,NONE,1.1


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src display_graphic_context.cxx,NONE,1.1 display_graphic_context.hxx,NONE,1.1 graphic_context.hxx,NONE,1.1 Makefile.am,1.92,1.93 console.hxx,1.8,1.9 playfield_view.hxx,1.3,1.4 view.cxx,1.7,1.8 view.hxx,1.6,1.7 world.cxx,1.19,1.20 world.hxx,1.8,1.9 worldobj.cxx,1.4,1.5 worldobj.hxx,1.5,1.6
Date: 4 Sep 2002 17:49:50 -0000

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

Modified Files:
        Makefile.am console.hxx playfield_view.hxx view.cxx view.hxx 
        world.cxx world.hxx worldobj.cxx worldobj.hxx 
Added Files:
        display_graphic_context.cxx display_graphic_context.hxx 
        graphic_context.hxx 
Log Message:
- added GraphicContext (aka View)

--- NEW FILE: display_graphic_context.cxx ---
//  $Id: display_graphic_context.cxx,v 1.1 2002/09/04 17:49:48 grumbel Exp $
//
//  Pingus - A free Lemmings clone
//  Copyright (C) 2002 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 <ClanLib/Display/Display/display.h>
#include "math.hxx"
#include "sprite.hxx"
#include "display_graphic_context.hxx"

using namespace Pingus;

DisplayGraphicContext::DisplayGraphicContext (int x1, int y1, int x2, int y2, 
                                              int /*x_offset*/, int 
/*y_offset*/)
  : x1 (x1), y1 (y1), x2 (x2), y2 (y2), offset (-(x2 - x1)/2.0f, -(y2-x1)/2.0f, 
1.0f)
{
  center = CL_Vector ((x2 - x1)/2.0f + x1,
                      (y2 - y1)/2.0f + y1);
  std::cout << "View: " << x1 << ", " << y1 << ", " << x2 << ", " << y2 
  << std::endl;
}

DisplayGraphicContext::~DisplayGraphicContext ()
{
}

void
DisplayGraphicContext::set_offset (float x, float y)
{
  offset.x = x;
  offset.y = y;
}

CL_Rect
DisplayGraphicContext::get_clip_rect()
{
  assert (!"DisplayGraphicContext::get_clip_rect(): unimplemented");
  return CL_Rect ();
}

CL_Vector
DisplayGraphicContext::get_offset ()
{
  return offset;
}

float
DisplayGraphicContext::get_zoom ()
{
  return offset.z;
}

void
DisplayGraphicContext::set_zoom (float new_zoom)
{
  offset.z = new_zoom;
  //std::cout << "Zoom: " << offset.z << std::endl;
}

void 
DisplayGraphicContext::zoom_to (const CL_Rect & arg_rect)
{
  CL_Rect rect;

  rect.x1 = Math::min (arg_rect.x1, arg_rect.x2);
  rect.x2 = Math::max (arg_rect.x1, arg_rect.x2);
  rect.y1 = Math::min (arg_rect.y1, arg_rect.y2);
  rect.y2 = Math::max (arg_rect.y1, arg_rect.y2);
  
  CL_Vector pos1 = screen_to_world (CL_Vector(rect.x1, rect.y1));
  CL_Vector pos2 = screen_to_world (CL_Vector(rect.x2, rect.y2));

  CL_Vector center = (pos2 + pos1) * 0.5f;
  offset = -center;

  float width  = pos2.x - pos1.x;
  float height = pos2.y - pos1.y;

  if (width < 10 && height < 10)
    return ;

  float screen_relation = get_width () / get_height ();
  float rect_reation = width / height;
  
  if (rect_reation > screen_relation)
    {
      set_zoom (get_width () / (pos2.x - pos1.x));
    }
  else
    {
      set_zoom (get_height () / (pos2.y - pos1.y));
    }
}

int 
DisplayGraphicContext::get_width ()
{
  return x2 - x1;
}

int
DisplayGraphicContext::get_height ()
{
  return y2 - y1;
}

void 
DisplayGraphicContext::move (const CL_Vector & delta)
{
  offset += delta;
}

CL_Vector
DisplayGraphicContext::screen_to_world (CL_Vector pos)
{
  return ((pos - center) * (1.0f/offset.z)) - offset;
}

CL_Vector
DisplayGraphicContext::world_to_screen (CL_Vector pos)
{
  return ((pos + offset) * offset.z) + center;
}

float 
DisplayGraphicContext::get_x_offset ()
{
  return offset.x;
}

float 
DisplayGraphicContext::get_y_offset ()
{
  return offset.y;
}

void 
DisplayGraphicContext::draw (Sprite& sprite, const CL_Vector& pos)
{
  CL_Surface sur (sprite.get_surface ());
  draw (sur, 
        (int) pos.x + sprite.get_x_align (),
        (int) pos.y + sprite.get_y_align ());
}

void 
DisplayGraphicContext::draw (Sprite& sprite, const CL_Vector& pos, int frame)
{
  CL_Surface sur (sprite.get_surface ());
  draw (sur, 
        (int) pos.x + sprite.get_x_align (),
        (int) pos.y + sprite.get_y_align (), 
        frame);
}

void 
DisplayGraphicContext::draw (CL_Surface& sur, const CL_Vector& pos)
{
  if (offset.z == 1.0)
    {   
      sur.put_screen (int(pos.x + get_x_offset () + center.x),
                      int(pos.y + get_y_offset () + center.y));
    }
  else
    {
      sur.put_screen (int((pos.x + get_x_offset ()) * offset.z + center.x),
                      int((pos.y + get_y_offset ()) * offset.z + center.y),
                      offset.z, offset.z);
    }
  //CL_Display::draw_line (x1, y1, x2, y2, 1.0, 1.0, 0.0);
  //CL_Display::draw_line (x1, y2, x2, y1, 1.0, 1.0, 0.0);
}

void 
DisplayGraphicContext::draw (CL_Surface& sur, const CL_Vector& pos, int frame)
{
  draw (sur, int(pos.x), int(pos.y), frame);
}

void 
DisplayGraphicContext::draw (CL_Surface& sur, int x_pos, int y_pos)
{
  if (offset.z == 1.0)
    {
      sur.put_screen (int(x_pos + get_x_offset () + center.x),
                      int(y_pos + get_y_offset () + center.y));
    }
  else
    {
      sur.put_screen (int((x_pos + get_x_offset ()) * offset.z + center.x),
                      int((y_pos + get_y_offset ()) * offset.z + center.y),
                      offset.z, offset.z);
    }
}

void 
DisplayGraphicContext::draw (CL_Surface& sur, int x_pos, int y_pos, int frame)
{
  if (offset.z == 1.0)
    {
      sur.put_screen (int(x_pos + get_x_offset () + center.x),
                      int(y_pos + get_y_offset () + center.y),
                      frame);  
    }
  else
    {
      sur.put_screen (int((x_pos + get_x_offset ()) * offset.z + center.x),
                      int((y_pos + get_y_offset ()) * offset.z + center.y),
                      offset.z, offset.z,
                      frame);  
    }
}

void 
DisplayGraphicContext::draw (CL_Surface& sur, int x_pos, int y_pos, 
            float size_x, float size_y, int frame)
{
  sur.put_screen (int(x_pos + get_x_offset () + center.x),
                  int(y_pos + get_y_offset () + center.y),
                  size_x * offset.z, 
                  size_y * offset.z, frame); 
}

void 
DisplayGraphicContext::draw_line (const CL_Vector& pos1, const CL_Vector& pos2,
                       float r, float g, float b, float a)
{
  draw_line (int(pos1.x), int(pos1.y), int(pos2.x), int(pos2.y), r, g, b, a);
}

void 
DisplayGraphicContext::draw_line (int x1, int y1, int x2, int y2, 
                       float r, float g, float b, float a)
{
  CL_Display::draw_line (int((x1 + get_x_offset ()) * offset.z + center.x),
                         int((y1 + get_y_offset ()) * offset.z + center.y),
                         int((x2 + get_x_offset ()) * offset.z + center.x),
                         int((y2 + get_y_offset ()) * offset.z + center.y),
                         r, g, b, a);
}

void 
DisplayGraphicContext::draw_fillrect (int x1, int y1, int x2, int y2, 
                           float r, float g, float b, float a)
{
  CL_Display::fill_rect (int((x1 + get_x_offset ()) * offset.z + center.x),
                         int((y1 + get_y_offset ()) * offset.z + center.y), 
                         int((x2 + get_x_offset ()) * offset.z + center.x),
                         int((y2 + get_y_offset ()) * offset.z + center.y),
                         r, g, b, a);
}

void 
DisplayGraphicContext::draw_rect (int x1, int y1, int x2, int y2, 
                 float r, float g, float b, float a)
{
  CL_Display::draw_rect (int((x1 + get_x_offset ()) * offset.z + center.x),
                         int((y1 + get_y_offset ()) * offset.z + center.y), 
                         int((x2 + get_x_offset ()) * offset.z + center.x),
                         int((y2 + get_y_offset ()) * offset.z + center.y),
                         r, g, b, a);
}

void 
DisplayGraphicContext::draw_pixel (int /*x_pos*/, int /*y_pos*/, 
                   float /*r*/, float /*g*/, float /*b*/, float /*a*/)
{
  //CL_Display::put_pixel (x1 + get_x_offset (),
  //                     y1 + get_y_offset (), r, g, b, a);
  std::cout << "View::draw_pixel () not implemented" << std::endl;
}

void 
DisplayGraphicContext::draw_circle (int x_pos, int y_pos, int radius,
                                    float r, float g, float b, float a)
{
  // FIXME: Probally not the fast circle draw algo on this world...
  const float pi = 3.1415927f * 2.0f;
  const float steps = 8;
  CL_Vector current (radius, 0);
  CL_Vector next = current.rotate (pi/steps, CL_Vector (0, 0, 1.0f));

  for (int i = 0; i < steps; ++i)
    {
      draw_line (int(x_pos + current.x), int(y_pos + current.y),
                 int(x_pos + next.x), int(y_pos + next.y),
                 r, g, b, a);
      current = next;
      next = next.rotate (pi/8, CL_Vector (0, 0, 1.0f));
    }
}

/* EOF */

--- NEW FILE: display_graphic_context.hxx ---
//  $Id: display_graphic_context.hxx,v 1.1 2002/09/04 17:49:48 grumbel Exp $
// 
//  Pingus - A free Lemmings clone
//  Copyright (C) 2002 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_DISPLAY_GRAPHIC_CONTEXT_HXX
#define HEADER_DISPLAY_GRAPHIC_CONTEXT_HXX

#include <ClanLib/Core/Math/cl_vector.h>
#include <ClanLib/Core/Math/rect.h>

#include "graphic_context.hxx"

/** A GraphicContext which represents the display and allows you to
    paint on it */
class DisplayGraphicContext : public GraphicContext
{
private:
  /** Position of the display on the screen */
  int x1, y1, x2, y2;

  /** scroll offset */
  CL_Vector offset;

  /** center of the display */
  CL_Vector center;

public:
  DisplayGraphicContext (int x1, int y1, int x2, int y2, 
                         int /*x_offset*/, int /*y_offset*/);
  virtual ~DisplayGraphicContext ();
  
  CL_Vector get_offset ();

  float get_x_offset ();
  float get_y_offset ();

  void  set_offset (float x, float y);

  CL_Rect get_clip_rect();

  int   get_width ();
  int   get_height ();

  float get_zoom ();
  void  set_zoom (float new_zoom);

  /** Set the current zoom and offset, so that the given rectangle is
      completly visible on the screen and maximally zoomed. */
  void zoom_to (const CL_Rect & rect);

  /// Scroll the view by the given delta
  void move (const CL_Vector & delta);

  /** Converts a given screen coordinate, as returned by
      CL_Mouse::get_x(), into the world coordinate system. */
  CL_Vector screen_to_world (CL_Vector pos);
  CL_Vector world_to_screen (CL_Vector pos);

  void draw (Sprite& sprite, const CL_Vector& pos);
  void draw (Sprite& sprite, const CL_Vector& pos, int frame);
  void draw (CL_Surface& sur, const CL_Vector& pos);
  void draw (CL_Surface& sur, const CL_Vector& pos, int frame);

  void draw (CL_Surface& sur, int x_pos, int y_pos);
  void draw (CL_Surface& sur, int x_pos, int y_pos, int frame);

  /** Draw a scaled surface */
  void draw (CL_Surface& sur, int x_pos, int y_pos, 
             float size_x, float size_y, int frame);

  /** Draw a line */
  void draw_line (const CL_Vector& pos1, const CL_Vector& pos2,
                  float r, float g, float b, float a = 1.0f);
  /** Draw a line */
  void draw_line (int x1, int y1, int x2, int y2, 
                  float r, float g, float b, float a = 1.0f);

  /** Draw a filled rectangle (FIXME: [x1,x2] or [x1,x2[ ?) */
  void draw_fillrect (int x1, int y1, int x2, int y2, 
                      float r, float g, float b, float a = 1.0f);

  /** Draw an unfilled rectangle (FIXME: [x1,x2] or [x1,x2[ ?) */
  void draw_rect (int x1, int y1, int x2, int y2, 
                  float r, float g, float b, float a = 1.0f);

  /** Draw a singel pixel */
  void draw_pixel (int x_pos, int y_pos, 
                   float r, float g, float b, float a = 1.0f);

  /** Draw a circle */
  void draw_circle (int x_pos, int y_pos, int radius,
                    float r, float g, float b, float a = 1.0f);

private:
  DisplayGraphicContext (const DisplayGraphicContext&);
  DisplayGraphicContext operator= (const DisplayGraphicContext&);
};

#endif

/* EOF */

--- NEW FILE: graphic_context.hxx ---
//  $Id: graphic_context.hxx,v 1.1 2002/09/04 17:49:48 grumbel Exp $
// 
//  Pingus - A free Lemmings clone
//  Copyright (C) 2002 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_GRAPHIC_CONTEXT_HXX
#define HEADER_PINGUS_GRAPHIC_CONTEXT_HXX

#include <ClanLib/Core/Math/cl_vector.h>
#include <ClanLib/Core/Math/rect.h>

class Sprite;
class CL_Surface;

/** Abstract interface */
class GraphicContext
{
private:
public:
  virtual CL_Vector get_offset () =0;

  /** Return the rectandle which represents the visible part of the
      world, so that objects outsite it can be cliped away easily */
  virtual CL_Rect get_clip_rect () =0;

  virtual float get_x_offset () =0;
  virtual float get_y_offset () =0;

  virtual int   get_width ()  =0;
  virtual int   get_height () =0;

  virtual float get_zoom () =0;
  virtual void  set_zoom (float new_zoom) =0;

  /** Set the current zoom and offset, so that the given rectangle is
      completly visible on the screen and maximally zoomed. */
  virtual void zoom_to (const CL_Rect & rect) =0;

  /// Scroll the view by the given delta
  virtual void move (const CL_Vector & delta) =0;

  /** Converts a given screen coordinate, as returned by
      CL_Mouse::get_x(), into the world coordinate system. */
  virtual CL_Vector screen_to_world (CL_Vector pos) =0;
  virtual CL_Vector world_to_screen (CL_Vector pos) =0;

  virtual void draw (Sprite& sprite, const CL_Vector& pos) =0;
  virtual void draw (Sprite& sprite, const CL_Vector& pos, int frame) =0;
  virtual void draw (CL_Surface& sur, const CL_Vector& pos) =0;
  virtual void draw (CL_Surface& sur, const CL_Vector& pos, int frame) =0;

  virtual void draw (CL_Surface& sur, int x_pos, int y_pos) =0;
  virtual void draw (CL_Surface& sur, int x_pos, int y_pos, int frame) =0;

  /** Draw a scaled surface */
  virtual void draw (CL_Surface& sur, int x_pos, int y_pos, 
                     float size_x, float size_y, int frame) =0;

  /** Draw a line */
  virtual void draw_line (const CL_Vector& pos1, const CL_Vector& pos2,
                          float r, float g, float b, float a = 1.0f) =0;
  /** Draw a line */
  virtual void draw_line (int x1, int y1, int x2, int y2, 
                          float r, float g, float b, float a = 1.0f) =0;

  /** Draw a filled rectangle (FIXME: [x1,x2] or [x1,x2[ ?) */
  virtual void draw_fillrect (int x1, int y1, int x2, int y2, 
                              float r, float g, float b, float a = 1.0f) =0;

  /** Draw an unfilled rectangle (FIXME: [x1,x2] or [x1,x2[ ?) */
  virtual void draw_rect (int x1, int y1, int x2, int y2, 
                          float r, float g, float b, float a = 1.0f) =0;

  /** Draw a singel pixel */
  virtual void draw_pixel (int x_pos, int y_pos, 
                           float r, float g, float b, float a = 1.0f) =0;

  /** Draw a circle */
  virtual void draw_circle (int x_pos, int y_pos, int radius,
                            float r, float g, float b, float a = 1.0f) =0;
};

#endif

/* EOF */

Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/Makefile.am,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -d -r1.92 -r1.93
--- Makefile.am 4 Sep 2002 14:55:11 -0000       1.92
+++ Makefile.am 4 Sep 2002 17:49:48 -0000       1.93
@@ -127,6 +127,8 @@
 direction.hxx \
 display.cxx \
 display.hxx \
+display_graphic_context.hxx \
+display_graphic_context.cxx \
 editor_hotspot.hxx \
 entrance.cxx \
 entrance.hxx \
@@ -162,6 +164,7 @@
 globals.hxx \
 groundpiece_data.cxx \
 groundpiece_data.hxx \
+graphic_context.hxx \
 gui_obj.hxx \
 gui_obj.cxx \
 gui_screen.cxx \

Index: console.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/console.hxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- console.hxx 4 Sep 2002 14:55:11 -0000       1.8
+++ console.hxx 4 Sep 2002 17:49:48 -0000       1.9
@@ -99,9 +99,7 @@
   /** Scroll down or up n lines, depending on the sign */
   void scroll (int n);
 
-  ///
   void puts(const std::string&);
-  ///
   void newline();
   
 private:

Index: playfield_view.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/playfield_view.hxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- playfield_view.hxx  23 Aug 2002 15:49:50 -0000      1.3
+++ playfield_view.hxx  4 Sep 2002 17:49:48 -0000       1.4
@@ -27,6 +27,7 @@
 class World;
 class Pingu;
 
+/** FIXME: Document me */
 class PlayfieldView : public GuiObj
 {
 private:

Index: view.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/view.cxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- view.cxx    5 Aug 2002 09:19:08 -0000       1.7
+++ view.cxx    4 Sep 2002 17:49:48 -0000       1.8
@@ -28,7 +28,8 @@
 World* View::world;
 
 View::View(Client* client, int x1, int y1, int x2, int y2, float s)
-  : cap (client->get_button_panel ()),
+  : display_gc (x1, y1, x2, y2, 0, 0),
+    cap (client->get_button_panel ()),
     current_pingu (0)
 {
   mouse_over = false;
@@ -66,6 +67,10 @@
   world->draw(x1_pos, y1_pos,
              x2_pos - x1_pos + 1, y2_pos - y1_pos + 1,
              x_offset, y_offset, size);
+
+  // Update the scroll position
+  display_gc.set_offset (x_offset, y_offset);
+  world->draw (display_gc);
   
   cap.set_pingu(current_pingu);
   cap.draw_offset(get_x_pos() + get_x_offset(), 

Index: view.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/view.hxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- view.hxx    23 Aug 2002 15:49:51 -0000      1.6
+++ view.hxx    4 Sep 2002 17:49:48 -0000       1.7
@@ -23,6 +23,7 @@
 #include <ClanLib/Display/Display/cliprect.h>
 #include "range.hxx"
 #include "capture_rectangle.hxx"
+#include "display_graphic_context.hxx"
 
 class Pingu;
 class World;
@@ -34,6 +35,8 @@
 class View
 {
 private:
+  DisplayGraphicContext display_gc;
+
   CL_ClipRect clip_rect;
   /// The position of the view in the world
   Range x_offset, y_offset; 

Index: world.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/world.cxx,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- world.cxx   25 Aug 2002 09:08:48 -0000      1.19
+++ world.cxx   4 Sep 2002 17:49:48 -0000       1.20
@@ -98,20 +98,24 @@
   x_of += x1;
   y_of += y1;
 
-  //unsigned int time = CL_System::get_time (); 
   for(WorldObjIter obj = world_obj.begin(); obj != world_obj.end(); ++obj)
     {
-      //unsigned int time = CL_System::get_time (); 
       (*obj)->draw_offset(x_of, y_of, s);
-      /*std::cout << "> time: " << CL_System::get_time() - time 
-               << " " << typeid (*obj->get()).name()
-               << std::endl;*/
     }
-  //std::cout << "time: " << CL_System::get_time() - time << std::endl;
-
-  //gfx_map->draw(x1, y1, w, h, x_of, y_of, s);
   
   particle_holder->draw_offset(x_of, y_of, s);
+}
+
+void
+World::draw (GraphicContext& gc)
+{
+  for(WorldObjIter obj = world_obj.begin(); obj != world_obj.end(); ++obj)
+    {
+      (*obj)->draw (gc);
+    }
+  
+  // FIXME: Shouldn't the particle_holder be a worldobj in the above list?
+  particle_holder->draw (gc); 
 }
 
 void 

Index: world.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/world.hxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- world.hxx   23 Aug 2002 15:49:52 -0000      1.8
+++ world.hxx   4 Sep 2002 17:49:48 -0000       1.9
@@ -43,7 +43,7 @@
 class WorldImpl;
 class WorldObj;
 class GameTime;
-
+class GraphicContext;
 
 using std::list;
 using std::string;
@@ -101,10 +101,17 @@
       @param h    The height of the drawing area.
       @param x_of x_of
       @param y_of y_of
-      @param s    s   */
+      @param s    s   
+      
+      FIXME: deprecated
+  */
   void    draw(int x1, int y1, int w, int h,
               int x_of, int y_of, float s);
-  ///
+
+  /** Draw the world onto the given GraphicContext */
+  void    draw (GraphicContext& gc);
+
+  /** Update the World */
   void    update (float delta);
 
   /// Issue an armageddon, all Pingus will explode in some seconds.

Index: worldobj.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldobj.cxx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- worldobj.cxx        4 Sep 2002 14:55:11 -0000       1.4
+++ worldobj.cxx        4 Sep 2002 17:49:48 -0000       1.5
@@ -18,8 +18,11 @@
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //  02111-1307, USA. 
 
+#include <typeinfo>
+#include <iostream>
 #include "world.hxx"
 #include "worldobj.hxx"
+#include "graphic_context.hxx"
 
 World* WorldObj::world;
 
@@ -55,6 +58,15 @@
 WorldObj::draw_offset(int /*x*/, int /*y*/, float /*s*/)
 {
   // do nothing
+  std::cout << "WorldObj::draw_offset(int /*x*/, int /*y*/, float /*s*/): not 
implemented, probally a bug" << std::endl;
+}
+
+void
+WorldObj::draw (GraphicContext& gc)
+{
+  std::cout << "WorldObj:draw(GraphicContext): Using compat-wrapper: " 
+           << typeid(*this).name () << std::endl;
+  draw_offset (int(gc.get_x_offset ()), int(gc.get_y_offset ()), gc.get_zoom 
());
 }
 
 /* EOF */

Index: worldobj.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldobj.hxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- worldobj.hxx        4 Sep 2002 14:55:11 -0000       1.5
+++ worldobj.hxx        4 Sep 2002 17:49:48 -0000       1.6
@@ -22,6 +22,7 @@
 
 #include "pingus.hxx"
 
+class GraphicContext;
 class World;
 class WorldObjData;
 
@@ -64,6 +65,9 @@
    *  @param s the scalar by with the object is zoomed (1.0 is default)
    */
   virtual void draw_offset (int x, int y, float s = 1.0);
+
+  /** Draw the WorldObj to the given GraphicContext */
+  virtual void draw (GraphicContext& gc);
 
   /** Draws the objects collision map to the main collision map, this
    *  can be used for traps which need a solid ground. */





reply via email to

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