home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 123 / cdrom123.iso / edu / tux / Tuxtype2-1.5.3-installer.exe / src / globals.h < prev    next >
Encoding:
C/C++ Source or Header  |  2004-03-25  |  5.2 KB  |  208 lines

  1. /***************************************************************************
  2.                           globals.h
  3.   description: global varis
  4.                              -------------------
  5.     begin                : Fri May 5 2000
  6.     copyright            : (C) 2000 by Sam Hart
  7.     email                : hart@geekcomix.com
  8.  ***************************************************************************/
  9.  
  10. /***************************************************************************
  11.  *                                                                         *
  12.  *   This program is free software; you can redistribute it and/or modify  *
  13.  *   it under the terms of the GNU General Public License as published by  *
  14.  *   the Free Software Foundation; either version 2 of the License, or     *
  15.  *   (at your option) any later version.                                   *
  16.  *                                                                         *
  17.  ***************************************************************************/
  18.  
  19. #define to_upper(c) (((c) >= 'a' && (c) <= 'z') ? (c) -32 : (c))
  20. #define COL2RGB( col ) SDL_MapRGB( screen->format, col->r, col->g, col->b )
  21.  
  22. #define FNLEN    200
  23.  
  24. #define RES_X    640
  25. #define RES_Y    480
  26. #define BPP    16    
  27.  
  28. #ifdef WIN32 
  29. #undef DATA_PREFIX
  30. #define DATA_PREFIX ".//"
  31. #endif
  32.  
  33. #ifndef __GLOBALS_H__
  34. #define __GLOBALS_H__
  35.  
  36. #define MAX_SPRITE_FRAMES 30
  37.  
  38. #include <string.h>
  39. #include <math.h>
  40. #include <time.h>
  41. #include <stdio.h>
  42. #include <stdlib.h>
  43. #include <sys/stat.h>
  44. #include <dirent.h>
  45.  
  46. #include "../config.h"
  47.  
  48. #include "SDL.h"
  49. #include "SDL_image.h"
  50. #include "SDL_mixer.h"
  51. #include "SDL_ttf.h"
  52.  
  53. #endif //  __GLOBALS_H__
  54.  
  55. #define next_frame(SPRITE) if ((SPRITE)->num_frames) (SPRITE)->cur = (((SPRITE)->cur)+1) % (SPRITE)->num_frames;
  56. #define rewind(SPRITE) (SPRITE)->cur = 0;
  57.  
  58. #define MIN(x,y) ((x) < (y) ? (x) : (y))
  59. #define MAX(x,y) ((x) > (y) ? (x) : (y))
  60.  
  61. typedef struct {
  62.     char lang[FNLEN];
  63.     char path[FNLEN];
  64.     char window[FNLEN];
  65.     int sfx_volume;
  66.     int mus_volume;
  67. } settings;
  68.  
  69. typedef struct {
  70.     SDL_Surface *frame[MAX_SPRITE_FRAMES];
  71.     SDL_Surface *default_img;
  72.     int num_frames;
  73.     int cur;
  74. } sprite;
  75.  
  76. #define _(str) gettext (str)
  77. #define gettext_noop(str) (str)
  78.  
  79. /* LOGGING works as such:
  80.  *
  81.  * - Use LOG if you want to output a string LOG( "Hello World");
  82.  *   
  83.  * - Use DOUT if you want to output a value of a variable and the
  84.  *   name of the variable gives enough context:
  85.  *   DOUT( specialCode );  would add to stderr: "specialCode = 1\n" or
  86.  *   whatever value specialCode had
  87.  *   
  88.  * - Use DEBUGCODE if you need to do something more complicated like
  89.  *   DEBUGCODE { fprintf(stderr, "examining letter %d\n", x); }
  90.  *   since DOUT(x) "x = 1\n" gives little information since x is used
  91.  *   all over the place!
  92.  */
  93.  
  94. #define LOG( str ) if (debugOn) fprintf( stderr, str );
  95. #define DEBUGCODE if (debugOn) 
  96. #define DOUT(x) if (debugOn) fprintf(stderr, "%s = %d\n", #x, x);
  97.  
  98. #if SDL_BYTEORDER == SDL_BIG_ENDIAN
  99. #define rmask 0xff000000
  100. #define gmask 0x00ff0000
  101. #define bmask 0x0000ff00
  102. #define amask 0x000000ff
  103. #else
  104. #define rmask 0x000000ff
  105. #define gmask 0x0000ff00
  106. #define bmask 0x00ff0000
  107. #define amask 0xff000000
  108. #endif
  109.  
  110. #define menu_font    "menu.ttf"
  111. #define menu_font_size    20
  112.  
  113. #define ttf_font    "letters.ttf"
  114. #define ttf_font_size    20
  115.  
  116. #define MAX_NUM_WORDS   500
  117. #define MAX_WORD_SIZE   8
  118.  
  119. #define WAIT_MS                2500
  120. #define    FRAMES_PER_SEC                    50
  121. #define FULL_CIRCLE                140
  122.  
  123. /* Menu Prototypes */
  124. enum Game_Type { 
  125.     QUIT_GAME, CASCADE, OPTIONS, LESSONS,
  126.     INSTRUCT_CASCADE, CASCADE1, CASCADE2, CASCADE3, CASCADE4,
  127.     INSTRUCT_LASER,    LASER1,    LASER2,    LASER3,    LASER4,
  128.     FREETYPE, ASDF, ALL, MAIN, SET_LANGUAGE, PROJECT_INFO, EDIT_WORDLIST,
  129.     LEVEL1, LEVEL2, LEVEL3, LEVEL4, LASER, INSTRUCT, NOT_CODED, NONE};
  130.  
  131. /* Title sequence constants */
  132. #define PRE_ANIM_FRAMES            10
  133. #define PRE_FRAME_MULT            3
  134. #define MENU_SEP            20
  135.  
  136. /* paths */
  137.  
  138. #define IMG_REGULAR  0x01
  139. #define IMG_COLORKEY 0x02
  140. #define IMG_ALPHA    0x04
  141. #define IMG_MODES    0x07
  142.  
  143. #define IMG_NOT_REQUIRED 0x10
  144. #define IMG_NO_THEME     0x20
  145.  
  146. //Game difficulty levels
  147. enum { EASY, MEDIUM, HARD, INSANE, INF_PRACT };
  148. #define NUM_LEVELS                4
  149.  
  150. extern SDL_Surface *screen;
  151. extern TTF_Font  *font;
  152. extern SDL_Event  event;
  153.  
  154. extern SDL_Color black;
  155. extern SDL_Color gray;
  156. extern SDL_Color dark_blue;
  157. extern SDL_Color red;
  158. extern SDL_Color white;
  159. extern SDL_Color yellow;
  160.  
  161. extern SDL_Surface *bkg;
  162. extern SDL_Surface *letters[255];
  163.  
  164. extern unsigned char ALPHABET[256];
  165. extern unsigned char KEYMAP[256];
  166. extern unsigned char FINGER[256][10];
  167. extern int ALPHABET_SIZE;
  168.  
  169. //global vars
  170. extern int speed_up;
  171. extern int show_tux4kids;
  172. extern int debugOn;
  173. extern int o_lives;
  174. extern int sound_vol;
  175. extern int hidden; // Read the README file in the image directory for info on this ;)
  176.  
  177. /* Alternative language/word/image/sound theming */
  178. extern unsigned char realPath[2][FNLEN];
  179. extern char themeName[FNLEN];
  180. extern int useEnglish;
  181.  
  182. enum {
  183.     WIN_WAV,
  184.     BITE_WAV,
  185.     LOSE_WAV,
  186.     RUN_WAV,
  187.     SPLAT_WAV,
  188.     WINFINAL_WAV,
  189.     EXCUSEME_WAV,
  190.     PAUSE_WAV,
  191.     NUM_WAVES
  192. };
  193.  
  194. extern Mix_Chunk      *sound[NUM_WAVES];
  195. extern Mix_Music      *music;
  196. extern int sys_sound;
  197.  
  198. #define MUSIC_FADE_OUT_MS    80
  199.  
  200. enum {
  201.     WIPE_BLINDS_VERT,
  202.     WIPE_BLINDS_HORIZ,
  203.     WIPE_BLINDS_BOX,
  204.     RANDOM_WIPE,
  205.  
  206.     NUM_WIPES
  207. };
  208.