[SCM] Packaging for spacehero branch, master, updated. upstream/0.0.7-14-g9a11fb1

Arne Wichmann arnew at rasentrimmer.org
Thu Oct 8 16:00:00 UTC 2009


The following commit has been merged in the master branch:
commit 4e133f091f8d28006e5c20747671e286492ff02d
Merge: f3015a09f4337a85aaae69e357315736abd15edb 669996dd01c76bdd340c15ec384df25ce99c8e9e
Author: Arne Wichmann <arnew at rasentrimmer.org>
Date:   Sun Feb 22 16:07:49 2009 +0100

    Merge commit 'upstream/0.0.8'
    
    Conflicts:
    
    	SpaceDisplay.cpp
    	SpaceDisplay.h

diff --combined Level.cpp
index 6788b8d,c7bd53a..fde73fd
--- a/Level.cpp
+++ b/Level.cpp
@@@ -6,7 -6,7 +6,7 @@@
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   * 
-  * Foobar is distributed in the hope that it will be useful,
+  * Spacehero 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.
@@@ -15,6 -15,7 +15,6 @@@
   * along with Spacehero.  If not, see <http://www.gnu.org/licenses/>.
   */
  #include "Universe.h"
 -#include <fstream>
  
  Level::Level(std::ifstream &in) :
    t0(),
