Cleanups. Basically I made sprites to care about the scrolling and not the player...
authorRicardo Cruz <rick2@aeiou.pt>
Tue, 11 May 2004 22:12:42 +0000 (22:12 +0000)
committerRicardo Cruz <rick2@aeiou.pt>
Tue, 11 May 2004 22:12:42 +0000 (22:12 +0000)
SVN-Revision: 1113

src/badguy.cpp
src/player.cpp
src/special.cpp
src/sprite.cpp
src/world.cpp

index e02da38..78927ee 100644 (file)
@@ -746,10 +746,10 @@ BadGuy::draw()
     }
 
   Sprite* sprite = (dir == LEFT) ? sprite_left : sprite_right;
-  sprite->draw(base.x - scroll_x, base.y);
+  sprite->draw(base.x, base.y);
 
   if (debug_mode)
-    fillrect(base.x - scroll_x, base.y, base.width, base.height, 75,0,75, 150);
+    fillrect(base.x, base.y, base.width, base.height, 75,0,75, 150);
 }
 
 void
@@ -810,7 +810,7 @@ BadGuy::squish_me(Player* player)
 {
   make_player_jump(player);
     
-  World::current()->add_score(base.x - scroll_x,
+  World::current()->add_score(base.x,
                               base.y, 50 * player_status.score_multiplier);
   play_sound(sounds[SND_SQUISH], SOUND_CENTER_SPEAKER);
   player_status.score_multiplier++;
@@ -830,7 +830,7 @@ BadGuy::squish(Player* player)
     World::current()->add_bad_guy(base.x, base.y, BAD_BOMB);
     
     make_player_jump(player);
-    World::current()->add_score(base.x - scroll_x, base.y, 50 * player_status.score_multiplier);
+    World::current()->add_score(base.x, base.y, 50 * player_status.score_multiplier);
     play_sound(sounds[SND_SQUISH], SOUND_CENTER_SPEAKER);
     player_status.score_multiplier++;
     remove_me();
@@ -882,7 +882,7 @@ BadGuy::squish(Player* player)
       
     make_player_jump(player);
              
-    World::current()->add_score(base.x - scroll_x, base.y, 25 * player_status.score_multiplier);
+    World::current()->add_score(base.x, base.y, 25 * player_status.score_multiplier);
     player_status.score_multiplier++;
      
     // simply remove the fish...
@@ -922,7 +922,7 @@ BadGuy::kill_me(int score)
   physic.enable_gravity(true);
 
   /* Gain some points: */
-    World::current()->add_score(base.x - scroll_x, base.y,
+    World::current()->add_score(base.x, base.y,
                     score * player_status.score_multiplier);
 
   /* Play death sound: */
index cfffa82..2966672 100644 (file)
@@ -551,7 +551,7 @@ Player::draw()
     {
       if (dying == DYING_SQUISHED)
         {
-          smalltux_gameover->draw(base.x - scroll_x, base.y);
+          smalltux_gameover->draw(base.x, base.y);
         }
       else
         {
@@ -567,46 +567,46 @@ Player::draw()
           if (duck && size != SMALL)
             {
               if (dir == RIGHT)
-                sprite->duck_right->draw(base.x - scroll_x, base.y);
+                sprite->duck_right->draw(base.x, base.y);
               else 
-                sprite->duck_left->draw(base.x - scroll_x, base.y);
+                sprite->duck_left->draw(base.x, base.y);
             }
           else if (skidding_timer.started())
             {
               if (dir == RIGHT)
-                sprite->skid_right->draw(base.x - scroll_x, base.y);
+                sprite->skid_right->draw(base.x, base.y);
               else
-                sprite->skid_left->draw(base.x - scroll_x, base.y); 
+                sprite->skid_left->draw(base.x, base.y); 
             }
           else if (kick_timer.started())
             {
               if (dir == RIGHT)
-                sprite->kick_right->draw(base.x - scroll_x, base.y);
+                sprite->kick_right->draw(base.x, base.y);
               else
-                sprite->kick_left->draw(base.x - scroll_x, base.y); 
+                sprite->kick_left->draw(base.x, base.y); 
             }
           else if (physic.get_velocity_y() != 0)
             {
               if (dir == RIGHT)
-                sprite->jump_right->draw(base.x - scroll_x, base.y);
+                sprite->jump_right->draw(base.x, base.y);
               else
-                sprite->jump_left->draw(base.x - scroll_x, base.y);                   
+                sprite->jump_left->draw(base.x, base.y);                   
             }
           else
             {
               if (fabsf(physic.get_velocity_x()) < 1.0f) // standing
                 {
                   if (dir == RIGHT)
-                    sprite->stand_right->draw( base.x - scroll_x, base.y);
+                    sprite->stand_right->draw( base.x, base.y);
                   else
-                    sprite->stand_left->draw( base.x - scroll_x, base.y);
+                    sprite->stand_left->draw( base.x, base.y);
                 }
               else // moving
                 {
                   if (dir == RIGHT)
-                    sprite->walk_right->draw(base.x - scroll_x, base.y);
+                    sprite->walk_right->draw(base.x, base.y);
                   else
-                    sprite->walk_left->draw(base.x - scroll_x, base.y);
+                    sprite->walk_left->draw(base.x, base.y);
                 }
             }
                       
@@ -614,9 +614,9 @@ Player::draw()
           if (holding_something && physic.get_velocity_y() == 0)
             {
               if (dir == RIGHT)
-                sprite->grab_right->draw(base.x - scroll_x, base.y);
+                sprite->grab_right->draw(base.x, base.y);
               else
-                sprite->grab_left->draw(base.x - scroll_x, base.y);
+                sprite->grab_left->draw(base.x, base.y);
             }
 
           // Draw blinking star overlay
@@ -624,15 +624,15 @@ Player::draw()
              (invincible_timer.get_left() > TUX_INVINCIBLE_TIME_WARNING || global_frame_counter % 3))
             {
               if (size == SMALL || duck)
-                smalltux_star->draw(base.x - scroll_x, base.y);
+                smalltux_star->draw(base.x, base.y);
               else
-                largetux_star->draw(base.x - scroll_x, base.y);
+                largetux_star->draw(base.x, base.y);
             }
         }
     }     
   
   if (debug_mode)
-    fillrect(base.x - scroll_x, base.y, 
+    fillrect(base.x, base.y, 
              base.width, base.height, 75,75,75, 150);
 }
 
@@ -673,7 +673,7 @@ Player::collision(void* p_c_object, int c_object)
                 {
                    pbad_c->dying = DYING_FALLING;
                    play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER);
-                   World::current()->add_score(pbad_c->base.x - scroll_x,
+                   World::current()->add_score(pbad_c->base.x,
                                                pbad_c->base.y,
                                                25 * player_status.score_multiplier);
                 }
index 4ce1025..64fc9d8 100644 (file)
@@ -123,7 +123,7 @@ Bullet::draw()
   if (base.x >= scroll_x - base.width &&
       base.x <= scroll_x + screen->w)
     {
-      img_bullet->draw(base.x - scroll_x, base.y);
+      img_bullet->draw(base.x, base.y);
     }
 }
 
@@ -252,7 +252,7 @@ Upgrade::draw()
     {
       /* Rising up... */
 
-      dest.x = (int)(base.x - scroll_x);
+      dest.x = (int)(base.x);
       dest.y = (int)(base.y + 32 - base.height);
       dest.w = 32;
       dest.h = (int)base.height;
@@ -271,21 +271,21 @@ Upgrade::draw()
       if (kind == UPGRADE_GROWUP)
         {
           img_growup->draw(
-                       base.x - scroll_x, base.y);
+                       base.x, base.y);
         }
       else if (kind == UPGRADE_ICEFLOWER)
         {
           img_iceflower->draw(
-                       base.x - scroll_x, base.y);
+                       base.x, base.y);
         }
       else if (kind == UPGRADE_HERRING)
         {
           img_star->draw(
-                       base.x - scroll_x, base.y);
+                       base.x, base.y);
         }
       else if (kind == UPGRADE_1UP)
         {
-          img_1up->draw( base.x - scroll_x, base.y);
+          img_1up->draw( base.x, base.y);
         }
     }
 }
