Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Added more tests for the different primitive types
  • Loading branch information
slouken committed Sep 19, 2009
1 parent 0ee6f94 commit 30b43e4
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion test/testsprite2.c
Expand Up @@ -100,6 +100,7 @@ MoveSprites(SDL_WindowID window, SDL_TextureID sprite)
{
int i, n;
int window_w, window_h;
SDL_Rect temp;
SDL_Rect *position, *velocity;

SDL_SelectRenderer(window);
Expand Down Expand Up @@ -138,13 +139,52 @@ MoveSprites(SDL_WindowID window, SDL_TextureID sprite)
SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
SDL_RenderFill(NULL);

/* Draw two red points to make sure they show up correctly */
/* Test points */
SDL_SetRenderDrawColor(0xFF, 0x00, 0x00, 0xFF);
SDL_RenderPoint(0, 0);
SDL_RenderPoint(window_w-1, 0);
SDL_RenderPoint(0, window_h-1);
SDL_RenderPoint(window_w-1, window_h-1);

/* Test horizontal and vertical lines */
SDL_SetRenderDrawColor(0x00, 0xFF, 0x00, 0xFF);
SDL_RenderLine(1, 0, window_w-2, 0);
SDL_RenderLine(1, window_h-1, window_w-2, window_h-1);
SDL_RenderLine(0, 1, 0, window_h-2);
SDL_RenderLine(window_w-1, 1, window_w-1, window_h-2);

/* Test fill */
SDL_SetRenderDrawColor(0xFF, 0xFF, 0xFF, 0xFF);
temp.x = window_w-sprite_w-1;
temp.y = 1;
temp.w = sprite_w;
temp.h = sprite_h;
SDL_RenderFill(&temp);
temp.x = 1;
temp.y = window_h-sprite_h-1;
temp.w = sprite_w;
temp.h = sprite_h;
SDL_RenderFill(&temp);

/* Test copy */
temp.x = 1;
temp.y = 1;
temp.w = sprite_w;
temp.h = sprite_h;
SDL_RenderCopy(sprite, NULL, &temp);
temp.x = window_w-sprite_w-1;
temp.y = window_h-sprite_h-1;
temp.w = sprite_w;
temp.h = sprite_h;
SDL_RenderCopy(sprite, NULL, &temp);

/* Test diagonal lines */
SDL_SetRenderDrawColor(0x00, 0xFF, 0x00, 0xFF);
SDL_RenderLine(sprite_w, sprite_h,
window_w-sprite_w-2, window_h-sprite_h-2);
SDL_RenderLine(window_w-sprite_w-2, sprite_h,
sprite_w, window_h-sprite_h-2);

/* Move the sprite, bounce at the wall, and draw */
n = 0;
for (i = 0; i < num_sprites; ++i) {
Expand Down

0 comments on commit 30b43e4

Please sign in to comment.