The enemy cpp is as I posted above, here is my main
Thanks!
#include "glut.h"#include "glm.h"GLMmodel *model_tankBase;GLMmodel *model_tankTurret;float baseScaleX = 8.0, baseScaleY = 8.0, baseScaleZ = 8.0;float baseTranslateX = 0.0, baseTranslateY = 0.0, baseTranslateZ = 0.0;float baseRotateZ = 0.0;float turretRotateZ = 0.0;int state = 2;#include <cmath>#include <stdlib.h>#include <stdarg.h>#include <iostream>#include <memory.h>#include <time.h>#include <fstream>#include "Enemy.cpp"#define PI 3.141592654using namespace std;// Default Image dimensionsint imageWidth = 640;int imageHeight = 480;// the circle object, initialized in setupGL()GLUquadricObj* circle = NULL; //OpenGL Callsvoid setupGL();void CheckGLError();//Callbacksvoid Display();void Idle();void Reshape(int w, int h);void Keyboard (unsigned char key, int , int );void SpecialKeyboard(int key, int x, int y);void MouseButton(int button, int state, int x, int y);void MouseMotion(int x, int y);//fontGLvoid *font_style = GLUT_BITMAP_HELVETICA_12;// a cleanup functionvoid quit(int i = 0);void main(int argc, char **argv){ // INITIALIZE THE GLUT WINDOW glutInit(&argc, argv); glutInitWindowSize(imageWidth, imageHeight); glutInitDisplayString("rgb double"); glutInitWindowPosition(0, 0); glutCreateWindow("Project #1"); //SETUP GLUT CALLBACKS cout << "Setting up callbacks... "; glutDisplayFunc(Display); glutKeyboardFunc(Keyboard); glutSpecialFunc(SpecialKeyboard); glutMouseFunc(MouseButton); glutMotionFunc(MouseMotion); glutReshapeFunc(Reshape); glutIdleFunc(Idle); cout << "[completed]\n"; glEnable(GL_DEPTH_TEST); //SETUP MISC GL setupGL(); CheckGLError(); model_tankBase = glmReadOBJ("data/tankBase.obj"); model_tankTurret = glmReadOBJ("data/tankTurret.obj"); glutMainLoop();}// This function checks the state of openGL and prints // an error if an error has occurredvoid CheckGLError(){ GLenum error; error = glGetError(); if (error!=GL_NO_ERROR) { cout << "OpenGL reports an error: "<< gluErrorString(error) << endl; quit(1); }}//drawstr method from Nate Robbins tutorials, 1997void drawstr(GLuint x, GLuint y, char* format, ...){ va_list args; char buffer[255], *s; va_start(args, format); vsprintf(buffer, format, args); va_end(args); glRasterPos2i(x, y); for (s = buffer; *s; s++) glutBitmapCharacter(font_style, *s);} Enemy enemies[5]; //enemies[0] = new Enemy(); enemies[0].setCurrentX(90.0); enemies[0].setCurrentY(50.0);//STATESvoid level_menu(){ //enemies[1]->draw(); //enemies[1]->move();}void level_01(){ glPushMatrix(); //Push base glTranslatef(baseTranslateX,baseTranslateY,0); glRotatef(baseRotateZ, 0, 0, 1); glScalef(baseScaleX, baseScaleY, baseScaleZ); glmDraw(model_tankBase,GLM_TEXTURE); glPushMatrix(); //Push turret glTranslatef(0,0,0); glRotatef(turretRotateZ,0,0,1); glScalef(1, 1, 1); glmDraw(model_tankTurret,GLM_TEXTURE); glPopMatrix(); glPopMatrix();}void level_credits(){}//END STATESvoid Display(){ // clear the screen glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Render the model if(state == 1){ level_menu(); } else if(state == 2){ level_01(); } else{ level_credits(); } //draw text drawstr(30.0, 460, "x = "); drawstr(50.0, 460, "%.1f", 3.0); // swap the buffers glutSwapBuffers();}//HELPERSfloat convertToRadians(float degree){ float radian; radian = (PI/180)*degree; return radian + (PI/2); //I add PI/2 because the coordinate system is off by 90 degrees}//TRANSFORMATIONSvoid baseScaleUp(){ if(baseScaleX <= 12 && baseScaleY <= 12 && baseScaleZ <= 12){ baseScaleX++; baseScaleY++; baseScaleZ++; }}void baseScaleDown(){ if(baseScaleX > 1 && baseScaleY > 1 && baseScaleZ > 1){ baseScaleX--; baseScaleY--; baseScaleZ--; }}void baseTranslatePositive(){ baseTranslateX += 2*cos(convertToRadians(baseRotateZ)); baseTranslateY += 2*sin(convertToRadians(baseRotateZ));}void baseTranslateNegative(){ baseTranslateX -= 2*cos(convertToRadians(baseRotateZ)); baseTranslateY -= 2*sin(convertToRadians(baseRotateZ));}void baseRotateZPositive(){ baseRotateZ += 1; if(baseRotateZ >= 360){ baseRotateZ = 0; }}void baseRotateZNegative(){ baseRotateZ -= 1; if(baseRotateZ >= 360){ baseRotateZ = 0; }}void turretRotateZPositive(){ turretRotateZ += 3; if(turretRotateZ >= 360){ baseRotateZ = 0; }}void turretRotateZNegative(){ turretRotateZ -= 3; if(turretRotateZ >= 360){ baseRotateZ = 0; }}//END TRANSFORMATIONS// set up GL stuffvoid setupGL() { // set the clear color glClearColor(0.0, 0.0, 0.0, 1.0); // background color // initialize the circle object circle = gluNewQuadric(); if (!circle) { cout << "The circle object could not be created! Quitting..." << endl; quit(1); }}// This function is continuously called when events are not being received// by the window. This is a good place to update the state of your objects // after every frame.void Idle() { glutPostRedisplay();}// This functions handles what happens when the window is reshapedvoid Reshape(int w, int h) { imageWidth = w; imageHeight = h; glViewport(0,0,w,h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(-100, 100, -100, 100); glMatrixMode(GL_MODELVIEW); glLoadIdentity();}void processNormalKeys(unsigned char key, int x, int y) { if (key == 27) exit(0);}// a cleanup function. call this when you want to exit.void quit(int i) { // cleanup the circle object if (circle) gluDeleteQuadric(circle); exit(i);}void SpecialKeyboard(int key, int x, int y){ switch(key){ case GLUT_KEY_UP: baseTranslatePositive(); break; case GLUT_KEY_DOWN: baseTranslateNegative(); break; case GLUT_KEY_LEFT: baseRotateZPositive(); break; case GLUT_KEY_RIGHT: baseRotateZNegative(); break; }}// keyboard handlervoid Keyboard (unsigned char key, int , int ){ switch(key) { // if esc or q, exit case 27: case 'u': baseScaleUp(); break; case 'i': baseScaleDown(); break; case 'n': turretRotateZPositive(); break; case 'm': turretRotateZNegative(); break; }}void MouseButton(int button, int state, int x, int y){ switch (button) { case GLUT_LEFT_BUTTON: break; case GLUT_MIDDLE_BUTTON: break; case GLUT_RIGHT_BUTTON: break; }}void MouseMotion(int x, int y){}