@@@ -29,52 -30,162 +29,52 @@@
    seed(0)
  
  {
 -  char c; int i;
 -  bool D=false,G=false;
 -  std::ios_base::iostate s = in.exceptions();
 -  in.exceptions(std::ios_base::badbit|std::ios_base::failbit|std::ios_base::eofbit);
 -  in >> c >> i;
 -  if(c!='V' && i!=1) throw Error::ParseLevel("wrong version in level file");
 -  try {
 -    while( in >> c, in.good()) {
 -      std::cerr << "level: trying to read: " << c << std::endl;
 -      switch(c) {
 -        case 'D': 
 -          goal = Goal(in);
 -          D=true;
 -          break;
 -        case 'G': 
 -          {
 -            Galaxy g(in);
 -            galaxies.push_back( g );
 -            std::cerr << "master galaxy? " << g.getmaster() << std::endl;
 -            if(g.getmaster()) G=true; // at least one master galaxy needed
 -          }
 -          break;
 -        case 'H':
 -          holes.push_back( Blackhole(in) );
 -          break;
 -        case 'S':
 -          in >> seed;
 -          break;
 -        case 'T':
 -          in >> maxtime;
 -          break;
 -        default:
 -          std::cerr << "unexpected char: " << c << std::endl;
 -          throw Error::ParseLevel("funny data in level");
 -      }
 -      std::cerr << "---" << std::endl;
 -    }
 -  } catch (std::ios_base::failure) {
 -    std::ios_base::iostate r = in.exceptions();
 -    if(r&std::ios_base::eofbit) {
 -      // end of level reached
 -      if(!(D&&G)) {
 -        if (!D) throw Error::ParseLevel("at least one goal needed");
 -        if (!G) throw Error::ParseLevel("at least one master galaxy needed");
 -      }
 -    } else {
 -      throw;
 -    }
 -  }
 -  in.exceptions(s);
 -}
 -
 -Goal::Goal(std::ifstream &in)
 -{
 -  bool P=false,R=false;
 -  char c;
 -  bool done=false;
 -  while( !done) {
 -    in >> c, in.good();
 -    std::cerr << "goal: trying to read: " << c << std::endl;
 +  goal = Goal(in);
 +  while(in.good()) {
 +    char c;
 +    in >> c;
 +    if(!in.good()) break;
 +    std::cerr << "Type: " << c << std::endl;
      switch(c) {
 -      case 'D':
 -        done=true;
 +      case 'M': 
 +        galaxies.push_back( Galaxy(in,true) );
          break;
 -      case 'P': 
 -        in >> x >> y >> z;
 -        P=true;
 +      case 'G': 
 +        galaxies.push_back( Galaxy(in) );
          break;
 -      case 'R': 
 -        in >> radius;
 -        R=true;
 +      case 'H':
 +        holes.push_back( Blackhole(in) );
 +        break;
 +      case 'S':
 +        in >> seed;
          break;
 -      default:
 -        std::cerr << "unexpected char: " << c << std::endl;
 -        throw Error::ParseLevel("funny data in goal");
      }
    }
 -  if(!P) throw Error::ParseLevel("Missing Position for Goal");
 -  if(!R) throw Error::ParseLevel("Missing Radius for Goal");
 +  maxtime = 30.0;
 +}
 +
 +Goal::Goal(std::ifstream &in)
 +{
 +  in >> x >> y >> z;
 +  in >> radius;
    setlevel();
  };
  
  Blackhole::Blackhole(std::ifstream &in) {
 -  bool P=false,W=false;
 -  char c;
 -  bool done=false;
 -  while( !done) {
 -    in >> c, in.good();
 -    std::cerr << "hole: trying to read: " << c << std::endl;
 -    switch(c) {
 -      case 'H':
 -        done=true;
 -        break;
 -      case 'P': 
 -        in >> x >> y >> z;
 -        P=true;
 -        break;
 -      case 'V':
 -        double t;
 -        in >> t >> t >> t; 
 -        break;
 -      case 'W': 
 -        in >> mass;
 -        W=true;
 -        break;
 -      default:
 -        std::cerr << "unexpected char: " << c << std::endl;
 -        throw Error::ParseLevel("funny data in hole");
 -    }
 -  }
 -  if(!P) throw Error::ParseLevel("Missing Position for Hole");
 -  if(!W) throw Error::ParseLevel("Missing Weight for Hole");
 +  double t;
 +  in >> x >> y >> z; 
 +  in >> t >> t >> t; 
 +  in >> mass; 
    radius = HOLESIZE*sqrt(mass/HOLEMEDIUMMASS);
    setlevel();
  };
  
 -Galaxy::Galaxy(std::ifstream &in) :
 -  master(false),
 +Galaxy::Galaxy(std::ifstream &in, bool master) :
 +  master(master),
    lr(true)
  {
 -  bool P=false,V=false,W=false;
 -  char c;
 -  bool done=false;
 -  while( !done) {
 -    in >> c, in.good();
 -    std::cerr << "galaxy: trying to read: " << c << std::endl;
 -    switch(c) {
 -      case 'G':
 -        done=true;
 -        break;
 -      case 'P': 
 -        in >> x >> y >> z;
 -        P=true;
 -        break;
 -      case 'V': 
 -        in >> vx >> vy >> vz; 
 -        V=true;
 -        break;
 -      case 'M':
 -        master=true;
 -        std::cerr << "Setting Galaxy as master" << std::endl;
 -        break;
 -      case 'W':
 -        in >> mass;
 -        W=true;
 -        break;
 -      default:
 -        std::cerr << "unexpected char: " << c << std::endl;
 -        throw Error::ParseLevel("funny data in galaxy");
 -    }
 -  }
 -  if(!P) throw Error::ParseLevel("Missing Position for Galaxy");
 -  if(!V) throw Error::ParseLevel("Missing Velocity for Galaxy");
 -  if(!W) throw Error::ParseLevel("Missing Weight for Galaxy");
 -  if(getmaster()) std::cerr << "this galaxy thinks it is master" << std::endl;
 - 
 -  setlevel();
 +  in >> x >> y >> z; 
 +  in >> vx >> vy >> vz; 
 +  in >> mass; 
    radius = BULGESIZE;
  };
diff --combined SpaceDisplay.h
index 7e36038,9345eaf..0951055
--- a/SpaceDisplay.h
+++ b/SpaceDisplay.h
@@@ -6,7 -6,7 +6,7 @@@
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   * 
-  * Foobar is distributed in the hope that it will be useful,
+  * Spacehero 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.
@@@ -33,7 -33,7 +33,7 @@@
  #define MEDIUM_HOLE (UNIVERSE_RIGHT*0.12)
  #define LARGE_HOLE (UNIVERSE_RIGHT*0.14)
  
- #define VIEWANGLE 45
+ #define VIEWANGLE 60
  
  #define TEXTR 0.0f
  #define TEXTG 1.0f
@@@ -45,6 -45,7 +45,6 @@@
  #include "PictureBook.h"
  #include "Illustrator.h"
  
 -
  class Editor;
  
  class SpaceDisplay
@@@ -59,7 -60,7 +59,7 @@@
        EditorView
      };
  
-     void displayUniverse( Universe &uni, int projection, int width, int height );
+     void displayUniverse( Universe &uni, int width, int height, bool eye = false, bool pleft = true );
      void drawBridge(Universe &uni, BridgeView view, double indicator, double holeWeight = 0);
      void handleEvents(BridgeView view, ButtonFlags &flags, Editor &editor);
      void showEnd(bool win, ButtonFlags &flags);
@@@ -76,13 -77,18 +76,18 @@@
      SDL_Event event;
      float zoom;
  
