C++ 预期为'';前内主支架
所以我因为没有放“;”而犯了一个错误在int main后面的括号“{”之前,令人恼火的是,到目前为止,我已经尝试了所有我能尝试的东西(警告:我根本不是一个有经验的程序员)我甚至试着加入新的库,但它不起作用。我注意到,通过使用相同int main的类似代码并复制/粘贴它,只有键盘功能才是造成问题的原因……我真的无法理解……提前感谢您提供的任何帮助:)C++ 预期为'';前内主支架,c++,game-physics,C++,Game Physics,所以我因为没有放“;”而犯了一个错误在int main后面的括号“{”之前,令人恼火的是,到目前为止,我已经尝试了所有我能尝试的东西(警告:我根本不是一个有经验的程序员)我甚至试着加入新的库,但它不起作用。我注意到,通过使用相同int main的类似代码并复制/粘贴它,只有键盘功能才是造成问题的原因……我真的无法理解……提前感谢您提供的任何帮助:) #包括 #包括 类框 { 公众:浮动x; 公众:流动人口;; 公众:w ;; 公众:h ;; 公众:流动电话;; 公众:g ;; 公众:浮动b ;;
#包括
#包括
类框
{
公众:浮动x;
公众:流动人口;;
公众:w ;;
公众:h ;;
公众:流动电话;;
公众:g ;;
公众:浮动b ;;
公众:浮动i ;;
公众:浮动j ;;
公众:bool-ActiveBox;
公众:布尔水平;
作废提款()
{
gl3f(r,g,b);
glRectf(x,y,x+w,y+h);
gl3f(1,1,1);
glBegin(GL_线_环);
glRectf(x,y,x+w,y+h);
glVertex2f(x,y);
glVertex2f(x,y+h);
glVertex2f(x+w,y+h);
glVertex2f(x+w,y);
格伦德();
}
空隙轮廓(浮子r、浮子g、浮子b、浮子x、浮子y、浮子w、浮子h)
{
gl3f(r,g,b);
glRectf(x,y,x+w,y+h);
线宽(3);
gl3f(1,1,1);
glBegin(GL_线_环);
glVertex2f(x,y);
glVertex2f(x,y+h);
glVertex2f(x+w,y+h);
glVertex2f(x+w,y);
格伦德();
}
box(){x=0;y=0;w=0;h=0;r=0;g=0;b=0;i=0;j=0;ActiveBox=false;Horizontal=false;}
~box(){x=0;y=0;w=0;h=0;r=0;g=0;b=0;i=0;j=0;ActiveBox=false;Horizontal=false;}
};
盒子和拼图块[10];
整数网格[6][6];
int d=1;
int highlight=1;
空心网格(浮点数i、浮点数j)
{
对于(int i=1;i<7;i++)
{
对于(int j=1;j<7;j++)
{
网格[i][j];
}
}
网格[1][1]=1;
网格[1][2]=1;
网格[1][3]=1;
网格[1][4]=1;
网格[1][5]=1;
网格[1][6]=1;
网格[2][1]=1;
网格[2][2]=1;
网格[2][3]=0;
网格[2][4]=1;
网格[2][5]=1;
网格[2][6]=1;
网格[3][1]=0;
网格[3][2]=1;
网格[3][3]=1;
网格[3][4]=1;
网格[3][5]=0;
网格[3][6]=0;
网格[4][1]=1;
网格[4][2]=1;
网格[4][3]=0;
网格[4][4]=1;
网格[4][5]=1;
网格[4][6]=0;
网格[5][1]=0;
网格[5][2]=0;
网格[5][3]=1;
网格[5][4]=1;
网格[5][5]=1;
网格[5][6]=0;
网格[6][1]=0;
网格[6][2]=0;
网格[6][3]=1;
网格[6][4]=0;
网格[6][5]=1;
网格[6][6]=0;
拼图[1],w=d;
拼图[1],h=2*d;
拼图[1],g=1;
拼图[2],x=1;
拼图[2],w=d;
拼图[2],h=2*d;
拼图[2],g=1;
拼图[3],x=2;
拼图[3],w=d;
拼图[3],h=2*d;
拼图[3],g=1;
拼图[4],x=3;
拼图[4],w=2*d;
拼图[4],h=d;
拼图[4],b=1;
拼图[4]。水平=真;
拼图[5],x=4;
拼图[5],y=1;
拼图[5],w=2*d;
拼图[5],h=d;
拼图[5],b=1;
拼图[5]。水平=真;
拼图[6],x=1;
拼图[6],y=3;
拼图[6],h=d;
拼图[6],w=2*d;
拼图[6],b=1;
拼图[6]。水平=真;
拼图[7],x=3;
拼图[7],y=2;
拼图[7],w=d;
拼图[7],h=3*d;
拼图[7],g=1;
拼图[8],x=1;
拼图[8],y=2;
拼图[8],w=2*d;
拼图[8],h=d;
拼图[8],r=1;
拼图[8]。水平=真;
拼图[9],x=2;
拼图[9],y=4;
拼图[9],w=d;
拼图[9],h=2*d;
拼图[9],g=1;
拼图[10],x=4;
拼图[10],y=3;
拼图[10],w=d;
拼图[10],h=2*d;
拼图[10],g=1;
}
作废显示(作废)
{
glClearColor(0.0,0.0,0.0,0.0);
glClear(GLU颜色缓冲位);
glLoadIdentity;
glTranslatef(2.5,2.5,0);
glBegin(GL_多边形);
glVertex2f(0,0);
glVertex2f(0,6);
glVertex2f(6,6);
glVertex2f(6,0);
格伦德();
对于(int i=0;i<11;i++)
{
拼图[i].Draw();
if(拼图块[i].ActiveBox==true)
{
拼图[i].大纲;
}
}
gl3f(1,1,1);
线宽(3);
glBegin(GL_线_环);
glVertex2f(0,0);
glVertex2f(0,6);
glVertex2f(6,6);
glVertex2f(6,0);
格伦德();
对于(int i=0;i<8;i++)
{
拼图[i]。绘画;
}
glFlush();
}
空洞重塑(整数w,整数h)
{
浮点数dx=600,dy=600;
GLVIEW(0,0,(GLsizei)w,(GLsizei)h);
glMatrixMode(GL_投影);
格洛托(0.0,dx,0.0,dy,0,10);
glMatrixMode(GLU模型视图);
glLoadIdentity();
}
无效键盘(无符号字符键,整数x,整数y)
{
开关(钥匙){
案例27:退出(0);//退出结束程序
案例“w”:
如果(突出显示==0)
{
拼图[highlight].Outline=true;
}
如果(高亮显示!=0)
{
拼图[highlight].Outline=true;
拼图[highlight-1].Outline=false;
}
如果(突出显示==8)
{
拼图[0]。大纲=true;
突出显示=0;
}
突出显示++;
打破
再发现();
}
int main(int argc,字符**argv)
**{**
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(500500);
位置(100100);
glutCreateWindow(“DPSD-图形手臂Ex-4”);
网格();
格洛蒂
#include <GL/glut.h>
#include <math.h>
class Boxes
{
public: float x;
public: float y;
public: float w;
public: float h;
public: float r;
public: float g;
public: float b;
public: float i;
public: float j;
public: bool ActiveBox;
public: bool Horizontal;
void Draw()
{
glColor3f(r, g, b);
glRectf(x, y, x + w, y + h);
glColor3f(1, 1, 1);
glBegin(GL_LINE_LOOP);
glRectf(x, y, x + w, y + h);
glVertex2f(x, y);
glVertex2f(x, y + h);
glVertex2f(x + w, y + h);
glVertex2f(x + w, y);
glEnd();
}
void Outline(float r, float g, float b, float x, float y, float w, float h)
{
glColor3f(r, g, b);
glRectf(x, y, x + w, y + h);
glLineWidth(3);
glColor3f(1, 1, 1);
glBegin(GL_LINE_LOOP);
glVertex2f(x, y);
glVertex2f(x, y + h);
glVertex2f(x + w, y + h);
glVertex2f(x + w, y);
glEnd();
}
Boxes() { x = 0; y = 0; w = 0; h = 0; r = 0; g = 0; b = 0; i = 0; j = 0; ActiveBox = false; Horizontal = false; }
~Boxes() { x = 0; y = 0; w = 0; h = 0; r = 0; g = 0; b = 0; i = 0; j = 0; ActiveBox = false; Horizontal = false; }
};
Boxes PuzzlePieces[10];
int grid[6][6];
int d = 1;
int highlight = 1;
void Grid(float i, float j)
{
for (int i = 1; i < 7; i++)
{
for (int j = 1; j < 7; j++)
{
grid[i][j];
}
}
grid[1][1] = 1;
grid[1][2] = 1;
grid[1][3] = 1;
grid[1][4] = 1;
grid[1][5] = 1;
grid[1][6] = 1;
grid[2][1] = 1;
grid[2][2] = 1;
grid[2][3] = 0;
grid[2][4] = 1;
grid[2][5] = 1;
grid[2][6] = 1;
grid[3][1] = 0;
grid[3][2] = 1;
grid[3][3] = 1;
grid[3][4] = 1;
grid[3][5] = 0;
grid[3][6] = 0;
grid[4][1] = 1;
grid[4][2] = 1;
grid[4][3] = 0;
grid[4][4] = 1;
grid[4][5] = 1;
grid[4][6] = 0;
grid[5][1] = 0;
grid[5][2] = 0;
grid[5][3] = 1;
grid[5][4] = 1;
grid[5][5] = 1;
grid[5][6] = 0;
grid[6][1] = 0;
grid[6][2] = 0;
grid[6][3] = 1;
grid[6][4] = 0;
grid[6][5] = 1;
grid[6][6] = 0;
PuzzlePieces[1].w = d;
PuzzlePieces[1].h = 2 * d;
PuzzlePieces[1].g = 1;
PuzzlePieces[2].x = 1;
PuzzlePieces[2].w = d;
PuzzlePieces[2].h = 2 * d;
PuzzlePieces[2].g = 1;
PuzzlePieces[3].x = 2;
PuzzlePieces[3].w = d;
PuzzlePieces[3].h = 2 * d;
PuzzlePieces[3].g = 1;
PuzzlePieces[4].x = 3;
PuzzlePieces[4].w = 2 * d;
PuzzlePieces[4].h = d;
PuzzlePieces[4].b = 1;
PuzzlePieces[4].Horizontal = true;
PuzzlePieces[5].x = 4;
PuzzlePieces[5].y = 1;
PuzzlePieces[5].w = 2 * d;
PuzzlePieces[5].h = d;
PuzzlePieces[5].b = 1;
PuzzlePieces[5].Horizontal = true;
PuzzlePieces[6].x = 1;
PuzzlePieces[6].y = 3;
PuzzlePieces[6].h = d;
PuzzlePieces[6].w = 2 * d;
PuzzlePieces[6].b = 1;
PuzzlePieces[6].Horizontal = true;
PuzzlePieces[7].x = 3;
PuzzlePieces[7].y = 2;
PuzzlePieces[7].w = d;
PuzzlePieces[7].h = 3 * d;
PuzzlePieces[7].g = 1;
PuzzlePieces[8].x = 1;
PuzzlePieces[8].y = 2;
PuzzlePieces[8].w = 2 * d;
PuzzlePieces[8].h = d;
PuzzlePieces[8].r = 1;
PuzzlePieces[8].Horizontal = true;
PuzzlePieces[9].x = 2;
PuzzlePieces[9].y = 4;
PuzzlePieces[9].w = d;
PuzzlePieces[9].h = 2 * d;
PuzzlePieces[9].g = 1;
PuzzlePieces[10].x = 4;
PuzzlePieces[10].y = 3;
PuzzlePieces[10].w = d;
PuzzlePieces[10].h = 2 * d;
PuzzlePieces[10].g = 1;
}
void display(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity;
glTranslatef(2.5, 2.5, 0);
glBegin(GL_POLYGON);
glVertex2f(0, 0);
glVertex2f(0, 6);
glVertex2f(6, 6);
glVertex2f(6, 0);
glEnd();
for (int i = 0; i < 11; i++)
{
PuzzlePieces[i].Draw();
if (PuzzlePieces[i].ActiveBox == true)
{
PuzzlePieces[i].Outline;
}
}
glColor3f(1, 1, 1);
glLineWidth(3);
glBegin(GL_LINE_LOOP);
glVertex2f(0, 0);
glVertex2f(0, 6);
glVertex2f(6, 6);
glVertex2f(6, 0);
glEnd();
for (int i = 0; i < 8; i++)
{
PuzzlePieces[i].Draw;
}
glFlush();
}
void reshape (int w, int h)
{
float dx=600, dy=600;
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glOrtho(0.0, dx, 0.0, dy, 0, 10);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void keyboard(unsigned char key, int x, int y)
{
switch (key) {
case 27: exit(0); // escape ends the programm
case 'w':
if (highlight == 0)
{
PuzzlePieces[highlight].Outline = true;
}
if (highlight != 0)
{
PuzzlePieces[highlight].Outline = true;
PuzzlePieces[highlight - 1].Outline = false;
}
if (highlight == 8)
{
PuzzlePieces[0].Outline = true;
highlight = 0;
}
highlight++;
break;
glutPostRedisplay();
}
int main(int argc, char** argv)
**{**
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (500, 500);
glutInitWindowPosition (100, 100);
glutCreateWindow ("DPSD - Graphics Arm Ex - 4");
Grid();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(keyboard);
glutMainLoop();
return 0;
void keyboard(unsigned char key, int x, int y)
{
switch (key) {
case 27: exit(0); // escape ends the programm
case 'w':
if (highlight == 0)
{
PuzzlePieces[highlight].Outline = true;
}
if (highlight != 0)
{
PuzzlePieces[highlight].Outline = true;
PuzzlePieces[highlight - 1].Outline = false;
}
if (highlight == 8)
{
PuzzlePieces[0].Outline = true;
highlight = 0;
}
highlight++;
break;
glutPostRedisplay();
}
} // <= This is what you need.
int main(int argc, char** argv)