Lots of updates! Level 2 support, mostly. (Thanks, Tobias Glaesser)
authorBill Kendrick <nbs@sonic.net>
Wed, 10 Dec 2003 07:38:52 +0000 (07:38 +0000)
committerBill Kendrick <nbs@sonic.net>
Wed, 10 Dec 2003 07:38:52 +0000 (07:38 +0000)
SVN-Revision: 9

46 files changed:
AUTHORS.txt
CHANGES.txt
Makefile
README.txt
TODO.txt
data/images/level2/bkgd-00.png [new file with mode: 0644]
data/images/level2/bkgd-01.png [new file with mode: 0644]
data/images/level2/bkgd-02.png [new file with mode: 0644]
data/images/level2/bkgd-03.png [new file with mode: 0644]
data/images/level2/bkgd-10.png [new file with mode: 0644]
data/images/level2/bkgd-11.png [new file with mode: 0644]
data/images/level2/bkgd-12.png [new file with mode: 0644]
data/images/level2/bkgd-13.png [new file with mode: 0644]
data/images/level2/brick0.png [new file with mode: 0644]
data/images/level2/brick1.png [new file with mode: 0644]
data/images/level2/solid0.png [new file with mode: 0644]
data/images/level2/solid1.png [new file with mode: 0644]
data/images/level2/solid2.png [new file with mode: 0644]
data/images/level2/solid3.png [new file with mode: 0644]
data/levels/level1.dat
data/levels/level1.dat-old [deleted file]
data/levels/level2.dat [new file with mode: 0644]
data/levels/level3.dat [new file with mode: 0644]
data/levels/level4.dat [new file with mode: 0644]
data/levels/level5.dat [new file with mode: 0644]
data/levels/level6.dat [new file with mode: 0644]
data/levels/level7.dat [new file with mode: 0644]
data/levels/level8.dat [new file with mode: 0644]
data/levels/level9.dat [new file with mode: 0644]
data/sounds/old/bigjump.wav [deleted file]
data/sounds/old/brick.wav [deleted file]
data/sounds/old/bump-upgrade.wav [deleted file]
data/sounds/old/coffee.wav [deleted file]
data/sounds/old/distro.wav [deleted file]
data/sounds/old/excellent.wav [deleted file]
data/sounds/old/fall.wav [deleted file]
data/sounds/old/herring.wav [deleted file]
data/sounds/old/hurt.wav [deleted file]
data/sounds/old/jump.wav [deleted file]
data/sounds/old/ricochet.wav [deleted file]
data/sounds/old/shoot.wav [deleted file]
data/sounds/old/skid.wav [deleted file]
data/sounds/old/squish.wav [deleted file]
data/sounds/old/upgrade.wav [deleted file]
src/gameloop.c
src/gameloop.h

index ec5b85f..84c9395 100644 (file)
@@ -4,9 +4,9 @@ by Bill Kendrick
 bill@newbreedsoftware.com
 http://www.newbreedsoftware.com/supertux/
 
-Version 0.0.2
+Version 0.0.5
 
-August 6, 2001
+December 9, 2003
 
 
 CREDITS
@@ -14,6 +14,8 @@ CREDITS
   Game Software:      Bill Kendrick, <bill@newbreedsoftware.com>
                       http://www.newbreedsoftware.com/bill/
 
+                     Tobias Glaesser <tobi.web@gmx.de>
+
   Graphics:           Bill Kendrick, using The GIMP
                       http://www.gimp.org/
 
index 6e4526c..59cfcc1 100644 (file)
@@ -14,6 +14,29 @@ http://www.newbreedsoftware.com/supertux/
 
   * Sped up FPS (throttle)
 
