|
@@ -30,7 +30,9 @@ int main()
|
|
|
|
|
|
// [2.2] Other components
|
|
|
SDL_Surface* grass = SDL_LoadBMP("textures/grass.bmp");
|
|
|
+ SDL_Surface* pawn = SDL_LoadBMP("textures/pawn.bmp");
|
|
|
SDL_Rect pos({0, 0, 0, 0});
|
|
|
+ SDL_Rect pawnPos({0, 0, 0, 0});
|
|
|
|
|
|
/// [3] Main loop
|
|
|
bool done(false);
|
|
@@ -49,6 +51,10 @@ int main()
|
|
|
if (event.key.keysym.sym == SDLK_ESCAPE)
|
|
|
done = true;
|
|
|
break;
|
|
|
+ case SDL_MOUSEMOTION:
|
|
|
+ pawnPos.x = event.motion.x - pawn->w / 2;
|
|
|
+ pawnPos.y = event.motion.y - pawn->h / 2;
|
|
|
+ break;
|
|
|
} // end switch event type
|
|
|
} // end of message processing
|
|
|
|
|
@@ -62,6 +68,8 @@ int main()
|
|
|
for (pos.x = 0; pos.x < width; pos.x += grass->w)
|
|
|
SDL_BlitSurface(grass, NULL, screen, &pos);
|
|
|
|
|
|
+ SDL_BlitSurface(pawn, NULL, screen, &pawnPos);
|
|
|
+
|
|
|
SDL_Flip(screen);
|
|
|
|
|
|
SDL_Delay(16);
|
|
@@ -69,6 +77,7 @@ int main()
|
|
|
|
|
|
///[4] Free components
|
|
|
SDL_FreeSurface(grass);
|
|
|
+ SDL_FreeSurface(pawn);
|
|
|
|
|
|
SDL_FreeSurface(screen);
|
|
|
|