- added new bigtux
authorIngo Ruhnke <grumbel@gmx.de>
Sun, 18 Apr 2004 20:36:01 +0000 (20:36 +0000)
committerIngo Ruhnke <grumbel@gmx.de>
Sun, 18 Apr 2004 20:36:01 +0000 (20:36 +0000)
SVN-Revision: 561

src/gameloop.cpp
src/player.cpp
src/player.h
src/resources.cpp
src/sound.h

index 1f1131a..2dec06b 100644 (file)
@@ -63,6 +63,8 @@ GameSession::restart_level()
   fps_timer.init(true);
   frame_timer.init(true);
 
+  delete world;
+
   if (st_gl_mode == ST_GL_LOAD_LEVEL_FILE)
     {
       world = new World(subset);
index d9d476e..d45be28 100644 (file)
@@ -17,6 +17,7 @@
 #include "defines.h"
 #include "scene.h"
 #include "tile.h"
+#include "sprite.h"
 #include "screen.h"
 
 Surface* tux_life;
@@ -27,10 +28,10 @@ Surface* smalltux_jump_right;
 Surface* smalltux_stand_left;
 Surface* smalltux_stand_right;
 
-Surface* bigtux_right[3];
-Surface* bigtux_left[3];
-Surface* bigtux_right_jump;
-Surface* bigtux_left_jump;
+Sprite* bigtux_right;
+Sprite* bigtux_left;
+Sprite* bigtux_right_jump;
+Sprite* bigtux_left_jump;
 Surface* ducktux_right;
 Surface* ducktux_left;
 Surface* skidtux_right;
@@ -597,45 +598,27 @@ Player::draw()
                 {
                   if (!skidding_timer.started())
                     {
-                      if (!jumping || physic.get_velocity_y() > 0)
+                      if (physic.get_velocity_y() == 0)
                         {
                           if (dir == RIGHT)
-                            {
-                              bigtux_right[frame_]->draw(
-                                           base.x- scroll_x - 8, base.y);
-                            }
+                            bigtux_right->draw(base.x- scroll_x - 8, base.y);
                           else
-                            {
-                              bigtux_left[frame_]->draw(
-                                           base.x- scroll_x - 8, base.y);
-                            }
+                              bigtux_left->draw(base.x- scroll_x - 8, base.y);
                         }
                       else
                         {
                           if (dir == RIGHT)
-                            {
-                              bigtux_right_jump->draw(
-                                           base.x- scroll_x - 8, base.y);
-                            }
+                            bigtux_right_jump->draw(base.x- scroll_x - 8, base.y);
                           else
-                            {
-                              bigtux_left_jump->draw(
-                                           base.x- scroll_x - 8, base.y);
-                            }
+                            bigtux_left_jump->draw(base.x- scroll_x - 8, base.y);
                         }
                     }
                   else
                     {
                       if (dir == RIGHT)
-                        {
-                          skidtux_right->draw(
-                                       base.x- scroll_x - 8, base.y);
-                        }
+                        skidtux_right->draw(base.x- scroll_x - 8, base.y);
                       else
-                        {
-                          skidtux_left->draw(
-                                       base.x- scroll_x - 8, base.y);
-                        }
+                        skidtux_left->draw(base.x- scroll_x - 8, base.y);
                     }
                 }
               else
index 97e6df1..c134427 100644 (file)
@@ -60,6 +60,8 @@ struct player_input_type
 
 void player_input_init(player_input_type* pplayer_input);
 
+class Sprite;
+
 extern Surface* tux_life;
 extern std::vector<Surface*> tux_right;
 extern std::vector<Surface*> tux_left;
@@ -67,10 +69,10 @@ extern Surface* smalltux_jump_left;
 extern Surface* smalltux_jump_right;
 extern Surface* smalltux_stand_left;
 extern Surface* smalltux_stand_right;
-extern Surface* bigtux_right[3];
-extern Surface* bigtux_left[3];
-extern Surface* bigtux_right_jump;
-extern Surface* bigtux_left_jump;
+extern Sprite* bigtux_right;
+extern Sprite* bigtux_left;
+extern Sprite* bigtux_right_jump;
+extern Sprite* bigtux_left_jump;
 extern Surface* ducktux_right;
 extern Surface* ducktux_left;
 extern Surface* skidtux_right;
index 9abc401..397b74b 100644 (file)
@@ -75,27 +75,11 @@ void loadshared()
   cape_left[1] = new Surface(datadir + "/images/shared/cape-left-1.png",
                USE_ALPHA);
 
-  bigtux_right[0] = new Surface(datadir + "/images/shared/bigtux-right-0.png",
-               USE_ALPHA);
-
-  bigtux_right[1] = new Surface(datadir + "/images/shared/bigtux-right-1.png",
-               USE_ALPHA);
-
-  bigtux_right[2] = new Surface(datadir + "/images/shared/bigtux-right-2.png",
-               USE_ALPHA);
-
-  bigtux_right_jump = new Surface(datadir + "/images/shared/bigtux-right-jump.png", USE_ALPHA);
-
-  bigtux_left[0] = new Surface(datadir + "/images/shared/bigtux-left-0.png",
-               USE_ALPHA);
-
-  bigtux_left[1] = new Surface(datadir + "/images/shared/bigtux-left-1.png",
-               USE_ALPHA);
-
-  bigtux_left[2] = new Surface(datadir + "/images/shared/bigtux-left-2.png",
-               USE_ALPHA);
+  bigtux_right = sprite_manager->load("largetux-walk-right");
+  bigtux_left  = sprite_manager->load("largetux-walk-left");
 
-  bigtux_left_jump = new Surface(datadir + "/images/shared/bigtux-left-jump.png", USE_ALPHA);
+  bigtux_left_jump  = sprite_manager->load("largetux-jump-left");
+  bigtux_right_jump = sprite_manager->load("largetux-jump-right");
 
   bigcape_right[0] = new Surface(datadir + "/images/shared/bigcape-right-0.png",
                USE_ALPHA);
@@ -302,8 +286,6 @@ void unloadshared(void)
     {
       delete tux_right[i];
       delete tux_left[i];
-      delete bigtux_right[i];
-      delete bigtux_left[i];
     }
 
   delete bigtux_right_jump;
index a7663e2..eab67aa 100644 (file)
@@ -71,8 +71,10 @@ extern char* soundfilenames[NUM_SOUNDS];
 #include <SDL_mixer.h>
 
 /* variables for stocking the sound and music */
-extern Mix_Chunk * sounds[NUM_SOUNDS];
-extern Mix_Music * level_song, * level_song_fast, * herring_song;
+extern Mix_Chunk* sounds[NUM_SOUNDS];
+extern Mix_Music* level_song;
+extern Mix_Music* level_song_fast;
+extern Mix_Music* herring_song;
 
 /* functions handling the sound and music */
 int open_audio(int frequency, Uint16 format, int channels, int chunksize);