+  * Adding a new level (level,images,music) should be very easy now!
+    Tobias Glaesser <tobi.web@gmx.de>
+
+  * Shooting enemies increases score
+    Tobias Glaesser <tobi.web@gmx.de>
+
+  * Game over sequence.
+    Tobias Glaesser <tobi.web@gmx.de>
+
+  * Added 'make install PREFIX=/usr' and 'make uninstall PREFIX=/usr'
+    Tobias Glaesser <tobi.web@gmx.de>
+
+  * Initial support for additional levels.
+    Tobias Glaesser <tobi.web@gmx.de>
+
+  * Added small "Level 2"
+    Tobias Glaesser <tobi.web@gmx.de>
+
+  * One-ups ever 100 distros
+    Tobias Glaesser <tobi.web@gmx.de>
+
+  * Fixed up Makefile
+
 
 0.0.4 - July 15, 2002
 ---------------------
index 05dd319..c66631e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -4,14 +4,15 @@
 # bill@newbreedsoftware.com
 # http://www.newbreedsoftware.com/
 
-# Version 0.0.0
+# Version 0.0.5
 
-# April 11, 2000 - December 26, 2000
+# April 11, 2000 - December 9, 2003
 
 
 # User-definable stuff:
 
-DATA_PREFIX=$(PWD)/data
+PREFIX=/usr/local/
+DATA_PREFIX=$(PREFIX)supertux/
 JOY=YES
 
 
@@ -44,9 +45,14 @@ OBJECTS=obj/supertux.o obj/setup.o obj/intro.o obj/title.o obj/gameloop.o \
 
 all:   $(TARGET)
 