+     inline void drawStars(bool behind, bool eye, bool pleft, Universe &uni);
+ 
      inline void drawSkymass(SkyMass body)
      {
+       double z = body.z;
+       z = 8000*z*z;
+       if(body.z < 0) z = -z;
        glBegin(GL_QUADS);
-       glTexCoord2f( 0.0f, 0.0f ); glVertex3f( -body.radius+body.x, -body.radius+body.y, body.z );
-       glTexCoord2f( 1.0f, 0.0f ); glVertex3f(  body.radius+body.x, -body.radius+body.y, body.z );
-       glTexCoord2f( 1.0f, 1.0f ); glVertex3f(  body.radius+body.x,  body.radius+body.y, body.z );
-       glTexCoord2f( 0.0f, 1.0f ); glVertex3f( -body.radius+body.x,  body.radius+body.y, body.z );
+       glTexCoord2f( 0.0f, 0.0f ); glVertex3f( -body.radius+body.x, -body.radius+body.y, z );
+       glTexCoord2f( 1.0f, 0.0f ); glVertex3f(  body.radius+body.x, -body.radius+body.y, z );
+       glTexCoord2f( 1.0f, 1.0f ); glVertex3f(  body.radius+body.x,  body.radius+body.y, z );
+       glTexCoord2f( 0.0f, 1.0f ); glVertex3f( -body.radius+body.x,  body.radius+body.y, z );
        glEnd();
        /* Objekt zeichnen */
        /*
@@@ -100,6 -106,10 +105,10 @@@
        glTexCoord2f( 0.0f, 1.0f ); glVertex3f( size+body.x,  body.y, -size+body.z );
        glEnd();*/
      };
+     
+   public:
+     Illustrator* getIllustrator(){return &illustrator;}
+     GLdisplay* getDisplay(){return &display;}
  };
  
  #include "Editor.h"
