void GenericSkin::keyReleased(int mak) { for(size_t i = 0; i < keyRects.size(); i++) { if(keyRects[i].keyCode == mak) { SDL_Rect clipRect; SDL_GetClipRect(getWindowSurface(), &clipRect); SDL_SetClipRect(getWindowSurface(), &windowRect); SDL_Rect src = { (Sint16)keyRects[i].x, (Sint16)keyRects[i].y, (Uint16)keyRects[i].w, (Uint16)keyRects[i].h }; SDL_BlitSurface(unselectedPhone, &src, getWindowSurface(), &src); SDL_UpdateRect(getWindowSurface(), src.x, src.y, src.w, src.h); SDL_SetClipRect(getWindowSurface(), &clipRect); return; } } }
void game::gameloop(){ // Mix_SetPostMix(band_separate, &au); //Mix_PlayMusic( music, -1 ); int score = 0; int cooldown = 20; while(shouldIQuit() == false) { if ((cooldown<0)&&au->poll_beat(0)){ //srand(au.poll_sig(4)); for (int i =0; i<rand()%10; i++) { baddie *b = new baddie(this); sprite_list.push_back(b); cooldown = 10; } } cooldown--; keys = SDL_GetKeyState( NULL ); bg->updateBackground(getWindowSurface()); std::list<sprite*>::iterator i; for(i=sprite_list.begin(); i != sprite_list.end(); ++i) { sprite *bees = *i; if (bees->removeMe) { i = sprite_list.erase(i); delete bees; } } for(i=sprite_list.begin(); i != sprite_list.end(); ++i) { (*i)->moveSprite(); } for(i=sprite_list.begin(); i != sprite_list.end(); ++i) { (*i)->renderSprite(); } h->displayText(10,10,"Score: %i0",score/10); if ((*sprite_list.begin())->currentState==IDLE){ if(2*(*sprite_list.begin())->xpos>SCREEN_WIDTH) { score+=2;} else {score++;}} if ((*sprite_list.begin())->currentState==DYING)score-=3; if ((*sprite_list.begin())->currentState==DEAD)score-=6; if (score <0) score = 0; Flip(); } }
void GenericSkin::drawMultiTouchSimulation() const { if( !mIsSimulatingMultiTouch ) return; SDL_Rect clipRect; SDL_GetClipRect(getWindowSurface(), &clipRect); SDL_SetClipRect(getWindowSurface(), &screenRect); SDL_Rect dstRect = sMultiTouchImage->clip_rect; // Calculates the spacing so that the little marker // will be drawn at the center of the touch event int xSpacing = (windowRect.x - screenRect.x) + (dstRect.w / 2); int ySpacing = (windowRect.y - screenRect.y) + (dstRect.h / 2); // Draw first touch event dstRect.x = mLastKnownMousePosition[0].first - xSpacing; dstRect.y = mLastKnownMousePosition[0].second - ySpacing; SDL_BlitSurface(sMultiTouchImage, NULL, getWindowSurface(), &dstRect); // Draw second touch event dstRect.x = mLastKnownMousePosition[1].first - xSpacing; dstRect.y = mLastKnownMousePosition[1].second - ySpacing; SDL_BlitSurface(sMultiTouchImage, NULL, getWindowSurface(), &dstRect); SDL_UpdateRect(getWindowSurface(), windowRect.x, windowRect.y, windowRect.w, windowRect.h); SDL_SetClipRect(getWindowSurface(), &clipRect); }