-#install: $(TARGET)
-#      -$(installdat) data $(DESTDIR)/usr/share/games/$(TARGET)/data
-#      -$(installbin) $(TARGET) $(DESTDIR)/usr/games/
+install: $(TARGET)
+       -mkdir -p $(DATA_PREFIX)
+       cp -R data/* $(DATA_PREFIX)
+       chown -R root.root $(DATA_PREFIX)
+       chmod -R a+rX $(DATA_PREFIX)
+       cp $(TARGET) $(PREFIX)bin/
+       chown root.root $(PREFIX)bin/$(TARGET)
+       chmod a+rx $(PREFIX)bin/$(TARGET)
 
 
 nosound:
index ed4321b..bdb2e22 100644 (file)
@@ -4,9 +4,9 @@ by Bill Kendrick
 bill@newbreedsoftware.com
 http://www.newbreedsoftware.com/supertux/
 
-Version 0.0.3
+Version 0.0.5
 
-November 14, 2001
+December 9, 2003
 
 
 NOTICE!  THIS GAME IS UNDER CONSTRUCTION!
@@ -14,7 +14,7 @@ Things you'll notice:
 
   Bugs
   Documentation is quite incomplete
-  Only one level
+  Only two levels
 
 
 DESCRIPTION
index f73b8c4..b21cc16 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -4,9 +4,9 @@ by Bill Kendrick
 bill@newbreedsoftware.com
 http://www.newbreedsoftware.com/supertux/
 
-Version 0.0.3
+Version 0.0.5
 
-November 25, 2001
+December 9, 2003
 
 
 TO DO
@@ -16,6 +16,6 @@ TO DO
   More enemies
   Redo laptop enemy graphics
   More levels
-  Play as Gown, resucing Tux
-  Game over
+  Play as Gown, rescuing Tux
+  End game on game over
   High score
diff --git a/data/images/level2/bkgd-00.png b/data/images/level2/bkgd-00.png
new file mode 100644 (file)
index 0000000..1491f74
Binary files /dev/null and b/data/images/level2/bkgd-00.png differ
diff --git a/data/images/level2/bkgd-01.png b/data/images/level2/bkgd-01.png
new file mode 100644 (file)
index 0000000..0428142
Binary files /dev/null and b/data/images/level2/bkgd-01.png differ
diff --git a/data/images/level2/bkgd-02.png b/data/images/level2/bkgd-02.png
new file mode 100644 (file)
index 0000000..3fe0f2a
Binary files /dev/null and b/data/images/level2/bkgd-02.png differ
diff --git a/data/images/level2/bkgd-03.png b/data/images/level2/bkgd-03.png
new file mode 100644 (file)
index 0000000..49a011e
Binary files /dev/null and b/data/images/level2/bkgd-03.png differ
diff --git a/data/images/level2/bkgd-10.png b/data/images/level2/bkgd-10.png
new file mode 100644 (file)
index 0000000..cd6e202
Binary files /dev/null and b/data/images/level2/bkgd-10.png differ
diff --git a/data/images/level2/bkgd-11.png b/data/images/level2/bkgd-11.png
new file mode 100644 (file)
index 0000000..734bb81
Binary files /dev/null and b/data/images/level2/bkgd-11.png differ
diff --git a/data/images/level2/bkgd-12.png b/data/images/level2/bkgd-12.png
new file mode 100644 (file)
index 0000000..9ba20d7
Binary files /dev/null and b/data/images/level2/bkgd-12.png differ
diff --git a/data/images/level2/bkgd-13.png b/data/images/level2/bkgd-13.png
new file mode 100644 (file)
index 0000000..c642394
Binary files /dev/null and b/data/images/level2/bkgd-13.png differ
diff --git a/data/images/level2/brick0.png b/data/images/level2/brick0.png
new file mode 100644 (file)
index 0000000..bc11142
Binary files /dev/null and b/data/images/level2/brick0.png differ
diff --git a/data/images/level2/brick1.png b/data/images/level2/brick1.png
new file mode 100644 (file)
index 0000000..32c9545
Binary files /dev/null and b/data/images/level2/brick1.png differ
diff --git a/data/images/level2/solid0.png b/data/images/level2/solid0.png
new file mode 100644 (file)
index 0000000..640c1ba
Binary files /dev/null and b/data/images/level2/solid0.png differ
diff --git a/data/images/level2/solid1.png b/data/images/level2/solid1.png
new file mode 100644 (file)
index 0000000..d6ebcb3
Binary files /dev/null and b/data/images/level2/solid1.png differ
diff --git a/data/images/level2/solid2.png b/data/images/level2/solid2.png
new file mode 100644 (file)
index 0000000..95db64a
Binary files /dev/null and b/data/images/level2/solid2.png differ
diff --git a/data/images/level2/solid3.png b/data/images/level2/solid3.png
new file mode 100644 (file)
index 0000000..0455f9f
Binary files /dev/null and b/data/images/level2/solid3.png differ
index 63c915e..b65155d 100644 (file)
@@ -1,6 +1,10 @@
+Antarctica
+255
+j_turn.it
 128
 192
 255
+375
 ......cdef......2.........................................cdef.........................................................CDEF.....................................cdedef..........................................................CDEF........................................................................cdef..............cf....................................................cde
 .......................................................................................................................cdef.....................................................................................................cdef...................................................................................................................................................
 ......................CDEF........................................CDEF.......................................................................CDEF....................................CDEF.......................................................................................................CDEDEF................................................................[.........*......
diff --git a/data/levels/level1.dat-old b/data/levels/level1.dat-old
deleted file mode 100644 (file)
index b6a073d..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-64
-96
-255
-ef.....................................................................cdef................................................................................................................................................................................................................[===============].........cdef.............................................................
-............................................................................................................................................................................................................................................................................................#################DEF.......................................................................
-........CDEF....................................................................................................CDEF........................................................................................................................................................................#################def.......................................................................
-........cdef..............................$.$.$.................................................................cdef....CDEF........................................................................................CDEF.....................................CDEF...........................#################..........................................................................
-............................................................................................CDEF........................cdef............................CDEF........................................................cdef.....................................cdef...........................#################..........................................................................
-.........................................YYYYYYy............................................cdef........................................................cdef............................................................................................................CDEF................#################..........................................................................
-......................................................................................................................................................................................................Y.................................................................cdef................#################..........................................................................
-......................................................CDEF..........................................................!.......................................................CDEF.............CDEF.........Y.................................................................................#################................CDEF......................................................
-........YAYBY........................YYYyXX.........[===]f.......................0.0.....................................................................................[====]f.............cdef....Y...............................=....................................................CD#################................cdef......................................................
-....................................................#####..................YYYYAYBYYY...................................................................................[######]...........................y.........................#DEF.................................................cd#################..........................................................................
-....................................................#####........................................[=]...........................###.....................................[########]...................Y..............................=.#def......................YYYYYY.......................#################..........................................................................
-.....YYYXXXXXYYY.................YYYYXXX...........[#####............0.0.0.......................###.........[=].........[=]...###...............=....................[##########]..........................Y......................#.#...........YYAYAYAYY.....XXXXXX..................................................................................................................
-...................YYY====YYYY.....................#######################==]....................###...[=]...###.........###...###...............#...................[############]..............................................=.#.#.........................XXXXXX.......................#################..........................................................................
-...................................0.0.0...........######...................#################....###...###...###...[=]...###...###....###........#...0.0.0..........[##############]..................................0.0........#.#.#.........................XXXXXX.................0.0...#################..........................................................................
-===================================================######^^^^^^^^^^^^^^^^^^^#################====###===###===###===###...###...###.........======#==================################==========####################################.#.#========================================]...[====================================================================================================
diff --git a/data/levels/level2.dat b/data/levels/level2.dat
new file mode 100644 (file)
index 0000000..663afa3
--- /dev/null
@@ -0,0 +1,22 @@
+Australia
+240
+SALCON.MOD
+128
+192
+255
+28
+......cddddeeeeeef......cdef
+............................
+............................
+............................
+............................
+............................
+..#.#.#.....#.#.#...........
+............................
+............................
+..............###...........
+...........###...######.....
+........###...........####..
+.....####...................
+..GHIJ......GHIJ............
+=======&&&&&&&&&&&==========
diff --git a/data/levels/level3.dat b/data/levels/level3.dat
new file mode 100644 (file)
index 0000000..79eed2e
--- /dev/null
@@ -0,0 +1 @@
+India
diff --git a/data/levels/level4.dat b/data/levels/level4.dat
new file mode 100644 (file)
index 0000000..21840b3
--- /dev/null
@@ -0,0 +1 @@
+Egypt
diff --git a/data/levels/level5.dat b/data/levels/level5.dat
new file mode 100644 (file)
index 0000000..b01b798
--- /dev/null
@@ -0,0 +1 @@
+Greece
diff --git a/data/levels/level6.dat b/data/levels/level6.dat
new file mode 100644 (file)
index 0000000..d7c7fd4
--- /dev/null
@@ -0,0 +1 @@
+Spain
diff --git a/data/levels/level7.dat b/data/levels/level7.dat
new file mode 100644 (file)
index 0000000..23f2ca7
--- /dev/null
@@ -0,0 +1 @@
+Brazil
diff --git a/data/levels/level8.dat b/data/levels/level8.dat
new file mode 100644 (file)
index 0000000..551d93d
--- /dev/null
@@ -0,0 +1 @@
+America
diff --git a/data/levels/level9.dat b/data/levels/level9.dat
new file mode 100644 (file)
index 0000000..5cf9203
--- /dev/null
@@ -0,0 +1 @@
+Redmond
diff --git a/data/sounds/old/bigjump.wav b/data/sounds/old/bigjump.wav
deleted file mode 100644 (file)
index ab03fcb..0000000
Binary files a/data/sounds/old/bigjump.wav and /dev/null differ
diff --git a/data/sounds/old/brick.wav b/data/sounds/old/brick.wav
deleted file mode 100644 (file)
index fc186f6..0000000
Binary files a/data/sounds/old/brick.wav and /dev/null differ
diff --git a/data/sounds/old/bump-upgrade.wav b/data/sounds/old/bump-upgrade.wav
deleted file mode 100644 (file)
index 00bfb9d..0000000
Binary files a/data/sounds/old/bump-upgrade.wav and /dev/null differ
diff --git a/data/sounds/old/coffee.wav b/data/sounds/old/coffee.wav
deleted file mode 100644 (file)
index 2e2be45..0000000
Binary files a/data/sounds/old/coffee.wav and /dev/null differ
diff --git a/data/sounds/old/distro.wav b/data/sounds/old/distro.wav
deleted file mode 100644 (file)
index 5741f23..0000000
Binary files a/data/sounds/old/distro.wav and /dev/null differ
diff --git a/data/sounds/old/excellent.wav b/data/sounds/old/excellent.wav
deleted file mode 100644 (file)
index cadcc5e..0000000
Binary files a/data/sounds/old/excellent.wav and /dev/null differ
diff --git a/data/sounds/old/fall.wav b/data/sounds/old/fall.wav
deleted file mode 100644 (file)
index 292e5c3..0000000
Binary files a/data/sounds/old/fall.wav and /dev/null differ
diff --git a/data/sounds/old/herring.wav b/data/sounds/old/herring.wav
deleted file mode 100644 (file)
index 96f3871..0000000
Binary files a/data/sounds/old/herring.wav and /dev/null differ
diff --git a/data/sounds/old/hurt.wav b/data/sounds/old/hurt.wav
deleted file mode 100644 (file)
index b8e95ca..0000000
Binary files a/data/sounds/old/hurt.wav and /dev/null differ
diff --git a/data/sounds/old/jump.wav b/data/sounds/old/jump.wav
deleted file mode 100644 (file)
index d89819e..0000000
Binary files a/data/sounds/old/jump.wav and /dev/null differ
diff --git a/data/sounds/old/ricochet.wav b/data/sounds/old/ricochet.wav
deleted file mode 100644 (file)
index 016c7bf..0000000
Binary files a/data/sounds/old/ricochet.wav and /dev/null differ
diff --git a/data/sounds/old/shoot.wav b/data/sounds/old/shoot.wav
deleted file mode 100644 (file)
index 48696ef..0000000
Binary files a/data/sounds/old/shoot.wav and /dev/null differ
diff --git a/data/sounds/old/skid.wav b/data/sounds/old/skid.wav
deleted file mode 100644 (file)
index 3abd9c7..0000000
Binary files a/data/sounds/old/skid.wav and /dev/null differ
diff --git a/data/sounds/old/squish.wav b/data/sounds/old/squish.wav
deleted file mode 100644 (file)
index a3f86c2..0000000
Binary files a/data/sounds/old/squish.wav and /dev/null differ
diff --git a/data/sounds/old/upgrade.wav b/data/sounds/old/upgrade.wav
deleted file mode 100644 (file)
index 95edf47..0000000
Binary files a/data/sounds/old/upgrade.wav and /dev/null differ
index 11be5ad..bba8c2f 100644 (file)
@@ -7,7 +7,7 @@
   bill@newbreedsoftware.com
   http://www.newbreedsoftware.com/supertux/
   
-  April 11, 2000 - July 15, 2002
+  April 11, 2000 - December 9, 2003
 */
 
 #include <stdio.h>
