Mercurial > sdl-ios-xcode
comparison test/testsprite2.c @ 3265:8f534bf37bef
Added more tests for the different primitive types
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 19 Sep 2009 05:43:15 +0000 |
parents | 8fe0806637df |
children | 7856dfe3a44f |
comparison
equal
deleted
inserted
replaced
3264:8fe0806637df | 3265:8f534bf37bef |
---|---|
98 void | 98 void |
99 MoveSprites(SDL_WindowID window, SDL_TextureID sprite) | 99 MoveSprites(SDL_WindowID window, SDL_TextureID sprite) |
100 { | 100 { |
101 int i, n; | 101 int i, n; |
102 int window_w, window_h; | 102 int window_w, window_h; |
103 SDL_Rect temp; | |
103 SDL_Rect *position, *velocity; | 104 SDL_Rect *position, *velocity; |
104 | 105 |
105 SDL_SelectRenderer(window); | 106 SDL_SelectRenderer(window); |
106 | 107 |
107 /* Query the sizes */ | 108 /* Query the sizes */ |
136 | 137 |
137 /* Draw a gray background */ | 138 /* Draw a gray background */ |
138 SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF); | 139 SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF); |
139 SDL_RenderFill(NULL); | 140 SDL_RenderFill(NULL); |
140 | 141 |
141 /* Draw two red points to make sure they show up correctly */ | 142 /* Test points */ |
142 SDL_SetRenderDrawColor(0xFF, 0x00, 0x00, 0xFF); | 143 SDL_SetRenderDrawColor(0xFF, 0x00, 0x00, 0xFF); |
143 SDL_RenderPoint(0, 0); | 144 SDL_RenderPoint(0, 0); |
144 SDL_RenderPoint(window_w-1, 0); | 145 SDL_RenderPoint(window_w-1, 0); |
145 SDL_RenderPoint(0, window_h-1); | 146 SDL_RenderPoint(0, window_h-1); |
146 SDL_RenderPoint(window_w-1, window_h-1); | 147 SDL_RenderPoint(window_w-1, window_h-1); |
148 | |
149 /* Test horizontal and vertical lines */ | |
150 SDL_SetRenderDrawColor(0x00, 0xFF, 0x00, 0xFF); | |
151 SDL_RenderLine(1, 0, window_w-2, 0); | |
152 SDL_RenderLine(1, window_h-1, window_w-2, window_h-1); | |
153 SDL_RenderLine(0, 1, 0, window_h-2); | |
154 SDL_RenderLine(window_w-1, 1, window_w-1, window_h-2); | |
155 | |
156 /* Test fill */ | |
157 SDL_SetRenderDrawColor(0xFF, 0xFF, 0xFF, 0xFF); | |
158 temp.x = window_w-sprite_w-1; | |
159 temp.y = 1; | |
160 temp.w = sprite_w; | |
161 temp.h = sprite_h; | |
162 SDL_RenderFill(&temp); | |
163 temp.x = 1; | |
164 temp.y = window_h-sprite_h-1; | |
165 temp.w = sprite_w; | |
166 temp.h = sprite_h; | |
167 SDL_RenderFill(&temp); | |
168 | |
169 /* Test copy */ | |
170 temp.x = 1; | |
171 temp.y = 1; | |
172 temp.w = sprite_w; | |
173 temp.h = sprite_h; | |
174 SDL_RenderCopy(sprite, NULL, &temp); | |
175 temp.x = window_w-sprite_w-1; | |
176 temp.y = window_h-sprite_h-1; | |
177 temp.w = sprite_w; | |
178 temp.h = sprite_h; | |
179 SDL_RenderCopy(sprite, NULL, &temp); | |
180 | |
181 /* Test diagonal lines */ | |
182 SDL_SetRenderDrawColor(0x00, 0xFF, 0x00, 0xFF); | |
183 SDL_RenderLine(sprite_w, sprite_h, | |
184 window_w-sprite_w-2, window_h-sprite_h-2); | |
185 SDL_RenderLine(window_w-sprite_w-2, sprite_h, | |
186 sprite_w, window_h-sprite_h-2); | |
147 | 187 |
148 /* Move the sprite, bounce at the wall, and draw */ | 188 /* Move the sprite, bounce at the wall, and draw */ |
149 n = 0; | 189 n = 0; |
150 for (i = 0; i < num_sprites; ++i) { | 190 for (i = 0; i < num_sprites; ++i) { |
151 position = &positions[i]; | 191 position = &positions[i]; |