void reshape (int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0.0, (GLdouble) w, 0.0, (GLdouble) h); windowWidth = w; windowHeight = h; image.resize(windowWidth*windowHeight); clearAnimation(); memset(image.data(),0,windowWidth*windowHeight*sizeof(Float3)); // clear image to black initializeAnimation(); glutDisplayFunc(display); } // end function reshape
void keyboard(unsigned char key, int x, int y) { switch(key) { case '\r': // enter key // reset clearAnimation(); memset(image.data(),0,windowWidth*windowHeight*sizeof(Float3)); // clear image to black initializeAnimation(); glutDisplayFunc(display); break; case 27: // escape key exit(0); } // end switch } // end function keyboard
void TileSprite::draw() { if(_animation.frames && _animation.framesCount > 0) { if(_lastFrameTime + _animation.frames[_currentFrameId].delay <= getCurrentTime()) { _tileId = _animation.frames[_currentFrameId].tileId; _currentFrameId++; _lastFrameTime = getCurrentTime(); if(_currentFrameId >= _animation.framesCount) { if(_animation.loop > 0) { _currentFrameId = 0; _animation.loop--; } else clearAnimation(); } } } _texture->drawTile(_tileId, _x, _y, _z, _scale, _scale); }