[Tux4kids-commits] r796 - in tuxmath/trunk: doc src
tholy-guest at alioth.debian.org
tholy-guest at alioth.debian.org
Thu Dec 11 12:08:14 UTC 2008
Author: tholy-guest
Date: 2008-12-11 12:08:13 +0000 (Thu, 11 Dec 2008)
New Revision: 796
Added:
tuxmath/trunk/src/fileops_media.c
tuxmath/trunk/src/globals.h
Modified:
tuxmath/trunk/doc/changelog
tuxmath/trunk/src/CMakeLists.txt
tuxmath/trunk/src/audio.c
tuxmath/trunk/src/fileops.c
tuxmath/trunk/src/fileops.h
tuxmath/trunk/src/game.h
tuxmath/trunk/src/highscore.c
tuxmath/trunk/src/highscore.h
tuxmath/trunk/src/lessons.c
tuxmath/trunk/src/lessons.h
tuxmath/trunk/src/multiplayer.c
tuxmath/trunk/src/options.c
tuxmath/trunk/src/options.h
tuxmath/trunk/src/tuxmath.h
Log:
Initial file reorganization to separate SDL-related code from more
infrastructural code. This is intended to allow us to create and
compile stand-alone programs that test specific functions (e.g.,
generating problems for specific lessons).
Modified: tuxmath/trunk/doc/changelog
===================================================================
--- tuxmath/trunk/doc/changelog 2008-12-10 23:50:23 UTC (rev 795)
+++ tuxmath/trunk/doc/changelog 2008-12-11 12:08:13 UTC (rev 796)
@@ -1,3 +1,11 @@
+2008.Dec.11 (svn.debian.org/tux4kids - revision 796)
+ Initial file reorganization to separate SDL-related code from more
+ infrastructural code. This is intended to allow us to create and
+ compile stand-alone programs that test specific functions (e.g.,
+ generating problems for specific lessons).
+
+ Tim Holy <holy at wustl.edu>
+
2008.Dec.08 (svn.debian.org/tux4kids - revision 788)
Version 1.7.0
First post-Google Summer of Code release with numerous enhancements.
Modified: tuxmath/trunk/src/CMakeLists.txt
===================================================================
--- tuxmath/trunk/src/CMakeLists.txt 2008-12-10 23:50:23 UTC (rev 795)
+++ tuxmath/trunk/src/CMakeLists.txt 2008-12-11 12:08:13 UTC (rev 796)
@@ -22,6 +22,7 @@
credits.c
factoroids.c
fileops.c
+ fileops_media.c
game.c
highscore.c
lessons.c
Modified: tuxmath/trunk/src/audio.c
===================================================================
--- tuxmath/trunk/src/audio.c 2008-12-10 23:50:23 UTC (rev 795)
+++ tuxmath/trunk/src/audio.c 2008-12-11 12:08:13 UTC (rev 796)
@@ -20,9 +20,9 @@
* *
***************************************************************************/
-//Needed for Opts_UsingSound():
-#include "options.h"
+#include "tuxmath.h"
+#include "options.h" //Needed for Opts_UsingSound()
#include "titlescreen.h"
Mix_Music *music;
Modified: tuxmath/trunk/src/fileops.c
===================================================================
--- tuxmath/trunk/src/fileops.c 2008-12-10 23:50:23 UTC (rev 795)
+++ tuxmath/trunk/src/fileops.c 2008-12-11 12:08:13 UTC (rev 796)
@@ -26,37 +26,21 @@
*
*/
-#include "config.h"
+#include <stdio.h>
+//#include "config.h"
+
/* Tuxmath includes: */
-#include "tuxmath.h"
+#include "globals.h"
#include "fileops.h"
#include "setup.h"
#include "mathcards.h"
#include "options.h"
#include "highscore.h"
#include "lessons.h"
-#include "titlescreen.h"
+//#include "titlescreen.h"
-
-
-
-
-
-
-
-
-
-/* SDL includes: */
-#include "SDL.h"
-
-#ifndef NOSOUND
-#include "SDL_mixer.h"
-#endif
-
-#include "SDL_image.h"
-
/* OS includes - NOTE: these may not be very portable */
#include <dirent.h> /* for opendir() */
#include <sys/stat.h>/* for mkdir() */
@@ -93,9 +77,6 @@
"summary10" SUMMARY_EXTENSION
};
-TTF_Font *default_font;
-TTF_Font *help_font;
-
/* local function prototypes: */
static int find_tuxmath_dir(void);
static int str_to_bool(const char* val);
@@ -2408,295 +2389,5 @@
-/*****************************************************************/
-/* Loading of data files for images and sounds. */
-/* These functions also draw some user feedback to */
-/* display the progress of the loading. */
-/*****************************************************************/
-/* returns 1 if all data files successfully loaded, 0 otherwise. */
-/* TODO load only "igloo" or "city" files, not both. */
-/* TODO get rid of files no longer used. */
-
-int load_image_data()
-{
- int i;
-
- static char* image_filenames[NUM_IMAGES] = {
- DATA_PREFIX "/images/status/standby.png",
- DATA_PREFIX "/images/title/menu_bkg.jpg",
- DATA_PREFIX "/images/title/title1.png",
- DATA_PREFIX "/images/status/title.png",
- DATA_PREFIX "/images/status/left.png",
- DATA_PREFIX "/images/status/left_gray.png",
- DATA_PREFIX "/images/status/right.png",
- DATA_PREFIX "/images/status/right_gray.png",
- DATA_PREFIX "/images/status/tux4kids.png",
- DATA_PREFIX "/images/status/nbs.png",
- DATA_PREFIX "/images/cities/city-blue.png",
- DATA_PREFIX "/images/cities/csplode-blue-1.png",
- DATA_PREFIX "/images/cities/csplode-blue-2.png",
- DATA_PREFIX "/images/cities/csplode-blue-3.png",
- DATA_PREFIX "/images/cities/csplode-blue-4.png",
- DATA_PREFIX "/images/cities/csplode-blue-5.png",
- DATA_PREFIX "/images/cities/cdead-blue.png",
- DATA_PREFIX "/images/cities/city-green.png",
- DATA_PREFIX "/images/cities/csplode-green-1.png",
- DATA_PREFIX "/images/cities/csplode-green-2.png",
- DATA_PREFIX "/images/cities/csplode-green-3.png",
- DATA_PREFIX "/images/cities/csplode-green-4.png",
- DATA_PREFIX "/images/cities/csplode-green-5.png",
- DATA_PREFIX "/images/cities/cdead-green.png",
- DATA_PREFIX "/images/cities/city-orange.png",
- DATA_PREFIX "/images/cities/csplode-orange-1.png",
- DATA_PREFIX "/images/cities/csplode-orange-2.png",
- DATA_PREFIX "/images/cities/csplode-orange-3.png",
- DATA_PREFIX "/images/cities/csplode-orange-4.png",
- DATA_PREFIX "/images/cities/csplode-orange-5.png",
- DATA_PREFIX "/images/cities/cdead-orange.png",
- DATA_PREFIX "/images/cities/city-red.png",
- DATA_PREFIX "/images/cities/csplode-red-1.png",
- DATA_PREFIX "/images/cities/csplode-red-2.png",
- DATA_PREFIX "/images/cities/csplode-red-3.png",
- DATA_PREFIX "/images/cities/csplode-red-4.png",
- DATA_PREFIX "/images/cities/csplode-red-5.png",
- DATA_PREFIX "/images/cities/cdead-red.png",
- DATA_PREFIX "/images/cities/shields.png",
- DATA_PREFIX "/images/comets/comet1.png",
- DATA_PREFIX "/images/comets/comet2.png",
- DATA_PREFIX "/images/comets/comet3.png",
- DATA_PREFIX "/images/comets/cometex3.png",
- DATA_PREFIX "/images/comets/cometex3.png",
- DATA_PREFIX "/images/comets/cometex2.png",
- DATA_PREFIX "/images/comets/cometex2.png",
- DATA_PREFIX "/images/comets/cometex1a.png",
- DATA_PREFIX "/images/comets/cometex1a.png",
- DATA_PREFIX "/images/comets/cometex1.png",
- DATA_PREFIX "/images/comets/cometex1.png",
- DATA_PREFIX "/images/comets/mini_comet1.png",
- DATA_PREFIX "/images/comets/mini_comet2.png",
- DATA_PREFIX "/images/comets/mini_comet3.png",
- DATA_PREFIX "/images/comets/bonus_comet1.png",
- DATA_PREFIX "/images/comets/bonus_comet2.png",
- DATA_PREFIX "/images/comets/bonus_comet3.png",
- DATA_PREFIX "/images/comets/bonus_cometex3.png",
- DATA_PREFIX "/images/comets/bonus_cometex3.png",
- DATA_PREFIX "/images/comets/bonus_cometex2.png",
- DATA_PREFIX "/images/comets/bonus_cometex2.png",
- DATA_PREFIX "/images/comets/bonus_cometex1a.png",
- DATA_PREFIX "/images/comets/bonus_cometex1a.png",
- DATA_PREFIX "/images/comets/bonus_cometex1.png",
- DATA_PREFIX "/images/comets/bonus_cometex1.png",
- DATA_PREFIX "/images/status/nums.png",
- DATA_PREFIX "/images/status/lednums.png",
- DATA_PREFIX "/images/status/led_neg_sign.png",
- DATA_PREFIX "/images/status/paused.png",
- DATA_PREFIX "/images/status/demo.png",
- DATA_PREFIX "/images/status/demo-small.png",
- DATA_PREFIX "/images/status/keypad.png",
- DATA_PREFIX "/images/status/keypad_no_neg.png",
- DATA_PREFIX "/images/tux/console_led.png",
- DATA_PREFIX "/images/tux/console_bash.png",
- DATA_PREFIX "/images/tux/tux-console1.png",
- DATA_PREFIX "/images/tux/tux-console2.png",
- DATA_PREFIX "/images/tux/tux-console3.png",
- DATA_PREFIX "/images/tux/tux-console4.png",
- DATA_PREFIX "/images/tux/tux-relax1.png",
- DATA_PREFIX "/images/tux/tux-relax2.png",
- DATA_PREFIX "/images/tux/tux-egypt1.png",
- DATA_PREFIX "/images/tux/tux-egypt2.png",
- DATA_PREFIX "/images/tux/tux-egypt3.png",
- DATA_PREFIX "/images/tux/tux-egypt4.png",
- DATA_PREFIX "/images/tux/tux-drat.png",
- DATA_PREFIX "/images/tux/tux-yipe.png",
- DATA_PREFIX "/images/tux/tux-yay1.png",
- DATA_PREFIX "/images/tux/tux-yay2.png",
- DATA_PREFIX "/images/tux/tux-yes1.png",
- DATA_PREFIX "/images/tux/tux-yes2.png",
- DATA_PREFIX "/images/tux/tux-sit.png",
- DATA_PREFIX "/images/tux/tux-fist1.png",
- DATA_PREFIX "/images/tux/tux-fist2.png",
- DATA_PREFIX "/images/penguins/flapdown.png",
- DATA_PREFIX "/images/penguins/flapup.png",
- DATA_PREFIX "/images/penguins/incoming.png",
- DATA_PREFIX "/images/penguins/grumpy.png",
- DATA_PREFIX "/images/penguins/worried.png",
- DATA_PREFIX "/images/penguins/standing-up.png",
- DATA_PREFIX "/images/penguins/sitting-down.png",
- DATA_PREFIX "/images/penguins/walk-on1.png",
- DATA_PREFIX "/images/penguins/walk-on2.png",
- DATA_PREFIX "/images/penguins/walk-on3.png",
- DATA_PREFIX "/images/penguins/walk-off1.png",
- DATA_PREFIX "/images/penguins/walk-off2.png",
- DATA_PREFIX "/images/penguins/walk-off3.png",
- DATA_PREFIX "/images/igloos/melted3.png",
- DATA_PREFIX "/images/igloos/melted2.png",
- DATA_PREFIX "/images/igloos/melted1.png",
- DATA_PREFIX "/images/igloos/half.png",
- DATA_PREFIX "/images/igloos/intact.png",
- DATA_PREFIX "/images/igloos/rebuilding1.png",
- DATA_PREFIX "/images/igloos/rebuilding2.png",
- DATA_PREFIX "/images/igloos/steam1.png",
- DATA_PREFIX "/images/igloos/steam2.png",
- DATA_PREFIX "/images/igloos/steam3.png",
- DATA_PREFIX "/images/igloos/steam4.png",
- DATA_PREFIX "/images/igloos/steam5.png",
- DATA_PREFIX "/images/igloos/cloud.png",
- DATA_PREFIX "/images/igloos/snow1.png",
- DATA_PREFIX "/images/igloos/snow2.png",
- DATA_PREFIX "/images/igloos/snow3.png",
- DATA_PREFIX "/images/igloos/extra_life.png",
- DATA_PREFIX "/images/status/wave.png",
- DATA_PREFIX "/images/status/score.png",
- DATA_PREFIX "/images/status/stop.png",
- DATA_PREFIX "/images/status/numbers.png",
- DATA_PREFIX "/images/status/gameover.png",
- DATA_PREFIX "/images/status/gameover_won.png",
- DATA_PREFIX "/images/factoroids/gbstars.png",
- DATA_PREFIX "/images/factoroids/asteroid1.png",
- DATA_PREFIX "/images/factoroids/asteroid2.png",
- DATA_PREFIX "/images/factoroids/asteroid3.png",
- DATA_PREFIX "/images/factoroids/ship01.png",
- DATA_PREFIX "/images/factoroids/factoroids.png",
- DATA_PREFIX "/images/factoroids/factors.png",
- DATA_PREFIX "/images/factoroids/tux.png",
- DATA_PREFIX "/images/factoroids/good.png"
- };
-
- /* Load images: */
- for (i = 0; i < NUM_IMAGES; i++)
- {
- images[i] = IMG_Load(image_filenames[i]);
-
- if (images[i] == NULL)
- {
- fprintf(stderr,
- "\nError: I couldn't load a graphics file:\n"
- "%s\n"
- "The Simple DirectMedia error that occured was:\n"
- "%s\n\n", image_filenames[i], SDL_GetError());
- return 0;
- }
- }
- /* If we make it to here OK, return 1: */
- return 1;
-}
-
-/* returns 1 if default font successfully loaded, 0 otherwise. */
-int load_default_font()
-{
- default_font = LoadFont( DEFAULT_FONT_NAME,
- DEFAULT_MENU_FONT_SIZE);
- help_font = LoadFont( DEFAULT_FONT_NAME,
- DEFAULT_HELP_FONT_SIZE);
-
- if (default_font && help_font)
- {
-#ifdef TUXMATH_DEBUG
- fprintf(stderr, "load_default_font(): %s loaded successfully\n\n",
- DEFAULT_FONT_NAME);
-#endif
- return 1;
- }
- else
- {
- fprintf(stderr, "LoadFont(): %s NOT loaded successfully. TTF: %s\n",
- DEFAULT_FONT_NAME, TTF_GetError() );
- return 0;
- }
-}
-
-
-
-
-#ifndef NOSOUND
-int load_sound_data(void)
-{
- int total_files, i;
-
- SDL_Rect dest;
-
- static char* sound_filenames[NUM_SOUNDS] = {
- DATA_PREFIX "/sounds/pop.wav",
- DATA_PREFIX "/sounds/tock.wav",
- DATA_PREFIX "/sounds/laser.wav",
- DATA_PREFIX "/sounds/buzz.wav",
- DATA_PREFIX "/sounds/alarm.wav",
- DATA_PREFIX "/sounds/shieldsdown.wav",
- DATA_PREFIX "/sounds/explosion.wav",
- DATA_PREFIX "/sounds/click.wav",
- DATA_PREFIX "/sounds/sizzling.wav",
- DATA_PREFIX "/sounds/towerclock.wav",
- DATA_PREFIX "/sounds/cheer.wav"
- };
-
- static char* music_filenames[NUM_MUSICS] = {
- DATA_PREFIX "/sounds/game.mod",
- DATA_PREFIX "/sounds/game2.mod",
- DATA_PREFIX "/sounds/game3.mod"
- };
-
- /* skip loading sound files if sound system not available: */
- if (Opts_UsingSound())
- {
- total_files = NUM_IMAGES + NUM_SOUNDS + NUM_MUSICS;
-
- for (i = 0; i < NUM_SOUNDS; i++)
- {
- sounds[i] = Mix_LoadWAV(sound_filenames[i]);
-
- if (sounds[i] == NULL)
- {
- fprintf(stderr,
- "\nError: I couldn't load a sound file:\n"
- "%s\n"
- "The Simple DirectMedia error that occured was:\n"
- "%s\n\n", sound_filenames[i], SDL_GetError());
- return 0;
- }
-
-
- dest.x = 0;
- dest.y = (screen->h) - 10;
- dest.w = ((screen->w) * (i + 1 + NUM_IMAGES)) / total_files;
- dest.h = 10;
-
- SDL_FillRect(screen, &dest, SDL_MapRGB(screen->format, 0, 255, 0));
- SDL_UpdateRect(screen, dest.x, dest.y, dest.w, dest.h);
-
- }
-
-
- for (i = 0; i < NUM_MUSICS; i++)
- {
- musics[i] = Mix_LoadMUS(music_filenames[i]);
-
- if (musics[i] == NULL)
- {
- fprintf(stderr,
- "\nError: I couldn't load a music file:\n"
- "%s\n"
- "The Simple DirectMedia error that occured was:\n"
- "%s\n\n", music_filenames[i], SDL_GetError());
- return 0;
- }
-
- if (i == NUM_MUSICS - 1)
- {
- dest.x = 0;
- dest.y = (screen->h) - 10;
- dest.w = ((screen->w) * (i + 1 + NUM_IMAGES + NUM_SOUNDS)) / total_files;
- dest.h = 10;
-
- SDL_FillRect(screen, &dest, SDL_MapRGB(screen->format, 0, 255, 0));
- SDL_UpdateRect(screen, dest.x, dest.y, dest.w, dest.h);
- }
- }
- }
- return 1;
-}
-#endif
-
-
-
Modified: tuxmath/trunk/src/fileops.h
===================================================================
--- tuxmath/trunk/src/fileops.h 2008-12-10 23:50:23 UTC (rev 795)
+++ tuxmath/trunk/src/fileops.h 2008-12-11 12:08:13 UTC (rev 796)
@@ -16,7 +16,7 @@
#ifndef FILEOPS_H
#define FILEOPS_H
-#include "tuxmath.h"
+#include "globals.h"
/* Flag basically telling whether or not to allow admin-level */
/* settings to be changed: */
Added: tuxmath/trunk/src/fileops_media.c
===================================================================
--- tuxmath/trunk/src/fileops_media.c (rev 0)
+++ tuxmath/trunk/src/fileops_media.c 2008-12-11 12:08:13 UTC (rev 796)
@@ -0,0 +1,297 @@
+#include "tuxmath.h"
+#include "fileops.h"
+
+TTF_Font *default_font;
+TTF_Font *help_font;
+
+
+/*****************************************************************/
+/* Loading of data files for images and sounds. */
+/* These functions also draw some user feedback to */
+/* display the progress of the loading. */
+/*****************************************************************/
+
+/* returns 1 if all data files successfully loaded, 0 otherwise. */
+
+/* TODO load only "igloo" or "city" files, not both. */
+/* TODO get rid of files no longer used. */
+
+int load_image_data()
+{
+ int i;
+
+ static char* image_filenames[NUM_IMAGES] = {
+ DATA_PREFIX "/images/status/standby.png",
+ DATA_PREFIX "/images/title/menu_bkg.jpg",
+ DATA_PREFIX "/images/title/title1.png",
+ DATA_PREFIX "/images/status/title.png",
+ DATA_PREFIX "/images/status/left.png",
+ DATA_PREFIX "/images/status/left_gray.png",
+ DATA_PREFIX "/images/status/right.png",
+ DATA_PREFIX "/images/status/right_gray.png",
+ DATA_PREFIX "/images/status/tux4kids.png",
+ DATA_PREFIX "/images/status/nbs.png",
+ DATA_PREFIX "/images/cities/city-blue.png",
+ DATA_PREFIX "/images/cities/csplode-blue-1.png",
+ DATA_PREFIX "/images/cities/csplode-blue-2.png",
+ DATA_PREFIX "/images/cities/csplode-blue-3.png",
+ DATA_PREFIX "/images/cities/csplode-blue-4.png",
+ DATA_PREFIX "/images/cities/csplode-blue-5.png",
+ DATA_PREFIX "/images/cities/cdead-blue.png",
+ DATA_PREFIX "/images/cities/city-green.png",
+ DATA_PREFIX "/images/cities/csplode-green-1.png",
+ DATA_PREFIX "/images/cities/csplode-green-2.png",
+ DATA_PREFIX "/images/cities/csplode-green-3.png",
+ DATA_PREFIX "/images/cities/csplode-green-4.png",
+ DATA_PREFIX "/images/cities/csplode-green-5.png",
+ DATA_PREFIX "/images/cities/cdead-green.png",
+ DATA_PREFIX "/images/cities/city-orange.png",
+ DATA_PREFIX "/images/cities/csplode-orange-1.png",
+ DATA_PREFIX "/images/cities/csplode-orange-2.png",
+ DATA_PREFIX "/images/cities/csplode-orange-3.png",
+ DATA_PREFIX "/images/cities/csplode-orange-4.png",
+ DATA_PREFIX "/images/cities/csplode-orange-5.png",
+ DATA_PREFIX "/images/cities/cdead-orange.png",
+ DATA_PREFIX "/images/cities/city-red.png",
+ DATA_PREFIX "/images/cities/csplode-red-1.png",
+ DATA_PREFIX "/images/cities/csplode-red-2.png",
+ DATA_PREFIX "/images/cities/csplode-red-3.png",
+ DATA_PREFIX "/images/cities/csplode-red-4.png",
+ DATA_PREFIX "/images/cities/csplode-red-5.png",
+ DATA_PREFIX "/images/cities/cdead-red.png",
+ DATA_PREFIX "/images/cities/shields.png",
+ DATA_PREFIX "/images/comets/comet1.png",
+ DATA_PREFIX "/images/comets/comet2.png",
+ DATA_PREFIX "/images/comets/comet3.png",
+ DATA_PREFIX "/images/comets/cometex3.png",
+ DATA_PREFIX "/images/comets/cometex3.png",
+ DATA_PREFIX "/images/comets/cometex2.png",
+ DATA_PREFIX "/images/comets/cometex2.png",
+ DATA_PREFIX "/images/comets/cometex1a.png",
+ DATA_PREFIX "/images/comets/cometex1a.png",
+ DATA_PREFIX "/images/comets/cometex1.png",
+ DATA_PREFIX "/images/comets/cometex1.png",
+ DATA_PREFIX "/images/comets/mini_comet1.png",
+ DATA_PREFIX "/images/comets/mini_comet2.png",
+ DATA_PREFIX "/images/comets/mini_comet3.png",
+ DATA_PREFIX "/images/comets/bonus_comet1.png",
+ DATA_PREFIX "/images/comets/bonus_comet2.png",
+ DATA_PREFIX "/images/comets/bonus_comet3.png",
+ DATA_PREFIX "/images/comets/bonus_cometex3.png",
+ DATA_PREFIX "/images/comets/bonus_cometex3.png",
+ DATA_PREFIX "/images/comets/bonus_cometex2.png",
+ DATA_PREFIX "/images/comets/bonus_cometex2.png",
+ DATA_PREFIX "/images/comets/bonus_cometex1a.png",
+ DATA_PREFIX "/images/comets/bonus_cometex1a.png",
+ DATA_PREFIX "/images/comets/bonus_cometex1.png",
+ DATA_PREFIX "/images/comets/bonus_cometex1.png",
+ DATA_PREFIX "/images/status/nums.png",
+ DATA_PREFIX "/images/status/lednums.png",
+ DATA_PREFIX "/images/status/led_neg_sign.png",
+ DATA_PREFIX "/images/status/paused.png",
+ DATA_PREFIX "/images/status/demo.png",
+ DATA_PREFIX "/images/status/demo-small.png",
+ DATA_PREFIX "/images/status/keypad.png",
+ DATA_PREFIX "/images/status/keypad_no_neg.png",
+ DATA_PREFIX "/images/tux/console_led.png",
+ DATA_PREFIX "/images/tux/console_bash.png",
+ DATA_PREFIX "/images/tux/tux-console1.png",
+ DATA_PREFIX "/images/tux/tux-console2.png",
+ DATA_PREFIX "/images/tux/tux-console3.png",
+ DATA_PREFIX "/images/tux/tux-console4.png",
+ DATA_PREFIX "/images/tux/tux-relax1.png",
+ DATA_PREFIX "/images/tux/tux-relax2.png",
+ DATA_PREFIX "/images/tux/tux-egypt1.png",
+ DATA_PREFIX "/images/tux/tux-egypt2.png",
+ DATA_PREFIX "/images/tux/tux-egypt3.png",
+ DATA_PREFIX "/images/tux/tux-egypt4.png",
+ DATA_PREFIX "/images/tux/tux-drat.png",
+ DATA_PREFIX "/images/tux/tux-yipe.png",
+ DATA_PREFIX "/images/tux/tux-yay1.png",
+ DATA_PREFIX "/images/tux/tux-yay2.png",
+ DATA_PREFIX "/images/tux/tux-yes1.png",
+ DATA_PREFIX "/images/tux/tux-yes2.png",
+ DATA_PREFIX "/images/tux/tux-sit.png",
+ DATA_PREFIX "/images/tux/tux-fist1.png",
+ DATA_PREFIX "/images/tux/tux-fist2.png",
+ DATA_PREFIX "/images/penguins/flapdown.png",
+ DATA_PREFIX "/images/penguins/flapup.png",
+ DATA_PREFIX "/images/penguins/incoming.png",
+ DATA_PREFIX "/images/penguins/grumpy.png",
+ DATA_PREFIX "/images/penguins/worried.png",
+ DATA_PREFIX "/images/penguins/standing-up.png",
+ DATA_PREFIX "/images/penguins/sitting-down.png",
+ DATA_PREFIX "/images/penguins/walk-on1.png",
+ DATA_PREFIX "/images/penguins/walk-on2.png",
+ DATA_PREFIX "/images/penguins/walk-on3.png",
+ DATA_PREFIX "/images/penguins/walk-off1.png",
+ DATA_PREFIX "/images/penguins/walk-off2.png",
+ DATA_PREFIX "/images/penguins/walk-off3.png",
+ DATA_PREFIX "/images/igloos/melted3.png",
+ DATA_PREFIX "/images/igloos/melted2.png",
+ DATA_PREFIX "/images/igloos/melted1.png",
+ DATA_PREFIX "/images/igloos/half.png",
+ DATA_PREFIX "/images/igloos/intact.png",
+ DATA_PREFIX "/images/igloos/rebuilding1.png",
+ DATA_PREFIX "/images/igloos/rebuilding2.png",
+ DATA_PREFIX "/images/igloos/steam1.png",
+ DATA_PREFIX "/images/igloos/steam2.png",
+ DATA_PREFIX "/images/igloos/steam3.png",
+ DATA_PREFIX "/images/igloos/steam4.png",
+ DATA_PREFIX "/images/igloos/steam5.png",
+ DATA_PREFIX "/images/igloos/cloud.png",
+ DATA_PREFIX "/images/igloos/snow1.png",
+ DATA_PREFIX "/images/igloos/snow2.png",
+ DATA_PREFIX "/images/igloos/snow3.png",
+ DATA_PREFIX "/images/igloos/extra_life.png",
+ DATA_PREFIX "/images/status/wave.png",
+ DATA_PREFIX "/images/status/score.png",
+ DATA_PREFIX "/images/status/stop.png",
+ DATA_PREFIX "/images/status/numbers.png",
+ DATA_PREFIX "/images/status/gameover.png",
+ DATA_PREFIX "/images/status/gameover_won.png",
+ DATA_PREFIX "/images/factoroids/gbstars.png",
+ DATA_PREFIX "/images/factoroids/asteroid1.png",
+ DATA_PREFIX "/images/factoroids/asteroid2.png",
+ DATA_PREFIX "/images/factoroids/asteroid3.png",
+ DATA_PREFIX "/images/factoroids/ship01.png",
+ DATA_PREFIX "/images/factoroids/factoroids.png",
+ DATA_PREFIX "/images/factoroids/factors.png",
+ DATA_PREFIX "/images/factoroids/tux.png",
+ DATA_PREFIX "/images/factoroids/good.png"
+ };
+
+ /* Load images: */
+ for (i = 0; i < NUM_IMAGES; i++)
+ {
+ images[i] = IMG_Load(image_filenames[i]);
+
+ if (images[i] == NULL)
+ {
+ fprintf(stderr,
+ "\nError: I couldn't load a graphics file:\n"
+ "%s\n"
+ "The Simple DirectMedia error that occured was:\n"
+ "%s\n\n", image_filenames[i], SDL_GetError());
+ return 0;
+ }
+ }
+ /* If we make it to here OK, return 1: */
+ return 1;
+}
+
+/* returns 1 if default font successfully loaded, 0 otherwise. */
+int load_default_font()
+{
+ default_font = LoadFont( DEFAULT_FONT_NAME,
+ DEFAULT_MENU_FONT_SIZE);
+ help_font = LoadFont( DEFAULT_FONT_NAME,
+ DEFAULT_HELP_FONT_SIZE);
+
+ if (default_font && help_font)
+ {
+#ifdef TUXMATH_DEBUG
+ fprintf(stderr, "load_default_font(): %s loaded successfully\n\n",
+ DEFAULT_FONT_NAME);
+#endif
+ return 1;
+ }
+ else
+ {
+ fprintf(stderr, "LoadFont(): %s NOT loaded successfully. TTF: %s\n",
+ DEFAULT_FONT_NAME, TTF_GetError() );
+ return 0;
+ }
+}
+
+
+
+
+#ifndef NOSOUND
+int load_sound_data(void)
+{
+ int total_files, i;
+
+ SDL_Rect dest;
+
+ static char* sound_filenames[NUM_SOUNDS] = {
+ DATA_PREFIX "/sounds/pop.wav",
+ DATA_PREFIX "/sounds/tock.wav",
+ DATA_PREFIX "/sounds/laser.wav",
+ DATA_PREFIX "/sounds/buzz.wav",
+ DATA_PREFIX "/sounds/alarm.wav",
+ DATA_PREFIX "/sounds/shieldsdown.wav",
+ DATA_PREFIX "/sounds/explosion.wav",
+ DATA_PREFIX "/sounds/click.wav",
+ DATA_PREFIX "/sounds/sizzling.wav",
+ DATA_PREFIX "/sounds/towerclock.wav",
+ DATA_PREFIX "/sounds/cheer.wav"
+ };
+
+ static char* music_filenames[NUM_MUSICS] = {
+ DATA_PREFIX "/sounds/game.mod",
+ DATA_PREFIX "/sounds/game2.mod",
+ DATA_PREFIX "/sounds/game3.mod"
+ };
+
+ /* skip loading sound files if sound system not available: */
+ if (Opts_UsingSound())
+ {
+ total_files = NUM_IMAGES + NUM_SOUNDS + NUM_MUSICS;
+
+ for (i = 0; i < NUM_SOUNDS; i++)
+ {
+ sounds[i] = Mix_LoadWAV(sound_filenames[i]);
+
+ if (sounds[i] == NULL)
+ {
+ fprintf(stderr,
+ "\nError: I couldn't load a sound file:\n"
+ "%s\n"
+ "The Simple DirectMedia error that occured was:\n"
+ "%s\n\n", sound_filenames[i], SDL_GetError());
+ return 0;
+ }
+
+
+ dest.x = 0;
+ dest.y = (screen->h) - 10;
+ dest.w = ((screen->w) * (i + 1 + NUM_IMAGES)) / total_files;
+ dest.h = 10;
+
+ SDL_FillRect(screen, &dest, SDL_MapRGB(screen->format, 0, 255, 0));
+ SDL_UpdateRect(screen, dest.x, dest.y, dest.w, dest.h);
+
+ }
+
+
+ for (i = 0; i < NUM_MUSICS; i++)
+ {
+ musics[i] = Mix_LoadMUS(music_filenames[i]);
+
+ if (musics[i] == NULL)
+ {
+ fprintf(stderr,
+ "\nError: I couldn't load a music file:\n"
+ "%s\n"
+ "The Simple DirectMedia error that occured was:\n"
+ "%s\n\n", music_filenames[i], SDL_GetError());
+ return 0;
+ }
+
+ if (i == NUM_MUSICS - 1)
+ {
+ dest.x = 0;
+ dest.y = (screen->h) - 10;
+ dest.w = ((screen->w) * (i + 1 + NUM_IMAGES + NUM_SOUNDS)) / total_files;
+ dest.h = 10;
+
+ SDL_FillRect(screen, &dest, SDL_MapRGB(screen->format, 0, 255, 0));
+ SDL_UpdateRect(screen, dest.x, dest.y, dest.w, dest.h);
+ }
+ }
+ }
+ return 1;
+}
+
+#endif /* NOSOUND */
Modified: tuxmath/trunk/src/game.h
===================================================================
--- tuxmath/trunk/src/game.h 2008-12-10 23:50:23 UTC (rev 795)
+++ tuxmath/trunk/src/game.h 2008-12-11 12:08:13 UTC (rev 796)
@@ -144,7 +144,7 @@
/*used in factoroids.c/h*/
int pause_game(void);
-void putpixel(SDL_Surface* surface, int x, int y, Uint32 pixel);
+//void putpixel(SDL_Surface* surface, int x, int y, Uint32 pixel);
void draw_line(int x1, int y1, int x2, int y2, int r, int g, int b);
void draw_numbers(const char* str, int x, int y);
Added: tuxmath/trunk/src/globals.h
===================================================================
--- tuxmath/trunk/src/globals.h (rev 0)
+++ tuxmath/trunk/src/globals.h 2008-12-11 12:08:13 UTC (rev 796)
@@ -0,0 +1,131 @@
+/*
+ globals.h
+
+ For TuxMath
+
+ Contains global data for configuration of math questions and for
+ general game options, as well as constants and defaults. Nothing
+ depending on SDL should be in here; put any SDL-related items into
+ tuxmath.h.
+
+ Author: David Bruce <dbruce at tampabay.rr.com>, (C) 2006
+
+
+ Part of "Tux4Kids" Project
+ http://www.tux4kids.org/
+
+ Added March 2, 2006
+
+ Copyright: See COPYING file that comes with this distribution
+ (briefly - GNU GPL v2 or later)
+*/
+
+
+
+#ifndef GLOBALS_H
+#define GLOBALS_H
+
+/* for conditional compilation of debugging output */
+#define TUXMATH_DEBUG
+/* for Tim's feedback speed control code */
+//#define FEEDBACK_DEBUG
+/* nice inline debugging macro */
+#ifdef TUXMATH_DEBUG
+#define tmdprintf(...) printf(__VA_ARGS__)
+#else
+#define tmdprintf(...) 0
+#endif
+
+/* Maximum length of file path: */
+#define PATH_MAX 4096
+
+/* Error code if game_options not valid: */
+#define GAME_OPTS_INVALID 9999
+
+/* Default values for game_options */
+/* They can be changed in the struct to other values at run-time */
+#define DEFAULT_PER_USER_CONFIG 1
+#define DEFAULT_USE_SOUND 1
+#define DEFAULT_MENU_SOUND 1
+#define DEFAULT_MENU_MUSIC 1
+#define DEFAULT_FULLSCREEN 1
+#define DEFAULT_USE_BKGD 1
+#define DEFAULT_HELP_MODE 0
+#define DEFAULT_DEMO_MODE 0
+#define DEFAULT_OPER_OVERRIDE 0
+#define DEFAULT_USE_KEYPAD 0
+#define DEFAULT_ALLOW_PAUSE 1
+#define DEFAULT_BONUS_SPEED_RATIO 1.5
+#define DEFAULT_BONUS_COMET_INTERVAL 10
+#define DEFAULT_SPEED 1
+#define DEFAULT_ALLOW_SPEEDUP 1
+#define DEFAULT_SPEEDUP_FACTOR 1.2
+#define DEFAULT_MAX_SPEED 10
+#define DEFAULT_SLOW_AFTER_WRONG 0
+#define DEFAULT_STARTING_COMETS 2
+#define DEFAULT_EXTRA_COMETS_PER_WAVE 2
+#define DEFAULT_MAX_COMETS 10
+#define DEFAULT_SAVE_SUMMARY 1
+#define DEFAULT_SOUND_HW_AVAILABLE 1
+#define DEFAULT_USE_IGLOOS 1
+#define DEFAULT_USE_FEEDBACK 0
+#define DEFAULT_DANGER_LEVEL 0.35
+#define DEFAULT_DANGER_LEVEL_SPEEDUP 1.1
+#define DEFAULT_DANGER_LEVEL_MAX 0.9
+#define DEFAULT_CITY_EXPL_HANDICAP 0
+#define DEFAULT_LAST_SCORE 0
+
+/* These values are hard-coded and used 'as is' by the program */
+/* (i.e. these behaviors require recompilation to change) */
+#define DEFAULT_NUM_CITIES 4 /* MUST BE AN EVEN NUMBER! */
+#define DEFAULT_MAX_CITY_COLORS 4
+
+#define MINIMUM_SPEED 0.8
+#define MAX_MAX_SPEED 20.0
+#define MIN_SPEEDUP_FACTOR 1.0
+#define MAX_SPEEDUP_FACTOR 2.0
+#define MAX_BONUS_SPEED_RATIO 3.0
+#define MIN_COMETS 1
+#define MAX_MAX_COMETS 100
+
+#define DEFAULT_FONT_NAME "AndikaDesRevG.ttf"
+#define DEFAULT_MENU_FONT_SIZE 18
+#define DEFAULT_HELP_FONT_SIZE 32
+
+
+#define HIGH_SCORES_SAVED 10
+#define HIGH_SCORE_NAME_LENGTH 32
+
+#define REG_RGBA 16,16,96,96
+#define SEL_RGBA 16,16,128,128
+
+#define RES_X 640
+#define RES_Y 480
+#define PIXEL_BITS 32
+
+enum {
+ CADET_HIGH_SCORE,
+ SCOUT_HIGH_SCORE,
+ RANGER_HIGH_SCORE,
+ ACE_HIGH_SCORE,
+ COMMANDO_HIGH_SCORE,
+ NUM_MATH_COMMAND_LEVELS
+};
+
+enum {
+ FACTORS_HIGH_SCORE = NUM_MATH_COMMAND_LEVELS,
+ FRACTIONS_HIGH_SCORE,
+ NUM_HIGH_SCORE_LEVELS
+};
+
+
+
+#define NAME_BUF_SIZE 200
+
+/* data for 'Training Academy' lessons: */
+extern char **lesson_list_titles;
+extern char **lesson_list_filenames;
+extern int* lesson_list_goldstars;
+extern int num_lessons;
+
+#endif
Modified: tuxmath/trunk/src/highscore.c
===================================================================
--- tuxmath/trunk/src/highscore.c 2008-12-10 23:50:23 UTC (rev 795)
+++ tuxmath/trunk/src/highscore.c 2008-12-11 12:08:13 UTC (rev 796)
@@ -11,9 +11,9 @@
*/
#include <string.h>
+#include "tuxmath.h"
#include "highscore.h"
#include "titlescreen.h"
-#include "tuxmath.h"
#include "fileops.h"
#include "setup.h"
#include "options.h"
Modified: tuxmath/trunk/src/highscore.h
===================================================================
--- tuxmath/trunk/src/highscore.h 2008-12-10 23:50:23 UTC (rev 795)
+++ tuxmath/trunk/src/highscore.h 2008-12-11 12:08:13 UTC (rev 796)
@@ -14,7 +14,7 @@
#define HIGHSCORE_H
-#include "tuxmath.h"
+#include "globals.h"
void DisplayHighScores(int level);
void HighScoreNameEntry(char* pl_name);
Modified: tuxmath/trunk/src/lessons.c
===================================================================
--- tuxmath/trunk/src/lessons.c 2008-12-10 23:50:23 UTC (rev 795)
+++ tuxmath/trunk/src/lessons.c 2008-12-11 12:08:13 UTC (rev 796)
@@ -9,6 +9,7 @@
* Copyright: See COPYING file that comes with this distribution
*
*/
+#include <stdio.h>
#include "lessons.h"
// extern unsigned char **lesson_list_titles;
Modified: tuxmath/trunk/src/lessons.h
===================================================================
--- tuxmath/trunk/src/lessons.h 2008-12-10 23:50:23 UTC (rev 795)
+++ tuxmath/trunk/src/lessons.h 2008-12-11 12:08:13 UTC (rev 796)
@@ -13,7 +13,7 @@
#ifndef LESSONS_H
#define LESSONS_H
-#include "tuxmath.h"
+#include "globals.h"
int read_goldstars_fp(FILE* fp);
void write_goldstars_fp(FILE* fp);
Modified: tuxmath/trunk/src/multiplayer.c
===================================================================
--- tuxmath/trunk/src/multiplayer.c 2008-12-10 23:50:23 UTC (rev 795)
+++ tuxmath/trunk/src/multiplayer.c 2008-12-11 12:08:13 UTC (rev 796)
@@ -8,7 +8,7 @@
*/
-#include "SDL.h"
+#include "tuxmath.h"
#include "SDL_extras.h"
#include "multiplayer.h"
#include "game.h"
Modified: tuxmath/trunk/src/options.c
===================================================================
--- tuxmath/trunk/src/options.c 2008-12-10 23:50:23 UTC (rev 795)
+++ tuxmath/trunk/src/options.c 2008-12-11 12:08:13 UTC (rev 796)
@@ -22,7 +22,7 @@
#include <stdlib.h>
#include <string.h>
-#include "SDL.h"
+//#include "SDL.h"
#include "mathcards.h"
@@ -30,7 +30,7 @@
#include "fileops.h"
#include "setup.h"
#include "game.h"
-#include "tuxmath.h"
+//#include "tuxmath.h"
/* FIXME figure out what oper_override is supposed to do and make sure */
/* this file behaves accordingly! */
Modified: tuxmath/trunk/src/options.h
===================================================================
--- tuxmath/trunk/src/options.h 2008-12-10 23:50:23 UTC (rev 795)
+++ tuxmath/trunk/src/options.h 2008-12-11 12:08:13 UTC (rev 796)
@@ -22,7 +22,7 @@
#ifndef OPTIONS_H
#define OPTIONS_H
-#include "tuxmath.h" /* needed for PATH_MAX definition */
+#include "globals.h" /* needed for PATH_MAX definition */
enum {
PER_USER_CONFIG,
Modified: tuxmath/trunk/src/tuxmath.h
===================================================================
--- tuxmath/trunk/src/tuxmath.h 2008-12-10 23:50:23 UTC (rev 795)
+++ tuxmath/trunk/src/tuxmath.h 2008-12-11 12:08:13 UTC (rev 796)
@@ -42,101 +42,12 @@
#endif
//#define NOSOUND
-/* for conditional compilation of debugging output */
-//#define TUXMATH_DEBUG
-/* for Tim's feedback speed control code */
-//#define FEEDBACK_DEBUG
-/* nice inline debugging macro */
-#ifdef TUXMATH_DEBUG
-#define tmdprintf(...) printf(__VA_ARGS__)
-#else
-#define tmdprintf(...) 0
+
+#ifndef GLOBALS_H
+#include "globals.h"
#endif
-/* Maximum length of file path: */
-#define PATH_MAX 4096
-/* Error code if game_options not valid: */
-#define GAME_OPTS_INVALID 9999
-
-/* Default values for game_options */
-/* They can be changed in the struct to other values at run-time */
-#define DEFAULT_PER_USER_CONFIG 1
-#define DEFAULT_USE_SOUND 1
-#define DEFAULT_MENU_SOUND 1
-#define DEFAULT_MENU_MUSIC 1
-#define DEFAULT_FULLSCREEN 1
-#define DEFAULT_USE_BKGD 1
-#define DEFAULT_HELP_MODE 0
-#define DEFAULT_DEMO_MODE 0
-#define DEFAULT_OPER_OVERRIDE 0
-#define DEFAULT_USE_KEYPAD 0
-#define DEFAULT_ALLOW_PAUSE 1
-#define DEFAULT_BONUS_SPEED_RATIO 1.5
-#define DEFAULT_BONUS_COMET_INTERVAL 10
-#define DEFAULT_SPEED 1
-#define DEFAULT_ALLOW_SPEEDUP 1
-#define DEFAULT_SPEEDUP_FACTOR 1.2
-#define DEFAULT_MAX_SPEED 10
-#define DEFAULT_SLOW_AFTER_WRONG 0
-#define DEFAULT_STARTING_COMETS 2
-#define DEFAULT_EXTRA_COMETS_PER_WAVE 2
-#define DEFAULT_MAX_COMETS 10
-#define DEFAULT_SAVE_SUMMARY 1
-#define DEFAULT_SOUND_HW_AVAILABLE 1
-#define DEFAULT_USE_IGLOOS 1
-#define DEFAULT_USE_FEEDBACK 0
-#define DEFAULT_DANGER_LEVEL 0.35
-#define DEFAULT_DANGER_LEVEL_SPEEDUP 1.1
-#define DEFAULT_DANGER_LEVEL_MAX 0.9
-#define DEFAULT_CITY_EXPL_HANDICAP 0
-#define DEFAULT_LAST_SCORE 0
-
-/* These values are hard-coded and used 'as is' by the program */
-/* (i.e. these behaviors require recompilation to change) */
-#define DEFAULT_NUM_CITIES 4 /* MUST BE AN EVEN NUMBER! */
-#define DEFAULT_MAX_CITY_COLORS 4
-
-#define MINIMUM_SPEED 0.8
-#define MAX_MAX_SPEED 20.0
-#define MIN_SPEEDUP_FACTOR 1.0
-#define MAX_SPEEDUP_FACTOR 2.0
-#define MAX_BONUS_SPEED_RATIO 3.0
-#define MIN_COMETS 1
-#define MAX_MAX_COMETS 100
-
-#define DEFAULT_FONT_NAME "AndikaDesRevG.ttf"
-#define DEFAULT_MENU_FONT_SIZE 18
-#define DEFAULT_HELP_FONT_SIZE 32
-
-
-#define HIGH_SCORES_SAVED 10
-#define HIGH_SCORE_NAME_LENGTH 32
-
-#define REG_RGBA 16,16,96,96
-#define SEL_RGBA 16,16,128,128
-
-#define RES_X 640
-#define RES_Y 480
-#define PIXEL_BITS 32
-
-enum {
- CADET_HIGH_SCORE,
- SCOUT_HIGH_SCORE,
- RANGER_HIGH_SCORE,
- ACE_HIGH_SCORE,
- COMMANDO_HIGH_SCORE,
- NUM_MATH_COMMAND_LEVELS
-};
-
-enum {
- FACTORS_HIGH_SCORE = NUM_MATH_COMMAND_LEVELS,
- FRACTIONS_HIGH_SCORE,
- NUM_HIGH_SCORE_LEVELS
-};
-
-
-
/* Global data gets 'externed' here: */
extern int fs_res_x;
extern int fs_res_y;
@@ -165,15 +76,6 @@
#endif
-
-#define NAME_BUF_SIZE 200
-
-/* data for 'Training Academy' lessons: */
-extern char **lesson_list_titles;
-extern char **lesson_list_filenames;
-extern int* lesson_list_goldstars;
-extern int num_lessons;
-
/* NOTE: default values for math options are now in mathcards.h */
#endif
More information about the Tux4kids-commits
mailing list