#include<iostream>
#include<glut.h>
#include "Hero.h"
#include"RGBA.h"
AnimatedSprite *hero;
AnimatedSprite *bg,*fg;
int currentAnim;
float L=0,R=480;
void display()
{
hero = new AnimatedSprite("alladin2.bmp",56,90,0,0,2001);
hero -> colorKey(255,0,255);
bg = new AnimatedSprite("BlueBkg2.bmp",760,480,L,R,2002);
bg -> colorKey(255,255,255);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_EQUAL,GL_ONE);
currentAnim=hero->currentAnimState;
hero->drawSprite();
}
void UpdateSpriteAnimation(void)
{
int currentAnim=hero->currentAnimState;
hero->anim[currentAnim].currentFrames = (hero->anim[currentAnim].currentFrames++);
if(hero->currentAnimState == hero->ANIM_WALK_LEFT)
{
if(hero->x >= L && hero->x <= R-10)
hero->x -= 1.0;
bg->anim[0].u -= 0.005;
fg->anim[0].u -= 0.002;
}
if(hero->currentAnimState == hero->ANIM_WALK_RIGHT)
{
if(hero->x < R)
hero->x += 1.0;
bg->anim[0].u -= 0.005;
fg->anim[0].u -= 0.002;
}
}
void myTimer (int tt)
{
UpdateSpriteAnimation();
glutPostRedisplay();
glutTimerFunc(hero->FRAME_DELAY_SPRITE,myTimer,0);
}
void main(int argc, char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA | GLUT_DEPTH);
glutInitWindowSize(640, 480);
glutInitWindowPosition(10, 10);
glutCreateWindow("Sprites Sheet");
glutDisplayFunc(display);
glutDisplayFunc(UpdateSpriteAnimation);
glutTimerFunc(500,myTimer,1);
glutMainLoop();
}
The break error occured
Unhandled exception at 0x00F76513 0xC0000005:
please help out