SpacePong.h

logotipo.png


SpacePong header - A little pong clone game

/*
  Mini-game example using CRM32Pro: SpacePong.
  --------------------------------------------
  
  >MegaStorm Systems (c) 2009
  >http://www.megastormsystems.com
  >Roberto Prieto
  
  - Pong clone with 3 differents game modes:
  .Auto mode
  .1 player
  .2 players (on the same computer)
  - 2D environment at 800x600
  - Graphics, sounds and musics using DPF
  - Platform: Win32 / Linux / MacOS X
  
  Thanks to Worvast for the new in-game graphics.

  >Created: 24 January 2004
  >Modified: 3 December 2009     
 */


// ---Defines---
#define PONG_VERSION "SpacePong v2.01"
#define GFX_RESOURCE "gfx.dpf"
#define MUS_RESOURCE "audio.dpf"
#define Y_POSITION_1  568
#define Y_POSITION_2   16
#define Y_SIZE_PADDER  16
#define X_SIZE_BALL    16
#define Y_SIZE_BALL    16
#define LEFT_BAR      151
#define RIGHT_BAR     648
#define UP_LIMIT       -8
#define DOWN_LIMIT    600
#define MAX_BALL_SPEED 2.0f

#define MODE_COMPUTER 0
#define MODE_1PLAYER  2
#define MODE_2PLAYER  4
#define MODE_2NET     8
#define GAME_TIME     0
#define GAME_GOAL     2
#define GAME_NORMAL   4

#define PADDER_ACEL     1.0f 
#define PADDER_MAXSPEED 8.0f 

// ---Structs---
struct _sBall
{
   float x,y;
   float sx,sy; // Specific speed per coordinate
   float speed; // Global speed (it is going up each padder hit)
   CRM32Pro_CSprite *spr;
} sBall;

struct _sPadder
{
   float x,y;
   float speed;
   short size,random;
   CRM32Pro_CSprite *spr;
} sPadder[2];

struct _sGameDat
{
   Uint32 iWinP1;
   Uint32 iWinP2;
   char iModo;
   char iTipo;
} sGameDat;

// ---Global vars---
SDL_Rect rRect;
SDL_Surface *sGameBg, *sRestoreBg[2];
SDL_Surface *sMenuBg, *sMenuTitle, *sMenuInfo;
CRM32Pro_CFont *fFont;
Uint32 iAux = 0;
Uint32 cCursor;
Uint32 bExitID, bPlayer1ID, bPlayer2ID;
Uint32 bTimeID, bGoalID, bNormalID, bAutoID, bID;
char sCad[10];

// ---Music and sound handles---
int music_menu;
int music_game;
int click, click2, thunder;
int p1, p2, pared, gol, end;

// ---Prototypes---
void LoadAudio();
void FreeAudio();
void LoadGraphics();
void FreeGraphics();
void RenderInGame(int bLogicUpdate);
void RenderInMenu(int bLogicUpdate);
void InitBall(int);
void AIPadder(int);
void PadderHitBall(int);
void GameLoop(void);
void DrawInterfaz(int);
void InfoEngine(int);

// ---Macros---
#define SET_SPEED(a,b)\
        { \
                if(b==1) sPadder[a].speed+=PADDER_ACEL; \
                else sPadder[a].speed-=PADDER_ACEL; \
                if(b==1) { if(sPadder[a].speed<0.0f) sPadder[a].speed+=PADDER_ACEL*2; } \
                else { if(sPadder[a].speed>0.0f) sPadder[a].speed-=PADDER_ACEL*2; } \
        }

Generated on Mon Dec 21 17:04:39 2009 for CRM32Pro SDK v5.00 by  doxygen 1.6.1