Mercurial > sdl-ios-xcode
comparison test/nds-test-progs/sprite2/source/testsprite2.c @ 2750:e3affc66d963
Fixes to the NDS sprite2 test. Illustrates partially working texture-as-sprite functionality.
author | Darren Alton <dalton@stevens.edu> |
---|---|
date | Sat, 06 Sep 2008 04:31:34 +0000 |
parents | 204be4fc2726 |
children | 9dde605c7540 |
comparison
equal
deleted
inserted
replaced
2749:1c5f440a60fe | 2750:e3affc66d963 |
---|---|
4 #include <stdio.h> | 4 #include <stdio.h> |
5 #include <time.h> | 5 #include <time.h> |
6 #include <nds.h> | 6 #include <nds.h> |
7 #include <fat.h> | 7 #include <fat.h> |
8 #include "common.h" | 8 #include "common.h" |
9 | |
10 #include "icon_bmp_bin.h" | |
11 | 9 |
12 #define NUM_SPRITES 10 | 10 #define NUM_SPRITES 10 |
13 #define MAX_SPEED 1 | 11 #define MAX_SPEED 1 |
14 | 12 |
15 static CommonState *state; | 13 static CommonState *state; |
182 /* Initialize test framework */ | 180 /* Initialize test framework */ |
183 state = CommonCreateState(argv, SDL_INIT_VIDEO); | 181 state = CommonCreateState(argv, SDL_INIT_VIDEO); |
184 if (!state) { | 182 if (!state) { |
185 return 1; | 183 return 1; |
186 } | 184 } |
187 for (i = 1; i < argc;) { | 185 |
188 int consumed; | |
189 | |
190 consumed = CommonArg(state, i); | |
191 if (consumed == 0) { | |
192 consumed = -1; | |
193 if (SDL_strcasecmp(argv[i], "--blend") == 0) { | |
194 if (argv[i + 1]) { | |
195 if (SDL_strcasecmp(argv[i + 1], "none") == 0) { | |
196 blendMode = SDL_TEXTUREBLENDMODE_NONE; | |
197 consumed = 2; | |
198 } else if (SDL_strcasecmp(argv[i + 1], "mask") == 0) { | |
199 blendMode = SDL_TEXTUREBLENDMODE_MASK; | |
200 consumed = 2; | |
201 } else if (SDL_strcasecmp(argv[i + 1], "blend") == 0) { | |
202 blendMode = SDL_TEXTUREBLENDMODE_BLEND; | |
203 consumed = 2; | |
204 } else if (SDL_strcasecmp(argv[i + 1], "add") == 0) { | |
205 blendMode = SDL_TEXTUREBLENDMODE_ADD; | |
206 consumed = 2; | |
207 } else if (SDL_strcasecmp(argv[i + 1], "mod") == 0) { | |
208 blendMode = SDL_TEXTUREBLENDMODE_MOD; | |
209 consumed = 2; | |
210 } | |
211 } | |
212 } else if (SDL_strcasecmp(argv[i], "--scale") == 0) { | |
213 if (argv[i + 1]) { | |
214 if (SDL_strcasecmp(argv[i + 1], "none") == 0) { | |
215 scaleMode = SDL_TEXTURESCALEMODE_NONE; | |
216 consumed = 2; | |
217 } else if (SDL_strcasecmp(argv[i + 1], "fast") == 0) { | |
218 scaleMode = SDL_TEXTURESCALEMODE_FAST; | |
219 consumed = 2; | |
220 } else if (SDL_strcasecmp(argv[i + 1], "slow") == 0) { | |
221 scaleMode = SDL_TEXTURESCALEMODE_SLOW; | |
222 consumed = 2; | |
223 } else if (SDL_strcasecmp(argv[i + 1], "best") == 0) { | |
224 scaleMode = SDL_TEXTURESCALEMODE_BEST; | |
225 consumed = 2; | |
226 } | |
227 } | |
228 } else if (SDL_strcasecmp(argv[i], "--cyclecolor") == 0) { | |
229 cycle_color = SDL_TRUE; | |
230 consumed = 1; | |
231 } else if (SDL_strcasecmp(argv[i], "--cyclealpha") == 0) { | |
232 cycle_alpha = SDL_TRUE; | |
233 consumed = 1; | |
234 } else if (SDL_isdigit(*argv[i])) { | |
235 num_sprites = SDL_atoi(argv[i]); | |
236 consumed = 1; | |
237 } | |
238 } | |
239 if (consumed < 0) { | |
240 fprintf(stderr, | |
241 "Usage: %s %s [--blend none|mask|blend|add|mod] [--scale none|fast|slow|best] [--cyclecolor] [--cyclealpha]\n", | |
242 argv[0], CommonUsage(state)); | |
243 quit(1); | |
244 } | |
245 i += consumed; | |
246 } | |
247 if (!CommonInit(state)) { | 186 if (!CommonInit(state)) { |
248 quit(2); | 187 quit(2); |
249 } | 188 } |
250 | 189 |
251 /* Create the windows, initialize the renderers, and load the textures */ | 190 /* Create the windows, initialize the renderers, and load the textures */ |
257 } | 196 } |
258 for (i = 0; i < state->num_windows; ++i) { | 197 for (i = 0; i < state->num_windows; ++i) { |
259 SDL_SelectRenderer(state->windows[i]); | 198 SDL_SelectRenderer(state->windows[i]); |
260 SDL_RenderFill(0xA0, 0xA0, 0xA0, 0xFF, NULL); | 199 SDL_RenderFill(0xA0, 0xA0, 0xA0, 0xFF, NULL); |
261 } | 200 } |
262 if (LoadSprite2(icon_bmp_bin, icon_bmp_bin_size) < 0) { | 201 if (LoadSprite("icon.bmp") < 0) { |
263 printf("errored.\n"); | 202 printf("\nerrored.\n"); |
203 while (1); | |
264 quit(2); | 204 quit(2); |
265 } | 205 } |
266 | 206 |
267 /* Allocate memory for the sprite info */ | 207 /* Allocate memory for the sprite info */ |
268 positions = (SDL_Rect *) SDL_malloc(num_sprites * sizeof(SDL_Rect)); | 208 positions = (SDL_Rect *) SDL_malloc(num_sprites * sizeof(SDL_Rect)); |