Pong em c
#include
#include
#include
/*Include the pong header file for the finding things in the datafile*/
#include "pong.h"
#define pong_ball 0 /* RLE */
#define pong_bar 1 /* RLE */
#define pong_boing 2 /* SAMP */
#define pong_pal 3 /* PAL */
#define pong_text 4 /* FONT */
#define pong_COUNT 5
/*Direction consts*/
#define DOWN_RIGHT 0
#define UP_RIGHT 1
#define DOWN_LEFT 2
#define UP_LEFT 3
/*Get the Pong DataFile*/
DATAFILE *pong_datafile=NULL;
/*Game variables*/ int bar1_y=30; //Player 1 Bar position int bar2_y=430; //Player 2 Bar position
int ball_x; //The location of the Ball int ball_y; //The location of the Ball int direction=0; //The direction the Ball is going
int score_p1=0; //Player 1 score int score_p2=0; //Plater 2 score
BITMAP *buffer; //The screen buffer of double buffering
int speed=2; //The speed of the Ball
int amout_of_hits=0; //Used to set the speed of the Ball
int up_ran_speed=0; //Random speed
/******************************************************** *NAME:Boing * *PURPOSE:To play the sound file when the ball is hit * *INPUT: N/A * *RETURN: N/A * *******************************************************/ void boing(void)
{
play_sample(pong_datafile[pong_boing].dat,255,255,1000,0); return;
}
/******************************************************** *NAME:Random Direction * *PURPOSE:To send back a random direction for the ball * *INPUT: N/A * *RETURN: An int for the direction *