[pandngdc] [commit] r350 - trunk/src

  • From: nicholas.samuel@xxxxxxxxx
  • To: pandngdc@xxxxxxxxxxxxx
  • Date: Fri, 26 Jun 2009 00:12:35 +0930

Author: enetheru
Date: Fri Jun 26 00:12:32 2009
New Revision: 350

Log:
created a new class called grid which will be used as a base animation and 
image list classes later. fixed up minor other things

Added:
   trunk/src/grid.cpp
   trunk/src/grid.h
Modified:
   trunk/src/Makefile.am
   trunk/src/healthbar.cpp
   trunk/src/newplayer.cpp
   trunk/src/newplayer.h
   trunk/src/testing.h

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am       Thu Jun 25 21:44:51 2009        (r349)
+++ trunk/src/Makefile.am       Fri Jun 26 00:12:32 2009        (r350)
@@ -14,4 +14,5 @@
        newobject.cpp \
        newplayer.cpp \
        environment.cpp \
-       healthbar.cpp
+       healthbar.cpp \
+       grid.cpp

Added: trunk/src/grid.cpp
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ trunk/src/grid.cpp  Fri Jun 26 00:12:32 2009        (r350)
@@ -0,0 +1,87 @@
+#include "common.h"
+#include "grid.h"
+
+PVN_Grid::PVN_Grid()
+{
+       SetImage(SDL_CreateRGBSurface(SDL_SWSURFACE,512,512,32,0,0,0,1));
+       SetFrame(new SDL_Rect);
+       SetPosition(new SDL_Rect);
+       GetFrame()->x = GetFrame()->y = 0;
+       GetFrame()->w = GetFrame()->h = 128;
+       index = 1;
+       end = 16;
+       hdiv = vdiv = 4;
+       return;
+}
+
+PVN_Grid::~PVN_Grid()
+{
+       return;
+}
+
+void PVN_Grid::SetEnd(int arg_value)
+{
+       if( arg_value > hdiv * vdiv ) end = hdiv * vdiv;
+       else if( arg_value <= 1 ) end = 2;
+       else end = arg_value;
+       return;
+}
+
+int PVN_Grid::GetEnd()
+{
+       return end;
+}
+
+void PVN_Grid::SetIndex(int arg_value)
+{
+       if( arg_value > end ) index = end;
+       else if( arg_value < 1 ) index = 1;
+       else index = arg_value;
+       return;
+}
+
+int PVN_Grid::GetIndex()
+{
+       return index;
+}
+
+void PVN_Grid::SetHDiv(int arg_value)
+{
+       if( arg_value > 1 ) hdiv = arg_value;
+       Reset();
+       return;
+}
+
+int PVN_Grid::GetHDiv()
+{
+       return hdiv;
+}
+
+void PVN_Grid::SetVDiv(int arg_value)
+{
+       if( arg_value > 1 ) vdiv = arg_value;
+       Reset();
+       return;
+}
+
+int PVN_Grid::GetVDiv()
+{
+       return vdiv;
+}
+
+void PVN_Grid::Reset()
+{
+       GetFrame()->w = GetImage()->w / hdiv;
+       GetFrame()->h = GetImage()->h / vdiv;
+       return;
+}
+       
+
+int PVN_Grid::Step()
+{
+       index++;
+       if( index > end) index = 1;
+       GetFrame()->x = (index-1) % hdiv * (GetImage()->w / hdiv);
+       GetFrame()->y = (index-1) / vdiv * (GetImage()->h / vdiv);
+       return index;
+}

Added: trunk/src/grid.h
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ trunk/src/grid.h    Fri Jun 26 00:12:32 2009        (r350)
@@ -0,0 +1,20 @@
+#ifndef PVN_GRID_H
+#define PVN_GRID_H
+
+#include "newobject.h"
+
+class PVN_Grid : public PVN_Object
+{
+       private:
+               int end, index, hdiv, vdiv;
+       public:
+               PVN_Grid();
+               ~PVN_Grid();
+               void SetEnd(int);                       int GetEnd();
+               void SetIndex(int);             int GetIndex();
+               void SetHDiv(int);              int GetHDiv();
+               void SetVDiv(int);              int GetVDiv();
+               void Reset();
+               int Step();
+};
+#endif /*PVN_GRID_H*/

Modified: trunk/src/healthbar.cpp
==============================================================================
--- trunk/src/healthbar.cpp     Thu Jun 25 21:44:51 2009        (r349)
+++ trunk/src/healthbar.cpp     Fri Jun 26 00:12:32 2009        (r350)
@@ -128,7 +128,6 @@
        return;
 }
 
-
 void PVN_HealthBar::Blit(SDL_Surface *arg_destination)
 {
        SDL_BlitSurface(GetImage(), GetFrame(), arg_destination, newposition);

Modified: trunk/src/newplayer.cpp
==============================================================================
--- trunk/src/newplayer.cpp     Thu Jun 25 21:44:51 2009        (r349)
+++ trunk/src/newplayer.cpp     Fri Jun 26 00:12:32 2009        (r350)
@@ -7,22 +7,6 @@
        return;
 }
 
-PVN_Player::PVN_Player(PVN_Object *arg_object,
-       int arg_health,
-       int arg_jumpheight,
-       int arg_runspeed,
-       int arg_attackpower)
-{
-       SetImage(arg_object->GetImage());
-       SetFrame(arg_object->GetFrame());
-       SetPosition(arg_object->GetPosition());
-       health = arg_health;
-       jumpheight = arg_jumpheight;
-       runspeed = arg_runspeed;
-       arg_attackpower = attackpower;
-       return;
-}
-
 PVN_Player::~PVN_Player()
 {
        return;

Modified: trunk/src/newplayer.h
==============================================================================
--- trunk/src/newplayer.h       Thu Jun 25 21:44:51 2009        (r349)
+++ trunk/src/newplayer.h       Fri Jun 26 00:12:32 2009        (r350)
@@ -9,7 +9,6 @@
                int health, jumpheight, runspeed, attackpower;
        public:
                PVN_Player();
-               PVN_Player(PVN_Object *, int, int, int, int);
                ~PVN_Player();
                void SetHealth(int);
                void SetJumpHeight(int);

Modified: trunk/src/testing.h
==============================================================================
--- trunk/src/testing.h Thu Jun 25 21:44:51 2009        (r349)
+++ trunk/src/testing.h Fri Jun 26 00:12:32 2009        (r350)
@@ -10,6 +10,7 @@
 #include "healthbar.h"
 #include "player.h"
 #include "state_template.h"
+#include "grid.h"
 
 class PVN_test: public PVN_state
 {

Other related posts:

  • » [pandngdc] [commit] r350 - trunk/src - nicholas . samuel