annotate test/nds-test-progs/sprite2/source/testsprite2.c @ 2686:e9f27fe4f2a1 gsoc2008_nds

Existing testsprite programs made into NDS projects
author Darren Alton <dalton@stevens.edu>
date Wed, 13 Aug 2008 00:49:03 +0000
parents
children cd8978f47849
rev   line source
2686
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
1 /* Simple program: Move N sprites around on the screen as fast as possible */
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
2
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
3 #include <stdlib.h>
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
4 #include <stdio.h>
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
5 #include <time.h>
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
6 #include <nds.h>
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
7 #include "common.h"
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
8
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
9 #define NUM_SPRITES 100
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
10 #define MAX_SPEED 1
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
11
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
12 static CommonState *state;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
13 static int num_sprites;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
14 static SDL_TextureID *sprites;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
15 static SDL_bool cycle_color;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
16 static SDL_bool cycle_alpha;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
17 static int cycle_direction = 1;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
18 static int current_alpha = 0;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
19 static int current_color = 0;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
20 static SDL_Rect *positions;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
21 static SDL_Rect *velocities;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
22 static int sprite_w, sprite_h;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
23 static SDL_TextureBlendMode blendMode = SDL_TEXTUREBLENDMODE_MASK;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
24 static SDL_TextureScaleMode scaleMode = SDL_TEXTURESCALEMODE_NONE;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
25
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
26 /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
27 static void
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
28 quit(int rc)
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
29 {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
30 if (sprites) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
31 SDL_free(sprites);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
32 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
33 if (positions) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
34 SDL_free(positions);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
35 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
36 if (velocities) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
37 SDL_free(velocities);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
38 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
39 CommonQuit(state);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
40 exit(rc);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
41 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
42
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
43 int
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
44 LoadSprite(char *file)
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
45 {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
46 int i;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
47 SDL_Surface *temp;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
48
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
49 /* Load the sprite image */
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
50 temp = SDL_LoadBMP(file);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
51 if (temp == NULL) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
52 fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError());
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
53 return (-1);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
54 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
55 sprite_w = temp->w;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
56 sprite_h = temp->h;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
57
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
58 /* Set transparent pixel as the pixel at (0,0) */
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
59 if (temp->format->palette) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
60 SDL_SetColorKey(temp, SDL_SRCCOLORKEY, *(Uint8 *) temp->pixels);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
61 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
62
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
63 /* Create textures from the image */
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
64 for (i = 0; i < state->num_windows; ++i) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
65 SDL_SelectRenderer(state->windows[i]);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
66 sprites[i] = SDL_CreateTextureFromSurface(0, temp);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
67 if (!sprites[i]) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
68 fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError());
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
69 SDL_FreeSurface(temp);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
70 return (-1);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
71 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
72 SDL_SetTextureBlendMode(sprites[i], blendMode);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
73 SDL_SetTextureScaleMode(sprites[i], scaleMode);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
74 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
75 SDL_FreeSurface(temp);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
76
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
77 /* We're ready to roll. :) */
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
78 return (0);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
79 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
80
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
81 void
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
82 MoveSprites(SDL_WindowID window, SDL_TextureID sprite)
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
83 {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
84 int i, n;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
85 int window_w, window_h;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
86 SDL_Rect area, *position, *velocity;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
87
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
88 SDL_SelectRenderer(window);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
89
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
90 /* Query the sizes */
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
91 SDL_GetWindowSize(window, &window_w, &window_h);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
92
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
93 /* Cycle the color and alpha, if desired */
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
94 if (cycle_color) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
95 current_color += cycle_direction;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
96 if (current_color < 0) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
97 current_color = 0;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
98 cycle_direction = -cycle_direction;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
99 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
100 if (current_color > 255) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
101 current_color = 255;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
102 cycle_direction = -cycle_direction;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
103 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
104 SDL_SetTextureColorMod(sprite, 255, (Uint8) current_color,
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
105 (Uint8) current_color);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
106 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
107 if (cycle_alpha) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
108 current_alpha += cycle_direction;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
109 if (current_alpha < 0) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
110 current_alpha = 0;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
111 cycle_direction = -cycle_direction;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
112 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
113 if (current_alpha > 255) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
114 current_alpha = 255;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
115 cycle_direction = -cycle_direction;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
116 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
117 SDL_SetTextureAlphaMod(sprite, (Uint8) current_alpha);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
118 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
119
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
120 /* Move the sprite, bounce at the wall, and draw */
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
121 n = 0;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
122 SDL_RenderFill(0xA0, 0xA0, 0xA0, 0xFF, NULL);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
123 for (i = 0; i < num_sprites; ++i) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
124 position = &positions[i];
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
125 velocity = &velocities[i];
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
126 position->x += velocity->x;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
127 if ((position->x < 0) || (position->x >= (window_w - sprite_w))) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
128 velocity->x = -velocity->x;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
129 position->x += velocity->x;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
130 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
131 position->y += velocity->y;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
132 if ((position->y < 0) || (position->y >= (window_h - sprite_w))) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
133 velocity->y = -velocity->y;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
134 position->y += velocity->y;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
135 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
136
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
137 /* Blit the sprite onto the screen */
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
138 SDL_RenderCopy(sprite, NULL, position);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
139 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
140
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
141 /* Update the screen! */
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
142 SDL_RenderPresent();
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
143 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
144
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
145 int
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
146 main(int argc, char *argv[])
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
147 {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
148 int i, done;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
149 SDL_Event event;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
150 Uint32 then, now, frames;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
151
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
152 /* Initialize parameters */
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
153 num_sprites = NUM_SPRITES;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
154
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
155 /* Initialize test framework */
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
156 state = CommonCreateState(argv, SDL_INIT_VIDEO);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
157 if (!state) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
158 return 1;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
159 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
160 for (i = 1; i < argc;) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
161 int consumed;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
162
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
163 consumed = CommonArg(state, i);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
164 if (consumed == 0) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
165 consumed = -1;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
166 if (SDL_strcasecmp(argv[i], "--blend") == 0) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
167 if (argv[i + 1]) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
168 if (SDL_strcasecmp(argv[i + 1], "none") == 0) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
169 blendMode = SDL_TEXTUREBLENDMODE_NONE;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
170 consumed = 2;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
171 } else if (SDL_strcasecmp(argv[i + 1], "mask") == 0) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
172 blendMode = SDL_TEXTUREBLENDMODE_MASK;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
173 consumed = 2;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
174 } else if (SDL_strcasecmp(argv[i + 1], "blend") == 0) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
175 blendMode = SDL_TEXTUREBLENDMODE_BLEND;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
176 consumed = 2;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
177 } else if (SDL_strcasecmp(argv[i + 1], "add") == 0) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
178 blendMode = SDL_TEXTUREBLENDMODE_ADD;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
179 consumed = 2;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
180 } else if (SDL_strcasecmp(argv[i + 1], "mod") == 0) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
181 blendMode = SDL_TEXTUREBLENDMODE_MOD;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
182 consumed = 2;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
183 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
184 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
185 } else if (SDL_strcasecmp(argv[i], "--scale") == 0) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
186 if (argv[i + 1]) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
187 if (SDL_strcasecmp(argv[i + 1], "none") == 0) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
188 scaleMode = SDL_TEXTURESCALEMODE_NONE;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
189 consumed = 2;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
190 } else if (SDL_strcasecmp(argv[i + 1], "fast") == 0) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
191 scaleMode = SDL_TEXTURESCALEMODE_FAST;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
192 consumed = 2;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
193 } else if (SDL_strcasecmp(argv[i + 1], "slow") == 0) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
194 scaleMode = SDL_TEXTURESCALEMODE_SLOW;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
195 consumed = 2;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
196 } else if (SDL_strcasecmp(argv[i + 1], "best") == 0) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
197 scaleMode = SDL_TEXTURESCALEMODE_BEST;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
198 consumed = 2;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
199 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
200 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
201 } else if (SDL_strcasecmp(argv[i], "--cyclecolor") == 0) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
202 cycle_color = SDL_TRUE;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
203 consumed = 1;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
204 } else if (SDL_strcasecmp(argv[i], "--cyclealpha") == 0) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
205 cycle_alpha = SDL_TRUE;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
206 consumed = 1;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
207 } else if (SDL_isdigit(*argv[i])) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
208 num_sprites = SDL_atoi(argv[i]);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
209 consumed = 1;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
210 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
211 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
212 if (consumed < 0) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
213 fprintf(stderr,
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
214 "Usage: %s %s [--blend none|mask|blend|add|mod] [--scale none|fast|slow|best] [--cyclecolor] [--cyclealpha]\n",
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
215 argv[0], CommonUsage(state));
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
216 quit(1);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
217 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
218 i += consumed;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
219 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
220 if (!CommonInit(state)) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
221 quit(2);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
222 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
223
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
224 /* Create the windows, initialize the renderers, and load the textures */
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
225 sprites =
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
226 (SDL_TextureID *) SDL_malloc(state->num_windows * sizeof(*sprites));
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
227 if (!sprites) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
228 fprintf(stderr, "Out of memory!\n");
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
229 quit(2);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
230 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
231 for (i = 0; i < state->num_windows; ++i) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
232 SDL_SelectRenderer(state->windows[i]);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
233 SDL_RenderFill(0xA0, 0xA0, 0xA0, 0xFF, NULL);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
234 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
235 if (LoadSprite("icon.bmp") < 0) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
236 quit(2);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
237 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
238
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
239 /* Allocate memory for the sprite info */
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
240 positions = (SDL_Rect *) SDL_malloc(num_sprites * sizeof(SDL_Rect));
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
241 velocities = (SDL_Rect *) SDL_malloc(num_sprites * sizeof(SDL_Rect));
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
242 if (!positions || !velocities) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
243 fprintf(stderr, "Out of memory!\n");
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
244 quit(2);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
245 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
246 srand(time(NULL));
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
247 if (scaleMode != SDL_TEXTURESCALEMODE_NONE) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
248 sprite_w += sprite_w / 2;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
249 sprite_h += sprite_h / 2;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
250 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
251 for (i = 0; i < num_sprites; ++i) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
252 positions[i].x = rand() % (state->window_w - sprite_w);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
253 positions[i].y = rand() % (state->window_h - sprite_h);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
254 positions[i].w = sprite_w;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
255 positions[i].h = sprite_h;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
256 velocities[i].x = 0;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
257 velocities[i].y = 0;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
258 while (!velocities[i].x && !velocities[i].y) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
259 velocities[i].x = (rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
260 velocities[i].y = (rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
261 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
262 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
263
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
264 /* Main render loop */
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
265 frames = 0;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
266 then = SDL_GetTicks();
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
267 done = 0;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
268 while (!done) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
269 /* Check for events */
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
270 ++frames;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
271 while (SDL_PollEvent(&event)) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
272 CommonEvent(state, &event, &done);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
273 switch (event.type) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
274 case SDL_WINDOWEVENT:
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
275 switch (event.window.event) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
276 case SDL_WINDOWEVENT_EXPOSED:
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
277 SDL_SelectRenderer(event.window.windowID);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
278 SDL_RenderFill(0xA0, 0xA0, 0xA0, 0xFF, NULL);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
279 break;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
280 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
281 break;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
282 default:
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
283 break;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
284 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
285 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
286 for (i = 0; i < state->num_windows; ++i) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
287 MoveSprites(state->windows[i], sprites[i]);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
288 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
289 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
290
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
291 /* Print out some timing information */
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
292 now = SDL_GetTicks();
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
293 if (now > then) {
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
294 printf("%2.2f frames per second\n",
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
295 ((double) frames * 1000) / (now - then));
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
296 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
297
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
298 quit(0);
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
299 return 0;
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
300 }
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
301
e9f27fe4f2a1 Existing testsprite programs made into NDS projects
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
302 /* vi: set ts=4 sw=4 expandtab: */