Home > other >  # # sdl2 why can't this function call?? To solve the
# # sdl2 why can't this function call?? To solve the

Time:09-17

The key is the place where two printf, why can output 1, can not output 2??


# include "SDL. H"//a BMP format picture automatically started to move to the lower right corner, after touching the window, bounce off
# include
# include
# include
Int a=1, b=1;
SDL_Rect the rect. Void aaBS ();
Int main (int arg c, char * argv []) {
SDL_Init (SDL_INIT_VIDEO);
SDL_Window * window=SDL_CreateWindow (" automove ", 100100, 800, 600, SDL_WINDOW_SHOWN);
SDL_Surface * surface=SDL_GetWindowSurface (Windows); SDL_Surface * mesurface=SDL_LoadBMP (" me. BMP "); Rend SDL_Renderer *=SDL_CreateRenderer (window, 1, SDL_RENDERER_ACCELERATED); SDL_Texture * me=SDL_CreateTextureFromSurface (rend, mesurface); SDL_Event event; SDL_RenderClear (rend);
The rect. X=1; The rect. Y=1;
The rect. H=mesurface - & gt; h;
The rect. W=mesurface - & gt; w;
Bool quit=false;
While (quit==false) {
While (SDL_PollEvent (& amp; The event)) {
If (event type==SDL_QUIT) {
The quit=true; }
SDL_RenderClear (rend);
Void aaBS (); Printf (" 1 ");
SDL_RenderCopy (rend me, NULL, & amp; The rect); } SDL_Delay (5);
SDL_RenderPresent (rend); } SDL_DestroyWindow (Windows);
SDL_Quit; return 0; }
Void aaBS () {
If (the rect. X & gt;=780 | | the rect. X & lt; 0 {
A=a * (1); }
Else if (the rect. Y & gt;=580 | | the rect. Y & lt; 0 {
B=b * (1); }
The rect. X=the rect. X + a; The rect. Y=the rect. Y + b; Printf (" 2 "); }
  • Related