index 5c9c3f6..72ef1da 100644 (file)
@@ -79,7 +79,7 @@ Sprite::draw(float x, float y)
   unsigned int frame = get_current_frame();
 
   if (frame < surfaces.size())
-    surfaces[frame]->draw(x - x_hotspot, y - y_hotspot - scroll_y);
+    surfaces[frame]->draw(x - x_hotspot - scroll_x, y - y_hotspot - scroll_y);
 }
 
 void
index 094f1be..43b0532 100644 (file)
@@ -325,7 +325,7 @@ void World::scrolling(double frame_ratio)
     return;
     }
 
-  int tux_pos_x = (int)(tux.base.x + (tux.base.width/2));
+  float tux_pos_x = tux.base.x + (tux.base.width/2);
 
   if (level->back_scrolling || debug_mode)
   {
@@ -393,7 +393,7 @@ void World::scrolling(double frame_ratio)
 
   /* Y-axis scrolling */
 
-  int tux_pos_y = (int)(tux.base.y + (tux.base.height/2));
+  float tux_pos_y = tux.base.y + (tux.base.height/2);
 
   scroll_y = tux_pos_y - (screen->h / 2);
 
@@ -496,7 +496,7 @@ World::add_score(float x, float y, int s)
   player_status.score += s;
 
   FloatingScore* new_floating_score = new FloatingScore();
-  new_floating_score->init(x,y,s);
+  new_floating_score->init(x-scroll_x, y-scroll_y, s);
   floating_scores.push_back(new_floating_score);
 }
 
@@ -504,7 +504,7 @@ void
 World::add_bouncy_distro(float x, float y)
 {
   BouncyDistro* new_bouncy_distro = new BouncyDistro();
-  new_bouncy_distro->init(x,y);
+  new_bouncy_distro->init(x, y);
   bouncy_distros.push_back(new_bouncy_distro);
 }