📄 game.h
字号:
#include <windows.h>
#include <GL/glu.h>
// Status codes for ball
#define BS_STATIONARY 0
#define BS_MOVING 1
#define BS_IN_THE_HOLE 2
#define BS_REMOVED 3
// Status codes for the game
#define GS_STATIONARY 0
#define GS_AIMING 1
#define GS_HITTING 2
#define GS_MOVING 3
#define GS_REPOSITION 4
#define GS_INIT_REPOSITION 5
#define GS_OVER 6
#define PI 3.14159265358979323846
#define PI_DIV_180 0.017453292519943296
class CPlayer
{
public:
char m_Name[20];
bool m_bTurn;//turn to hit
int m_ballHitMin;
int m_ballHitMax;
CPlayer *m_pOpponent;
CPlayer(void);
};
class CBall
{
public:
double x[3]; // Center position
double r; // Radius
double v[3]; // Velocity
double mass; // Mass
double ball_alpha;
int h_num;
double before_in[3];
GLubyte color[4]; // Color
//double rot[4][4]; // Rotation matrix
int status; // status
bool hit;
CBall(void);
void SetParameters(double cx0, double cy0, double cz0, double r0, double mass0,
GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
};
class CBoundary
{
public:
double x[4][2]; // Vertex positions
double n[3][2]; // Normal vectors for three sides
double topn[3];
double inn[3];
double top, bottom; // z coordinate for top and bottom
GLubyte color[4]; // Color
CBoundary(void);
void SetParameters(double x0, double y0, double x1, double y1,
double x2, double y2, double x3, double y3,
double top0, double bottom0,
GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
};
class CHole
{
public:
double x[2]; // Center
double r; // Radius
double top, bottom; // z coordinate for top and bottom
GLubyte color[4]; // Color
CHole(void);
void SetParameters(double x0, double y0, double r0,
double top0, double bottom0,
GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
};
class CPoolGame
{
public:
////////////////////////
bool rule;
bool restart;
bool choose;
bool first;
bool player1red;
bool normally;
bool pot;
bool foul;
bool win;
bool loss;
int bdhitnum;
int bdhit[16];
int ballhit; //the first ball hit else be 0
int numin; //numbers of in hole
int ballin[16]; //balls in hole
////////////////////////
CPlayer player1,player2;
int num_balls; // Number of balls
CBall balls[20]; // Balls
int num_boundaries; // Number of boundaries
CBoundary boundaries[10]; // Boundaries
int num_holes; // Number of holes
CHole holes[10]; // Holes
double hit_speed; // Ball speed after being hitted
double max_hit_speed;
double min_hit_speed;
double rod_ball_dist;
double max_rod_ball_dist;
double min_rod_ball_dist;
double sizex, sizey; // Table size
double thickness; // Table thickness
int status; // Game status
bool reposition_valid;
bool keymap[256];
int mousex, mousey;
bool rotation_flag;
int viewport_x, viewport_y;
private:
GLuint leg_list;
GLuint sphere_list;
GLuint disk_list;
GLuint disk_list_m;
GLuint cylinder_list_1;
GLuint cylinder_list_2;
GLuint shadow_list;
GLuint rod_list;
public:
CPoolGame(void);
~CPoolGame(void);
void reset(void);
void Collision(double time_step);
void Move(double time_step);
bool Is_white_ball_pos_valid();
void FrameMove(int mousex0, int mousey0, double time_step);
void Render(void);
void Render2DPanel(void);
void GL_init(void);
void GL_init2D(void);
void GL_resize(int w, int h);
void GL_cleanup(void);
void GL_cleanup2D(void);
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -