0

スペースキーを押したときに画像を描画したい。これは私のコードです:

void drawImage()
{
   rect.x = 100;
   rect.y = 100;

   SDL_Surface *image = IMG_Load("image.png");
   SDL_BlitSurface(image, NULL, screen, &rect);
}

これは次のように呼ばれます。

while (SDL_PollEvent(&event))
{
    if (event.type == SDL_QUIT)
    {
        gameRunning = false;
    }
    if (event.type == SDL_KEYDOWN)
    {
        if (event.key.keysym.sym == SDLK_SPACE)
        {
            drawImage();
        }
    }

}

スペースキーを押しても画像が描画されません。なにが問題ですか?

4

3 に答える 3

2

画面バッファ (SDL_Surfaces) を反転します

于 2013-06-10T16:07:30.743 に答える