資源簡介
OpenGL寫的推箱子,window與linux都可以用。為與之前的TC_BOX地圖兼容,部分代碼冗余。
代碼片段和文件信息
#include?
#include?
#include?
#include?
#include?
#include?
#define?SIZE?25
#define?SIZE_X?20
#define?SIZE_Y?20
#define?SIZE_GROUP?SIZE_X*SIZE_Y
#define?SIZE_STAGE?(3*SIZE_GROUP+2)
#define?X_I?((int)?role_x?)
#define?Y_I?((int)?role_y?)
#define?HEAVY_BOX 1
#define?HEAVY_WALL 100
#define?HEAVY_ROLE 250
#define?HEAVY_DESITINATION 210
GLuint?draw_wall?draw_box?draw_role?draw_desitination?draw_line?;
int?heavy_read[SIZE_X][SIZE_Y];
int?heavy[SIZE_X+2][SIZE_Y+2];
unsigned?char?desi_role[SIZE_X+2][SIZE_Y+2]?=?{0};
int?role_x?role_y;?
char?wall_point[SIZE_X][SIZE_Y];
char?box_point[SIZE_X][SIZE_Y];
char?destination_point[SIZE_X][SIZE_Y];
char?file_name[20];??
int?stage_total?;
int?stage_current?=?1;?
void?init?(void);
void?win?(void);
void?read_stage(int?map_s);
struct?Role
{
int?x;
int?y;
int?strength;
int?heavyer;?
}role;
/*
*?heavy?of?wall?100
*?heavy?of?box 1
*?heavy?of?destination?210
*?
*/
void?draw(void)
{
GLfloat point[8][3]?=?{{000}?{0.100}?{00.10}?{000.1}?{0.10.10}?{0.100.1}?{00.10.1}?{0.10.10.1}};
GLint?face[6][4]?=?{{0142}{0263}{0351}{1574}{2476}{3675}};
GLfloat?color[6][3]?=?{{100}?{010}?{001}?{110}?{101}?{011}};
GLint?i?j;
draw_wall?=?glGenLists(1);
glNewList?(draw_wall?GL_COMPILE);
glBegin?(GL_POLYGON);
for?(i=0;?i<6;?i++)
for?(j=0;?j<4;?j++)
{
glColor3fv?(color[j]);
glVertex3fv?(point[face[i][j]]);
}
glEnd();
glEndList?();
draw_box?=?glGenLists(1);
glNewList?(draw_box?GL_COMPILE);
glBegin?(GL_POLYGON);
for?(i=0;?i<6;?i++)
{
glColor3fv?(color[i]);
for?(j=0;?j<4;?j++)
glVertex3fv?(point[face[i][j]]);
}
glEnd();
glEndList?();
draw_role?=?glGenLists?(1);
glNewList?(draw_role?GL_COMPILE);
glBegin?(GL_POLYGON);
glColor3f?(0?1?0);
glVertex3f?(0.05?0.1?0.05);
glVertex3f?(0.1?0?0);
glVertex3f?(0?0?0);
glEnd?();
glBegin?(GL_POLYGON);
glColor3f?(1?0?1);
glVertex3f?(0.05?0.1?0.05);
glVertex3f?(0.1?0?0);
glVertex3f?(0.1?0?0.1);
glEnd?();
glBegin?(GL_POLYGON);
glColor3f?(1?1?0);
glVertex3f?(0.05?0.1?0.05);
glVertex3f?(0?0?0.1);
glVertex3f?(0?0?0);
glEnd?();
glBegin?(GL_POLYGON);
glColor3f?(0?1?1);
glVertex3f?(0.05?0.1?0.05);
glVertex3f?(0.1?0?0.1);
glVertex3f?(0?0?0.1);
glEnd?();
glEndList?();
draw_desitination?=?glGenLists?(1);
glNewList?(draw_desitination?GL_COMPILE);
glBegin?(GL_LINES);
glColor3f?(0?0?1);
glVertex3f?(0?0?0);
glVertex3f?(0.1?0.1?0);
glVertex3f?(0?0.1?0);
glVertex3f?(0.1?0?0);
glVertex3f?(0?0?0.1);
glVertex3f?(0.1?0.1?0.1);
glVertex3f?(0?0.1?0.1);
glVertex3f?(0.1?0?0.1);
glEnd();
glEndList?();
draw_line?=?glGenLists?(1);
glNewList?(draw_line?GL_COMPILE);
glColor3f?(0?0?1);?
glBegin?(GL_LINE_LOOP);
glVertex3f?(0.1?0.1?0);
- 上一篇:飛思卡爾XS128
- 下一篇:ABB ACS800變頻器資料
評論
共有 條評論