|
SDLGameEngine
|
00001 #ifndef _SGE_H 00002 #define _SGE_H 00003 00004 #ifdef __cplusplus 00005 extern "C" { 00006 #endif 00007 00012 /* 00013 * Copyright (c) 2007 Heiko Irrgang 00014 * 00015 * The license and distribution terms for this file may be 00016 * found in the file COPYING in this distribution or at 00017 * http://93-interactive.com/cms/products/software/sdl-game-engine/license/ 00018 */ 00019 00136 #include <SDL.h> 00137 #include <SDL_image.h> 00138 #include <SDL_mixer.h> 00139 #include <SDL_audio.h> 00140 #include <stdio.h> 00141 #include <stdlib.h> 00142 #include <string.h> 00143 #include <sys/types.h> 00144 #include <sys/stat.h> 00145 #ifndef MORPHOS 00146 #include <unistd.h> 00147 #endif 00148 #include <fcntl.h> 00149 #include <time.h> 00150 #include <math.h> 00151 00178 #define sgeLock(surface) do {\ 00179 if (SDL_MUSTLOCK(surface)) SDL_LockSurface(surface);\ 00180 } while (0) 00181 00189 #define sgeUnlock(surface) do {\ 00190 if (SDL_MUSTLOCK(surface)) SDL_UnlockSurface(surface);\ 00191 } while (0) 00192 00204 #define sgeBailOut(format, args...) do {\ 00205 fprintf(stderr,(format),args); \ 00206 exit(-1); \ 00207 } while (0) 00208 00223 #define sgeMalloc(target,type,amount) do {\ 00224 (target)=(type *)malloc((amount+1)*sizeof(type));\ 00225 if ((target)==NULL) {\ 00226 sgeBailOut("could not allocate %d bytes of ram\n", (int)((amount)*sizeof(type)));\ 00227 }\ 00228 memset(target,0,((amount)*sizeof(type)));\ 00229 } while (0) 00230 00245 #define sgeMallocNoInit(target,type,amount) do {\ 00246 (target)=(type *)malloc((amount+1)*sizeof(type));\ 00247 if ((target)==NULL) {\ 00248 sgeBailOut("could not allocate %d bytes of ram\n", (int)((amount)*sizeof(type)));\ 00249 }\ 00250 } while (0) 00251 00260 #define sgeRealloc(target,type,amount) do {\ 00261 (target)=realloc((target),sizeof(type)*(amount+1));\ 00262 if (target==NULL) {\ 00263 sgeBailOut("could not allocate %d bytes of ram\n", (int)((amount)*sizeof(type)));\ 00264 }\ 00265 } while (0) 00266 00274 #define sgeNew(target,type) sgeMalloc(target,type,1); 00275 00281 #define sgeFree(target) do {\ 00282 free(target);\ 00283 target=NULL;\ 00284 } while(0) 00285 00293 #define sgeRandom(from, range) (from + (int) ((float)(range+1) * (rand() / (RAND_MAX + (float)from)))) 00294 00302 #define sgeRandomFloat(from, range) (float) ((float)from + ((float)(range+1) * (rand() / (RAND_MAX + (float)from)))) 00303 00313 #if SDL_BYTEORDER == SDL_LIL_ENDIAN 00314 #define sgeByteSwap16(val) (val) 00315 00324 #define sgeByteSwap32(val) (val) 00325 #else 00326 #define sgeByteSwap16(val) SDL_Swap16(val) 00327 #define sgeByteSwap32(val) SDL_Swap32(val) 00328 #endif 00329 00336 #ifdef NOROUND 00337 #define sgeRound(val) (int)((val*100+50)/100) 00338 #else 00339 #define sgeRound(val) round(val) 00340 #endif 00341 00348 #ifndef MAX 00349 #define MAX(x, y) ((x) > (y) ? (x) : (y)) 00350 #endif 00351 00358 #ifndef MIN 00359 #define MIN(x, y) ((x) < (y) ? (x) : (y)) 00360 #endif 00361 00369 #define MINMAX(value, lower, upper) MIN(MAX((value), (lower)), (upper)) 00370 00371 // @} 00372 00373 #include <sgedefines.h> 00374 #include <sgestring.h> 00375 #include <sgeinit.h> 00376 #include <sgegp2x.h> 00377 #include <sgemisc.h> 00378 #include <sgelist.h> 00379 #include <sgearray.h> 00380 #include <sgescreen.h> 00381 #include <sgecontrol.h> 00382 #include <sgegfx.h> 00383 #include <sgeresource.h> 00384 #include <sgeevent.h> 00385 #include <sgesound.h> 00386 #include <sgespriteimage.h> 00387 #include <sgesprite.h> 00388 #include <sgespritegroup.h> 00389 #include <sgestage.h> 00390 #include <sgegamestate.h> 00391 #include <sgefont.h> 00392 #include <sgepathfinder.h> 00393 #include <sgeparticles.h> 00394 #include <sgefadefx.h> 00395 00396 #include <../thirdparty/md5/md5.h> 00397 #include <../thirdparty/sha1-c/sha1.h> 00398 00399 #ifdef __cplusplus 00400 } 00401 #endif 00402 00403 #endif