test/testsprite2.c
changeset 1917 3f54b3ec5a07
parent 1916 c773b0c0ac89
child 1965 a788656ca29a
     1.1 --- a/test/testsprite2.c	Wed Jul 19 05:03:21 2006 +0000
     1.2 +++ b/test/testsprite2.c	Wed Jul 19 05:45:42 2006 +0000
     1.3 @@ -17,6 +17,7 @@
     1.4  static SDL_Rect *velocities;
     1.5  static int sprite_w, sprite_h;
     1.6  static SDL_TextureBlendMode blendMode = SDL_TextureBlendMode_Mask;
     1.7 +static SDL_TextureScaleMode scaleMode = SDL_TextureScaleMode_None;
     1.8  
     1.9  /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
    1.10  static void
    1.11 @@ -87,12 +88,6 @@
    1.12      /* Move the sprite, bounce at the wall, and draw */
    1.13      n = 0;
    1.14      SDL_RenderFill(NULL, BACKGROUND);
    1.15 -    /*
    1.16 -       for (i = 0; i < num_sprites; ++i) {
    1.17 -       position = &positions[i];
    1.18 -       SDL_RenderFill(position, BACKGROUND);
    1.19 -       }
    1.20 -     */
    1.21      for (i = 0; i < num_sprites; ++i) {
    1.22          position = &positions[i];
    1.23          velocity = &velocities[i];
    1.24 @@ -108,8 +103,7 @@
    1.25          }
    1.26  
    1.27          /* Blit the sprite onto the screen */
    1.28 -        SDL_RenderCopy(sprite, NULL, position, blendMode,
    1.29 -                       SDL_TextureScaleMode_None);
    1.30 +        SDL_RenderCopy(sprite, NULL, position, blendMode, scaleMode);
    1.31      }
    1.32  
    1.33      /* Update the screen! */
    1.34 @@ -142,6 +136,9 @@
    1.35                      if (SDL_strcasecmp(argv[i + 1], "none") == 0) {
    1.36                          blendMode = SDL_TextureBlendMode_None;
    1.37                          consumed = 2;
    1.38 +                    } else if (SDL_strcasecmp(argv[i + 1], "mask") == 0) {
    1.39 +                        blendMode = SDL_TextureBlendMode_Mask;
    1.40 +                        consumed = 2;
    1.41                      } else if (SDL_strcasecmp(argv[i + 1], "blend") == 0) {
    1.42                          blendMode = SDL_TextureBlendMode_Blend;
    1.43                          consumed = 2;
    1.44 @@ -153,13 +150,30 @@
    1.45                          consumed = 2;
    1.46                      }
    1.47                  }
    1.48 +            } else if (SDL_strcasecmp(argv[i], "--scale") == 0) {
    1.49 +                if (argv[i + 1]) {
    1.50 +                    if (SDL_strcasecmp(argv[i + 1], "none") == 0) {
    1.51 +                        scaleMode = SDL_TextureScaleMode_None;
    1.52 +                        consumed = 2;
    1.53 +                    } else if (SDL_strcasecmp(argv[i + 1], "fast") == 0) {
    1.54 +                        scaleMode = SDL_TextureScaleMode_Fast;
    1.55 +                        consumed = 2;
    1.56 +                    } else if (SDL_strcasecmp(argv[i + 1], "slow") == 0) {
    1.57 +                        scaleMode = SDL_TextureScaleMode_Slow;
    1.58 +                        consumed = 2;
    1.59 +                    } else if (SDL_strcasecmp(argv[i + 1], "best") == 0) {
    1.60 +                        scaleMode = SDL_TextureScaleMode_Best;
    1.61 +                        consumed = 2;
    1.62 +                    }
    1.63 +                }
    1.64              } else if (SDL_isdigit(*argv[i])) {
    1.65                  num_sprites = SDL_atoi(argv[i]);
    1.66                  consumed = 1;
    1.67              }
    1.68          }
    1.69          if (consumed < 0) {
    1.70 -            fprintf(stderr, "Usage: %s %s [--blend none|blend|add|mod]",
    1.71 +            fprintf(stderr,
    1.72 +                    "Usage: %s %s [--blend none|mask|blend|add|mod] [--scale none|fast|slow|best]",
    1.73                      argv[0], CommonUsage(state));
    1.74              quit(1);
    1.75          }
    1.76 @@ -192,6 +206,10 @@
    1.77          quit(2);
    1.78      }
    1.79      srand(time(NULL));
    1.80 +    if (scaleMode != SDL_TextureScaleMode_None) {
    1.81 +        sprite_w += sprite_w / 2;
    1.82 +        sprite_h += sprite_h / 2;
    1.83 +    }
    1.84      for (i = 0; i < num_sprites; ++i) {
    1.85          positions[i].x = rand() % (state->window_w - sprite_w);
    1.86          positions[i].y = rand() % (state->window_h - sprite_h);