Guest User

Untitled

a guest
Jun 19th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.96 KB | None | 0 0
  1.  
  2. void start_GW(SDL_Surface *screen,struct S_SPRITESHEET *S_sprite,SDL_Event event)
  3. {
  4.  
  5.  
  6.   /* Load Background */
  7.   if (GW_background == NULL) { GW_background = IMG_Load("Img/Screen1.png"); }
  8.   SDL_BlitSurface(GW_background,NULL,SDL_GetVideoSurface(),NULL);
  9.  
  10.   /* Initial Position */
  11.  
  12.     S_sprite->link_src.x = 50;
  13.     S_sprite->link_src.y = 0;
  14.     S_sprite->link_src.h = 53;
  15.     S_sprite->link_src.w = 39;
  16.  
  17.  
  18.     S_sprite->link_dst.y = 70;
  19.  
  20.    
  21.     /* Move Link  */
  22.     if(event.key.keysym.sym == SDLK_RIGHT) {
  23.  
  24.       if(x <= 190) { x += 20; }
  25.       SDL_Delay(100);
  26.     }
  27.     if(event.key.keysym.sym == SDLK_LEFT) {
  28.       if(x >= 55) { x -=  20; }
  29.     }  
  30.  
  31.     S_sprite->link_dst.x = x;
  32.     if (S_sprite->link_dst.x == 200) {S_sprite->link_dst.x == 200; }
  33.      
  34.      
  35.    
  36.     SDL_BlitSurface(S_sprite->img,&S_sprite->link_src,SDL_GetVideoSurface(),&S_sprite->link_dst);
  37.     /* Don't return to initial position */
  38.     initial = 1;  
  39. }
Add Comment
Please, Sign In to add comment