@@ -76,30 +76,15 @@ char * soundfilenames[NUM_SOUNDS] = {
 };
 
 
-/* Level names: */
-
-char * levelnames[] = {
-  "Antarctica",
-  "Australia",
-  "India",
-  "Egypt",
-  "Greece",
-  "Spain",
-  "Brazil",
-  "America",
-  "Redmond"
-};
-
-
 /* Local variables: */
 
-int score, distros, level, lives, scroll_x,
+int score, distros, level, lives, scroll_x, next_level,
   tux_dir, tux_size, tux_duck, tux_x, tux_xm, tux_y, tux_ym,
   tux_dying, tux_safe, jumping, jump_counter, frame, score_multiplier,
   tux_frame_main, tux_frame, tux_got_coffee, tux_skidding,
-  super_bkgd_time, time_left, tux_invincible_time,
+  super_bkgd_time, time_left, tux_invincible_time, endpos,
   counting_distros, distro_counter;
-int bkgd_red, bkgd_green, bkgd_blue;
+int bkgd_red, bkgd_green, bkgd_blue, level_width;
 int left, right, up, down, fire, old_fire;
 SDL_Surface * img_brick[2], * img_solid[4], * img_distro[4],
   * img_waves[3], * img_water, * img_pole, * img_poletop, * img_flag[2];