diff --combined Universe.h
index 798fe6e,a355c7e..d9d7a98
--- a/Universe.h
+++ b/Universe.h
@@@ -6,7 -6,7 +6,7 @@@
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   * 
-  * Foobar is distributed in the hope that it will be useful,
+  * Spacehero 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.
@@@ -36,6 -36,15 +36,6 @@@ using boost::timer
  using boost::progress_timer;
  using boost::progress_display;
  
 -namespace Error {
 -  class ParseLevel {
 -    const char *p;
 -    public:
 -    ParseLevel(const char* q): p(q) {}
 -    const char* msg() {return p;}
 -  };
 -}
 -
  class SkyObject {
    public:
      double x, y, z; /* in 600000 LJ (0.5 = 300000 LJ = Mitte vom Spielfeld) */
@@@ -99,7 -108,7 +99,7 @@@ class Galaxy : public SkyMass 
  
      Galaxy();
    public:
 -    Galaxy(std::ifstream &in);
 +    Galaxy(std::ifstream &in, bool master=false);
      Galaxy(double ix, double iy, double imass, bool imaster, bool ilr) : SkyMass(ix, iy, imass, BULGESIZE), master(imaster), lr(ilr) {};
  
      std::vector<Star> getStars(int seed);
@@@ -148,7 -157,7 +148,7 @@@ class Level 
      double ldelta(double weight=0.1 ) { return weight*m_delta + (1-weight)*(elapsed()-lastt); };
      double delta() { return m_delta; }; // filtered delta
  
 -    double getmaxtime() const { return maxtime; }; // get maxtime
 +    double getmaxtime() { return maxtime; }; // get maxtime
      bool timeout() {return elapsed() > maxtime; }; // TODO: fix to use summed movement time
  
      double fps() {
@@@ -187,26 -196,30 +187,30 @@@ inline void SkyMass::move(double delta
  }
  
  inline void SkyMass::newton(SkyMass &m, double delta) {
-   double AX, AY, a1, a2, r3;
+   double AX, AY, AZ, a1, a2, r3;
    //std::cerr << *this << m << std::endl;
    if( (!getexists()) || (!m.getexists()) ) return;
  
    AX = x - m.x;
    AY = y - m.y;
+   AZ = z - m.z;
  
-   r3 = hypot(AX,AY);
+   r3 = sqrt(AX*AX+AY*AY+AZ*AZ);
    r3 = r3*r3*r3;
  
    AX = AX/r3;
    AY = AY/r3;
+   AZ = AZ/r3;
  
    a1 = SUNGRAVTIMEWIDTH*mass*delta;
    m.vx += a1*AX;
    m.vy += a1*AY;  
+   m.vz += a1*AZ;  
  
    a2 = SUNGRAVTIMEWIDTH*m.mass*delta;
    vx -= a2*AX;
    vy -= a2*AY;
+   vz -= a2*AZ;
  };
  
  #endif
diff --combined main.cpp
index 0639bfc,8c36816..0958fdb
--- a/main.cpp
+++ b/main.cpp
@@@ -6,7 -6,7 +6,7 @@@
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   * 
-  * Foobar is distributed in the hope that it will be useful,
+  * Spacehero 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.
@@@ -64,12 -64,17 +64,12 @@@ int main(int argc, char *argv[]
        for (directory_iterator itr(levels); itr != directory_iterator(); ++itr) {
          std::cerr << "trying to load level: " << itr->path() << std::endl;
          std::ifstream level(itr->path().string().c_str());
 -        std::ofstream levelwrite("/tmp/level.out");
          if(level) {
 -          try { 
 -            Level l(level); 
 -            levelwrite << l;
 -            Universe u(l);
 -            Spacehero s(display,u);
 -            s.play();
 -          } catch (Error::ParseLevel e) {
 -            std::cerr << e.msg() << std::endl;
 -          }
 +          Level l(level);
 +          std::cerr << l << std::endl;
 +          Universe u(l);
 +          Spacehero s(display,u);
 +          s.play();
  
          }
        }
@@@ -81,7 -86,6 +81,6 @@@
      Universe u(l);
      Spacehero s(display,u);
      s.play();
- 
    }
  
  
diff --combined output.cpp
index c22bf59,694a0be..2071897
--- a/output.cpp
+++ b/output.cpp
@@@ -6,7 -6,7 +6,7 @@@
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   * 
-  * Foobar is distributed in the hope that it will be useful,
+  * Spacehero 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.
@@@ -17,45 -17,51 +17,45 @@@
  
  #include "Universe.h"
  
 +
 +
  std::ostream& operator<< (std::ostream &o, const SkyObject &g) {
 -//  o << "SkyObject: " << std::endl;
 -  o << "P " << g.x << " " << g.y << " " << g.z << std::endl;
 +  o << "SkyObject: " << std::endl;
 +  o << "(x,y,z): " << g.x << " " << g.y << " " << g.z << std::endl;
    return o;
  }
  
  std::ostream& operator<< (std::ostream &o, const SkyMass &g) {
 -  //o << "SkyMass: " << std::endl;
 +  o << "SkyMass: " << std::endl;
 +  o << "mass: " << g.mass << std::endl;
    //o << "(fx,fy,fz): " << g.fx << " " << g.fy << " " << g.fz << std::endl;
 -  o << static_cast<SkyObject>(g);
 -  o << "V " << g.vx << " " << g.vy << " " << g.vz << std::endl;
 -  o << "W " << g.mass << std::endl;
 +  o << "(vx,vy,vz)" << g.vx << " " << g.vy << " " << g.vz << std::endl;
 +  o << static_cast<SkyObject>(g) << std::endl;
    return o;
  }
  std::ostream& operator<< (std::ostream &o, const Goal &g) {
 -  o << "D " << std::endl;
 -  o << static_cast<SkyObject>(g);
 -  o << "R " << g.radius << std::endl;
 -  o << "D " << std::endl << std::endl;
 +  o << "Goal: " << std::endl;
 +  o << "radius: " << g.radius << std::endl;
 +  o << static_cast<SkyObject>(g) << std::endl;
    return o;
  }
  std::ostream& operator<< (std::ostream &o, const Blackhole &g) {
 -  o << "H" << std::endl;
 -  o << static_cast<SkyMass>(g);
 -  o << "H" << std::endl << std::endl;
 +  o << "Blackhole: " << std::endl;
 +  o << static_cast<SkyMass>(g) << std::endl;
    return o;
  }
  std::ostream& operator<< (std::ostream &o, const Star &g) {
 -  o << "S" << std::endl;
 -  o << static_cast<SkyMass>(g);
 -  o << "S" << std::endl << std::endl;
 +  o << "Star: " << std::endl;
 +  o << static_cast<SkyMass>(g) << std::endl;
    return o;
  }
  std::ostream& operator<< (std::ostream &o, const Galaxy &g) {
 -  o << "G" << std::endl;
 -  o << (g.master?"M ":"") << std::endl;
 -  o << static_cast<SkyMass>(g);
 -  o << "G" << std::endl << std::endl;
 +  o << "Galaxy: " << std::endl;
 +  o << static_cast<SkyMass>(g) << std::endl;
    return o;
  }
 -
  std::ostream& operator<< (std::ostream &o, const Level &l) {
 -  o << "V 1" << std::endl;
 -  o << "T " << l.getmaxtime() << std::endl;
 -  o << l.goal;
 +  o << l.goal << std::endl;
    copy(l.holes.begin(),l.holes.end(),std::ostream_iterator<Blackhole>(o));
    copy(l.galaxies.begin(),l.galaxies.end(),std::ostream_iterator<Galaxy>(o));
    return o;

-- 
Packaging for spacehero



More information about the Pkg-games-commits mailing list