Commits

Filip Mravunac  committed bc008be Merge

Merge

  • Participants
  • Parent commits 1d45a1f, a6e3061

Comments (0)

Files changed (4)

File gm_level.cpp

         (*it)->paintSelf();
     }
 
+
+
+
+
+
     SDL_GL_SwapBuffers();
 }
 
         double randomNumberY = 240 - ((rand() % 10000) / 10000.) * 480;
         spawnAsteroid(randomNumberX, randomNumberY);
     }
+    this->playership->updateSelf(timeDelta);
+    for(std::vector<Layer*>::iterator it = this->layers.begin(); it != this->layers.end(); it++)
+    {
+        (*it)->updateSelf(timeDelta);
+    }
     for(std::vector<Asteroid*>::iterator it = this->asteroids.begin(); it != this->asteroids.end(); it++)
     {
         (*it)->updateSelf(timeDelta);
     }
-    this->playership->updateSelf(timeDelta);
     for(std::vector<GameObject*>::iterator it = this->gameObjects.begin(); it != this->gameObjects.end(); it++)
     {
         (*it)->updateSelf(timeDelta);
     if(playership->isDead())
     {
         gGame->switchGameMode(new GM_MainMenu());
-        printf("Game Over");
+        printf("Game Over\n");
     }
 }

File levelbackground.cpp

 
 
 LevelBackground::LevelBackground(const int argX,
-                                 const int argY) : Layer ("background.png", 0,0)
+                                 const int argY) : Layer ("lvlbackground1.png", 0,0), xOffset(0), yOffset(0)
 {
 }
 LevelBackground::~LevelBackground()
 void
 LevelBackground::paintSelf()
 {
-    this->texture->bind();
-    glEnable(GL_TEXTURE_2D);
+    glMatrixMode(GL_TEXTURE);
+    glPushMatrix();
+    glTranslatef(xOffset, yOffset, 0);
 
-    glPushMatrix();
-    glTranslatef(this->x, this->y, 0);
-    glScalef(this->texture->getW(), this->texture->getH(), 0);
+    glMatrixMode(GL_MODELVIEW);
 
-    glBegin(GL_TRIANGLES);
+    Layer::paintSelf();
 
-    glTexCoord2f(0, 0);
-    glVertex2f(-0.5, -0.5);
-    glTexCoord2f(0, 1);
-    glVertex2f(-0.5, 0.5);
-    glTexCoord2f(1, 1);
-    glVertex2f(0.5, 0.5);
+    glMatrixMode(GL_TEXTURE);
+    glPopMatrix();
 
-    glTexCoord2f(1, 1);
-    glVertex2f(0.5, 0.5);
-    glTexCoord2f(1, 0);
-    glVertex2f(0.5, -0.5);
-    glTexCoord2f(0, 0);
-    glVertex2f(-0.5, -0.5);
-
-    glEnd();
-
-    glPopMatrix();
+    glMatrixMode(GL_MODELVIEW);
 
 }
 
 LevelBackground::updateSelf(const double timeDelta)
 {
     Layer::updateSelf(timeDelta);
+    xOffset += timeDelta / 25;
 }

File levelbackground.h

     void paintSelf();
     void updateSelf(const double timeDelta);
 
+    private:
+    double xOffset;
+    double yOffset;
 };
 
 

File playership.cpp

 
 static const double playerShipAngleV = 180;
 static const double playerShipYV = 380;
-static double playerShipLives = 3;
+static int playerShipLives = 3;
 
 extern SDL_Joystick * gJoystick;
 
 {
     playerShipLives -= 1;
     if(playerShipLives <= 0)
+    {
         died = true;
+        playerShipLives = 3;
+    }
+
 }