pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] CVS: Games/Pingus/src Makefile.am, 1.152, 1.153 action_butt


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src Makefile.am, 1.152, 1.153 action_button.cxx, 1.31, 1.32 globals.cxx, 1.15, 1.16 globals.hxx, 1.17, 1.18 math.hxx, 1.8, 1.9 pingus_main.cxx, 1.95, 1.96 pingus_main.hxx, 1.12, 1.13 sprite.cxx, 1.14, 1.15 sprite.hxx, 1.10, 1.11
Date: 16 Aug 2003 20:51:30 -0000

Update of /var/lib/cvs/Games/Pingus/src
In directory dark:/tmp/cvs-serv15910

Modified Files:
        Makefile.am action_button.cxx globals.cxx globals.hxx math.hxx 
        pingus_main.cxx pingus_main.hxx sprite.cxx sprite.hxx 
Log Message:
- added level preview render code

Index: Makefile.am
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/Makefile.am,v
retrieving revision 1.152
retrieving revision 1.153
diff -u -d -r1.152 -r1.153
--- Makefile.am 24 Apr 2003 15:18:19 -0000      1.152
+++ Makefile.am 16 Aug 2003 20:51:28 -0000      1.153
@@ -159,12 +159,6 @@
 indexed_canvas.cxx \
 layer_manager.cxx \
 layer_manager.hxx \
-level_desc.cxx \
-level_desc.hxx \
-level_interrupt.cxx \
-level_interrupt.hxx \
-level_result.cxx \
-level_result.hxx \
 libxmlfwd.hxx \
 loading.cxx \
 loading.hxx \
@@ -227,6 +221,8 @@
 plt_xml.hxx \
 prefab.cxx \
 prefab.hxx \
+preview_renderer.hxx \
+preview_renderer.cxx \
 range.cxx \
 range.hxx \
 res_descriptor.cxx \

Index: action_button.cxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/action_button.cxx,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- action_button.cxx   22 Apr 2003 16:40:41 -0000      1.31
+++ action_button.cxx   16 Aug 2003 20:51:28 -0000      1.32
@@ -153,12 +153,12 @@
   if (Cheat::unlimited_actions)
     {
       // FIXME: insert unlimited surface here
-      font->print_center(x_pos + 46, y_pos + 10, "oo");
+      font->print_center(x_pos + 46, y_pos + 5, "oo");
     }
   else
     {
       std::string str = to_string(action_holder->get_available(name));
-      font->print_center(x_pos + 46, y_pos + 10, str.c_str ());
+      font->print_center(x_pos + 46, y_pos + 5, str.c_str ());
     }
 }
 

Index: globals.cxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/globals.cxx,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- globals.cxx 13 Aug 2003 13:46:39 -0000      1.15
+++ globals.cxx 16 Aug 2003 20:51:28 -0000      1.16
@@ -51,6 +51,7 @@
 bool        use_opengl                      = false;
 bool        action_help                     = true;
 bool        show_input_debug_screen         = false;
+bool        render_preview                  = false;
 
 int         min_frame_skip                  = 1;
 int         max_frame_skip                  = 5;

Index: globals.hxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/globals.hxx,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- globals.hxx 19 Apr 2003 10:23:17 -0000      1.17
+++ globals.hxx 16 Aug 2003 20:51:28 -0000      1.18
@@ -56,7 +56,8 @@
 extern bool        max_cpu_usage;                   ///< --max-cpu-usage
 extern bool        use_opengl;                      ///< --use-opengl
 extern bool        action_help;                     ///< --action-help
-extern bool        show_input_debug_screen;         ///
+extern bool        show_input_debug_screen;         ///<
+extern bool        render_preview;                  ///<
 
 extern std::string global_username;                 ///< The name of the 
currently logged in user
 extern std::string global_email;                    ///< The email address of 
the currently logged in user

Index: math.hxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/math.hxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- math.hxx    19 Apr 2003 10:23:17 -0000      1.8
+++ math.hxx    16 Aug 2003 20:51:28 -0000      1.9
@@ -69,6 +69,15 @@
   return rand()%2 == 0;
 }
 
+inline
+int round (float f)
+{
+  if (f >= 0.0f)
+    return int(f + 0.5f);
+  else
+    return int(f - 0.5f);
+}
+
 } // namespace Math
 
 #endif

Index: pingus_main.cxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/pingus_main.cxx,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -d -r1.95 -r1.96
--- pingus_main.cxx     14 Aug 2003 20:08:25 -0000      1.95
+++ pingus_main.cxx     16 Aug 2003 20:51:28 -0000      1.96
@@ -80,6 +80,7 @@
 #include "string_tokenizer.hxx"
 #include "story.hxx"
 #include "cheat.hxx"
+#include "preview_renderer.hxx"
 #include "worldmap/manager.hxx"
 #include "worldobj_data_factory.hxx"
 
@@ -229,6 +230,7 @@
       {"frame-skip",        required_argument, 0, 157},
       {"cheat",             required_argument, 0, 156},
       {"controller",        required_argument, 0, 160},
+      {"render-preview",    required_argument, 0, 161},
 #ifdef HAVE_LIBCLANGL
       {"use-opengl",        no_argument,       0, 'G'},
 #endif
@@ -486,6 +488,12 @@
       controller_file = optarg;
       break;
 
+    case 161:
+      std::cout << "Rendering a Level Preview..." << std::endl;
+      render_preview = true;
+      preview_file   = optarg;
+      break;
+
     default:
       if (verbose) std::cout << _("Unknow char: ") << c << std::endl << 
std::endl;
       std::cout << _("Usage: ") << argv[0] << _(" [OPTIONS]... [LEVELFILE]") 
