Created
September 20, 2014 09:45
-
-
Save saad749/3aa081c5391996e578a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Includes.h" | |
using namespace std; | |
void display(void); | |
void myTimer(int id); | |
void registerCallbacks(); | |
/* Setup Data */ | |
// initialize a setup object | |
_Setup *mySetup = new _Setup(); | |
// acess all your constants with 'myConstant' from anywhere in your project | |
// all your structs are available to you anywhere in your project | |
Shanu *myLib = new Shanu(); | |
/* Global Data */ | |
Rect R1 = { -5, -5, 4, 2 }; | |
Rect R2 = { -5, -4, 1, 2 }; | |
Enemies *Enemy1; | |
int main(int argc, char *argv[]){ | |
glutInit(&argc, argv); | |
/* Project Environment Setup */ | |
mySetup->setupEnvironment( | |
"Simple Project Structure", | |
Screen{ 800, 480 }, | |
Screen{ 50, 50 }, | |
CartesianSystem{ 0, 800, 0, 800 } | |
); | |
Enemy1 = new Enemies("run.bmp", 79, 86, 0, 0, 2001); | |
glClearColor(1.0f, 1.0f, 1.0f, 1.0); | |
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | |
glMatrixMode(GL_PROJECTION); | |
glLoadIdentity(); | |
glMatrixMode(GL_MODELVIEW); | |
glLoadIdentity(); | |
gluOrtho2D(0, 800, 0, 800); | |
glViewport(0, 0, 800, 480); | |
registerCallbacks(); // event handlers | |
glutMainLoop(); // wait state | |
} | |
void display(void){ | |
glEnable(GL_DEPTH_TEST); | |
glEnable(GL_TEXTURE_2D); | |
glEnable(GL_ALPHA_TEST); | |
glEnable(GL_NORMALIZE); | |
glEnable(GL_COLOR_MATERIAL); | |
glAlphaFunc(GL_EQUAL, GL_ONE); | |
// Drawing Area | |
//glColor3f(0.5, 0.2, 0.9); | |
//mySetup->showCoordsLine(); | |
Enemy1->draw(); | |
glutSwapBuffers(); | |
} | |
void myTimer(int id){ | |
// Change Postion, Change Size, Change Orientation, use your object update() method | |
Enemy1->update(); | |
glutPostRedisplay(); | |
glutTimerFunc(myConstant.FRAME_DELAY_SPRITE, myTimer, 1); | |
} | |
void registerCallbacks(){ | |
glutDisplayFunc(display); | |
glutTimerFunc(myConstant.FRAME_DELAY_SPRITE, myTimer, 1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment