我想要一個項目符號移動,當我點擊空間。首先,當空間被按下時,子彈圖像被點亮,同時定時器啓動,當它達到5000毫秒時,圖像的x值應該改變。這是我的代碼:子彈運動SDL/C++
SDL_Rect bulletRect;
bulletRect.x = dstX+31; //dstX/Y is the source destination of another image where the bullet should be drawn
bulletRect.y = dstY+10.5;
SDL_Surface *bullet = IMG_Load(bullet.png");
if (drawBullet) //bool set to true in the space key event.
{
SDL_BlitSurface(bullet, NULL, screen, &bulletRect);
//timer
my_timer.start(); //starts the timer
if (SDL_GetTicks() == 5000) //if 5 sec
{
bulletRect.x += 10;
}
}
圖像只圖混合,但5秒鐘後沒有任何反應。哪裏不對?
以外我確實建議查看['Model | View | Controller'](https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80 %93控制器)分離的擔憂。無論如何, –