@@ -126,7 +111,7 @@ SDL_Surface * tux_right[3], * tux_left[3],
 Mix_Chunk * sounds[NUM_SOUNDS];
 Mix_Music * song;
 #endif
-unsigned char tiles[15][LEVEL_WIDTH + 5];
+unsigned char * tiles[15];
 bouncy_distro_type bouncy_distros[NUM_BOUNCY_DISTROS];
 broken_brick_type broken_bricks[NUM_BROKEN_BRICKS];
 bouncy_brick_type bouncy_bricks[NUM_BOUNCY_BRICKS];
@@ -134,6 +119,8 @@ bad_guy_type bad_guys[NUM_BAD_GUYS];
 floating_score_type floating_scores[NUM_FLOATING_SCORES];
 upgrade_type upgrades[NUM_UPGRADES];
 bullet_type bullets[NUM_BULLETS];
+char song_title[20];
+char levelname[20];
 
 
 /* Local function prototypes: */
@@ -331,7 +318,7 @@ int gameloop(void)
       
       /* Handle key and joystick state: */
       
-      if (!tux_dying)
+      if (!tux_dying && !next_level)
        {
          if (right == DOWN && left == UP)
            {
@@ -441,6 +428,16 @@ int gameloop(void)
                    }
                }
            }
+
+
+         /* End of level? */
+
+         if (tux_x >= endpos && endpos != 0)
+         {
+            /* FIXME: No need to kill Tux to end the level! ;^) */
+           next_level = 1;
+           tux_dying = 1;
+         }
          
          
          /* Jump/jumping? */