<< std::endl;
@@ -771,6 +779,18 @@
     {
       ScreenManager::instance()->push_screen(new InputDebugScreen (), true);
     }
+  else if (render_preview)
+    {
+      if (levelfile.empty())
+        {
+          PingusError::raise("You need to give a level file to render a 
preview");
+        }
+      else
+        {
+          PreviewRenderer::render(PLFResMgr::load_plf_from_filename(levelfile),
+                                  preview_file);
+        }
+    }
   else if (show_credits)
     {
       ScreenManager::instance()->push_screen(Credits::instance(), false);
@@ -801,8 +821,6 @@
             }
           else
             {
-              /*ScreenManager::instance()->push_screen
-                (new PingusGameSession 
(PLFResMgr::load_plf_from_filename(levelfile), false), true);*/
               ScreenManager::instance()->push_screen
                 (new StartScreen(PLFResMgr::load_plf_from_filename(levelfile)),
                  true);

Index: pingus_main.hxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/pingus_main.hxx,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- pingus_main.hxx     19 Apr 2003 10:23:17 -0000      1.12
+++ pingus_main.hxx     16 Aug 2003 20:51:28 -0000      1.13
@@ -35,6 +35,10 @@
   /// the name of the exe: argv[0]
   std::string executable_name;
   std::string levelfile;
+
+  /** Filename to which the level preview should be saved */
+  std::string preview_file;
+
   std::string worldmapfile;
   std::string resolution;
 

Index: sprite.cxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/sprite.cxx,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- sprite.cxx  19 Apr 2003 10:23:17 -0000      1.14
+++ sprite.cxx  16 Aug 2003 20:51:28 -0000      1.15
@@ -22,16 +22,10 @@
 #include "vector.hxx"
 #include "pingus_resource.hxx"
 #include "sprite.hxx"
+#include "math.hxx"
+#include "gui/graphic_context.hxx"
 #include "globals.hxx"
 
-int round (float f)
-{
-  if (f >= 0.0f)
-    return int(f + 0.5f);
-  else
-    return int(f - 0.5f);
-}
-
 Sprite::Sprite ()
 {
 }
@@ -121,13 +115,13 @@
   switch (direction)
     {
     case Sprite::NONE:
-      sur.put_screen (x + x_align, y + y_align, round(frame));
+      sur.put_screen (x + x_align, y + y_align, Math::round(frame));
       break;
     case Sprite::LEFT:
-      sur.put_screen (x + x_align, y + y_align, round(frame));
+      sur.put_screen (x + x_align, y + y_align, Math::round(frame));
       break;
     case Sprite::RIGHT:
-      sur.put_screen (x + x_align, y + y_align, round(frame) + max_frames ());
+      sur.put_screen (x + x_align, y + y_align, Math::round(frame) + 
max_frames ());
       break;
     default:
       std::cout << "Direction: " << direction << std::endl;
@@ -135,13 +129,40 @@
     }
 }
 
-
 void
 Sprite::put_screen (const Vector& pos)
 {
   put_screen (int(pos.x), int(pos.y));
 }
 
+void
+Sprite::draw(GraphicContext& gc, const Vector& pos)
+{
+  if (!sur)
+    return;
+
+  // FIXME: HACK
+  update (0.0f);
+
+  int x = int(pos.x);
+  int y = int(pos.y);
+
+  switch (direction)
+    {
+    case Sprite::NONE:
+    case Sprite::LEFT:
+      gc.draw(sur, x + x_align, y + y_align, Math::round(frame));
+      break;
+
+    case Sprite::RIGHT:
+      gc.draw(sur, x + x_align, y + y_align, Math::round(frame) + max_frames 
());
+      break;
+
+    default:
+      std::cout << "Direction: " << direction << std::endl;
+      assert(0);
+    }
+}
 
 void
 Sprite::set_align (int arg_x, int arg_y)
@@ -170,7 +191,7 @@
 {
   ++frame;
 
-  if (round(frame) >= int(sur.get_num_frames ()))
+  if (Math::round(frame) >= int(sur.get_num_frames ()))
     frame = 0;
 }
 
@@ -181,7 +202,7 @@
 {
   --frame;
 
-  if (round(frame) < 0)
+  if (Math::round(frame) < 0)
     frame = sur.get_num_frames () - 1;
 }
 
@@ -236,12 +257,12 @@
     case ENDLESS:
       frame += frames_per_second * delta;
 
-      if (round(frame) < 0) {
+      if (Math::round(frame) < 0) {
        std::cout << "frame below zero: " << frame << std::endl;
        frame  = (max_frames ()-1.0f);
       }
 
-      if (round(frame) >= max_frames ()) {
+      if (Math::round(frame) >= max_frames ()) {
        is_finished = true;
        frame = 0;
       }
@@ -249,7 +270,7 @@
 
     case ONCE:
       frame += frames_per_second * delta;
-      if (round(frame) >= max_frames ())
+      if (Math::round(frame) >= max_frames ())
        {
          is_finished = true;
          frame = max_frames () - 1;

Index: sprite.hxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/sprite.hxx,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- sprite.hxx  19 Apr 2003 10:23:17 -0000      1.10
+++ sprite.hxx  16 Aug 2003 20:51:28 -0000      1.11
@@ -25,6 +25,7 @@
 
 class Vector;
 class ResDescriptor;
+class GraphicContext;
 
 class Sprite
 {
@@ -80,6 +81,9 @@
       the alignment */
   void put_screen (const Vector& pos);
 
+  /** Equal to put_screen() except that it draws to a GraphicContext */
+  void draw(GraphicContext& gc, const Vector& pos );
+
   /** Set the alignment (aka offset) of the surface
    @param arg_x The x offset by which the surface drawn
    @param arg_y The y offset by which the surface drawn */





reply via email to

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