You know right now I am getting very frustrated with even displaying Food, via
glPoints. I tried debugging it but could not find any problem. Can you help.
Relevant code :
My Display List for food
void DisplayList::Render_Food(string *FoodCol, float Diameter){ cFood.dListIDFd[0] = glGenLists(3); glNewList(cFood.dListIDFd[0],GL_COMPILE); //Determine Color if(FoodCol[0].compare("RED") == 0) RED; else if(FoodCol[0].compare("BLUE") == 0) BLUE; else if(FoodCol[0].compare("YELLOW") == 0) YELLOW; glPointSize(Diameter); glBegin(GL_POINTS); glVertex2f(0.0,0.0); glEnd(); glEndList(); cFood.dListIDFd[1] = cFood.dListIDFd[0]+1; glNewList(cFood.dListIDFd[1],GL_COMPILE); //Determine Color if(FoodCol[1].compare("RED") == 0) RED; else if(FoodCol[1].compare("BLUE") == 0) BLUE; else if(FoodCol[1].compare("YELLOW") == 0) YELLOW; glPointSize(Diameter); glBegin(GL_POINTS); glVertex2f(0.0,0.0); glEnd(); glEndList(); cFood.dListIDFd[2] = cFood.dListIDFd[1]+1; glNewList(cFood.dListIDFd[2],GL_COMPILE); //Determine Color if(FoodCol[2].compare("RED") == 0) RED; else if(FoodCol[2].compare("BLUE") == 0) BLUE; else if(FoodCol[2].compare("YELLOW") == 0) YELLOW; glPointSize(Diameter); glBegin(GL_POINTS); glVertex2f(10.0,-10.0); glEnd(); glEndList();}
This gets called in the constructor :
FOOD::FOOD(){ //4 * Mr.Pacman Radius Diameter = (SCREEN_W+SCREEN_H)/200; //Set Food Color FoodColor[0] = "RED"; FoodColor[1] = "BLUE"; FoodColor[2] = "YELLOW";//Render Food Display List cFood.Render_Food(FoodColor,Diameter); }
Here is the Draw food Func:
void DrawFood(float PosX, float PosY,int colNum) { glTranslatef(PosX,PosY,-1.0); glCallList(dListIDFd[colNum]); };
And
void LEVELS::DrawLevel1(){ srand(0); cLevel.DrawFood((rand()%SCREEN_W)-Line_width,rand()%SCREEN_H-Line_width,cLevel.dListIDFd[(rand()%3)]);}
and in this func :
void StateFunc::GameState(){ //Draw our blue borders RED; cScreen.DrawBorders(SCREEN_W,SCREEN_H); glPushMatrix(); //Determine Level Number switch(cLevel.GetLevel()) { case 1: cLevel.DrawLevel1(); break; default: cLevel.DrawLevel1();break; } glPopMatrix(); //Move Mr. Pacman cPacman.Move_Pacman(cPacman.Direction,cPacman.vec2DPos,cPacman.Speed); //Rotate Mr.pacman accordingly glRotatef(cPacman.GetAngle(),0,0,1); //Render Mr.Pacman by switching between D-lists cPacman.Animate_Pacman(cPacman.AnimateChange); //Handle Wall to pacman Collision cHandle_collision.CheckWallToObjectCollision(cPacman.vec2DPos[POS_X],cPacman.vec2DPos[POS_Y],cPacman.vec2DPos,cPacman.Speed); //cout<<"X : "<<cPacman.vec2DPos[POS_X]<<","<<"Y : "<< cPacman.vec2DPos[POS_Y]<<endl;}
and
Its been a while since I first tried to fix this problem. So its not like
I did not try. I am at the point of starting all over, if that. And also this
level1 is just a test