@@ -518,9 +515,11 @@ int gameloop(void)
              else
                tux_duck = NO;
            }
-       } /* !tux_dying */
+       } /* !tux_dying && !next_level */
       else
        {
+          /* Tux either died, or reached the end of a level! */
+               
          tux_ym = tux_ym + GRAVITY;
          
          if (tux_y >= 480)
@@ -532,13 +531,64 @@ int gameloop(void)
                    Mix_HaltMusic();
                }
 #endif
+            
+             if (next_level)
+             {
+               /* End of a level! */
+
+               level++;
+               next_level = 0;
+             }
+             else
+             {
+               /* He died :^( */
+                     
+               lives--;
+             }
+
+             
+             /* No more lives!? */
+
+             if (lives <= 0)
+             {
+
+
+               /* Display end-of-level stuff */
+               /* (FIXME: This should go in its own event loop function!) */
+               
+               clearscreen(0, 0, 0);
+
+               drawcenteredtext("GAMEOVER", 200, letters_red, NO_UPDATE);
+
+               sprintf(str, "SCORE: %d", score);
+               drawcenteredtext(str, 224, letters_gold, NO_UPDATE);
+
+               sprintf(str, "DISTROS: %d", distros);
+               drawcenteredtext(str, 256, letters_blue, NO_UPDATE);
+
+               SDL_Flip(screen);
+               SDL_Delay(5000);
+
+
+               /* FIXME: Should return to title screen, not restart game... */
+               
+               level = 0;
+               lives = 3;
+               
+               score=0;
+               distros=0;
+             }
+             
+             
+             /* Either way, (re-)load the (next) level... */
              
-             lives--;
              loadlevel();
+
+             unloadlevelgfx();
+             loadlevelgfx();
            }
        }
-      
-      
+
       /* Move tux: */
       
       tux_x = tux_x + tux_xm;
@@ -549,15 +599,15 @@ int gameloop(void)
       
       if (tux_x < 0)
        tux_x = 0;
-      else if (tux_x > 320 && scroll_x < ((LEVEL_WIDTH * 32) - 640))
+      else if (tux_x > 320 && scroll_x < ((level_width * 32) - 640))
        {
          /* Scroll the screen in past center: */
          
          scroll_x = scroll_x + (tux_x - 320);
          tux_x = 320;
          
-         if (scroll_x > ((LEVEL_WIDTH * 32) - 640))
-           scroll_x = ((LEVEL_WIDTH * 32) - 640);
+         if (scroll_x > ((level_width * 32) - 640))
+           scroll_x = ((level_width * 32) - 640);
        }
       else if (tux_x > 608)
        {
@@ -834,6 +884,17 @@ int gameloop(void)
              trygrabdistro(tux_x + 31, tux_y - 32, scroll_x, NO_BOUNCE);
            }
        }
+
+
+      /* Enough distros for a One-up? */
+
+      if (distros >= DISTROS_LIFEUP)
+      {
+       /* FIXME: Play a special sound or flash or both! */
+
+       distros = distros - DISTROS_LIFEUP;
+       lives++;
+      }
      
 
       /* Keep in-bounds, vertically: */
@@ -1016,9 +1077,28 @@ int gameloop(void)
                          bullets[i].y >= bad_guys[j].y - 4 &&
                          bullets[i].y <= bad_guys[j].y + 32 + 4)
                        {
+                         /* Kill the bad guy! */
+                               
                          bullets[i].alive = 0;
                          bad_guys[j].dying = FALLING;
                          bad_guys[j].ym = -8;
+
+
+                         /* Gain some points: */
+
+                         if (bad_guys[j].kind == BAD_BSOD)
+                          {
+                            add_score(bad_guys[j].x - scroll_x, bad_guys[j].y,
+                                       50 * score_multiplier);
+                          }
+                          else if (bad_guys[j].kind == BAD_LAPTOP)
+                          {
+                            add_score(bad_guys[j].x - scroll_x, bad_guys[j].y,
+                                         25 * score_multiplier);
+                         }
+
+
+                         /* Play death sound: */
 #ifndef NOSOUND
                          playsound(sounds[SND_FALL]);
 #endif
@@ -2136,7 +2216,7 @@ int gameloop(void)
 
 void initgame(void)
 {
-  level = 0;
+  level = 1;
   score = 0;
   distros = 0;
   lives = 3;
@@ -2151,7 +2231,7 @@ void loadlevel(void)
   FILE * fi;
   char * filename;
   char str[80];
-  char line[LEVEL_WIDTH + 5];
+  char * line;
   
   
   /* Reset arrays: */
@@ -2179,8 +2259,9 @@ void loadlevel(void)
 
 
   /* Load data file: */
-  
-  filename = strdup(DATA_PREFIX "/levels/level1.dat");
+  filename = (char *) malloc(sizeof(char) * (strlen(DATA_PREFIX) + 20));
+  sprintf(filename, "%s/levels/level%d.dat", DATA_PREFIX, level);
   fi = fopen(filename, "r");
   if (fi == NULL)
     {
@@ -2189,18 +2270,51 @@ void loadlevel(void)
     }
   free(filename);
   
-  fgets(line, 10, fi);
-  bkgd_red = atoi(line);
-  fgets(line, 10, fi);
-  bkgd_green= atoi(line);
-  fgets(line, 10, fi);
-  bkgd_blue = atoi(line);
+
+  /* Load header info: */
+
+  /* (Level title) */
+  fgets(str, 20, fi);
+  strcpy(levelname, str);
+
+  /* (Time to beat level) */
+  fgets(str, 10, fi);
+  time_left = atoi(str);
+
+  /* (Song file for this level) */
+  fgets(str, 20, fi);
+  strcpy(song_title, str);
+  
+  /* (Level background color) */
+  fgets(str, 10, fi);
+  bkgd_red = atoi(str);
+  fgets(str, 10, fi);
+  bkgd_green= atoi(str);
+  fgets(str, 10, fi);
+  bkgd_blue = atoi(str);
+
+  /* (Level width) */
+  fgets(str, 10, fi);
+  level_width = atoi(str);
+  
+
+  /* Allocate some space for the line-reading! */
+  
+  line = (char *) malloc(sizeof(char) * (level_width + 5));
+  if (line == NULL)
+  {
+    fprintf(stderr, "Couldn't allocate space to load level data!");
+    exit(1);
+  }
+  
+  
+  /* Load the level lines: */
   
   for (y = 0; y < 15; y++)
     {
-      fgets(line, LEVEL_WIDTH + 5, fi);
+      fgets(line, level_width + 5, fi);
       line[strlen(line) - 1] = '\0';
-      strcpy(tiles[y], line);
+      tiles[y] = strdup(line);
     }
   
   fclose(fi);
@@ -2210,7 +2324,7 @@ void loadlevel(void)
   
   for (y = 0; y < 15; y++)
     {
-      for (x = 0; x < LEVEL_WIDTH; x++)
+      for (x = 0; x < level_width; x++)
        {
          if (tiles[y][x] >= '0' && tiles[y][x] <= '9')
            {
@@ -2266,7 +2380,7 @@ void loadlevel(void)
   sprintf(str, "LEVEL %d", level + 1);
   drawcenteredtext(str, 200, letters_red, NO_UPDATE);
   
-  sprintf(str, "%s", levelnames[level]);
+  sprintf(str, "%s", levelname);
   drawcenteredtext(str, 224, letters_gold, NO_UPDATE);
   
   sprintf(str, "TUX x %d", lives);
@@ -2320,8 +2434,17 @@ void loadlevelgfx(void)
 
 void loadlevelsong(void)
 {
+  char * song_path;
+
 #ifndef NOSOUND
+  song_path = (char *) malloc(sizeof(char) * (strlen(DATA_PREFIX) +
+                                             strlen(song_title) + 8));
+
+  sprintf(song_path, "%s/music/%s", DATA_PREFIX, song_title);
+  
   song = load_song(DATA_PREFIX "/music/ji_turn.it");
+
+  free(song_path);
 #endif
 }
 
@@ -2840,7 +2963,13 @@ void drawshape(int x, int y, unsigned char c)
   else if (c == '*')
     drawimage(img_poletop, x, y, NO_UPDATE);
   else if (c == '|')
+  {
     drawimage(img_pole, x, y, NO_UPDATE);
+
+    /* Mark this as the end position of the level! */
+
+    endpos = x;
+  }
   else if (c == '\\')
     {
       z = (frame / 3) % 2;
@@ -2862,7 +2991,7 @@ unsigned char shape(int x, int y, int sx)
   yy = (y / 32);
   xx = ((x + sx) / 32);
   
-  if (yy >= 0 && yy <= 15 && xx >= 0 && xx <= LEVEL_WIDTH)
+  if (yy >= 0 && yy <= 15 && xx >= 0 && xx <= level_width)
     c = tiles[yy][xx];
   else
     c = '.';
@@ -2970,7 +3099,7 @@ void change(int x, int y, int sx, unsigned char c)
   yy = (y / 32);
   xx = ((x + sx) / 32);
   
-  if (yy >= 0 && yy <= 15 && xx >= 0 && xx <= LEVEL_WIDTH)
+  if (yy >= 0 && yy <= 15 && xx >= 0 && xx <= level_width)
     tiles[yy][xx] = c;
 }
 
index 813a077..acde442 100644 (file)
 #define BOUNCE 1
 
 
+/* One-ups... */
+
+#define DISTROS_LIFEUP 100
+
+
 /* Dying types: */
 
 /* ---- NO 0 */