iOS: Fixed compiling demos on C89 compilers.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
diff --git a/Xcode-iOS/Demos/src/accelerometer.c b/Xcode-iOS/Demos/src/accelerometer.c
index 3b7985f..9ff61ae 100644
--- a/Xcode-iOS/Demos/src/accelerometer.c
+++ b/Xcode-iOS/Demos/src/accelerometer.c
@@ -34,6 +34,7 @@ void
render(SDL_Renderer *renderer, int w, int h)
{
+ float speed;
/* get joystick (accelerometer) axis values and normalize them */
float ax = SDL_JoystickGetAxis(accelerometer, 0);
@@ -58,7 +59,7 @@ render(SDL_Renderer *renderer, int w, int h)
ay * SDL_IPHONE_MAX_GFORCE / SINT16_MAX * GRAVITY_CONSTANT *
MILLESECONDS_PER_FRAME;
- float speed = sqrt(shipData.vx * shipData.vx + shipData.vy * shipData.vy);
+ speed = sqrt(shipData.vx * shipData.vx + shipData.vy * shipData.vy);
if (speed > 0) {
/* compensate for friction */
@@ -207,8 +208,8 @@ main(int argc, char *argv[])
done = 0;
/* enter main loop */
while (!done) {
- startFrame = SDL_GetTicks();
SDL_Event event;
+ startFrame = SDL_GetTicks();
while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) {
done = 1;
diff --git a/Xcode-iOS/Demos/src/happy.c b/Xcode-iOS/Demos/src/happy.c
index ce661d9..c8a7ec3 100644
--- a/Xcode-iOS/Demos/src/happy.c
+++ b/Xcode-iOS/Demos/src/happy.c
@@ -147,8 +147,8 @@ main(int argc, char *argv[])
/* main loop */
done = 0;
while (!done) {
- startFrame = SDL_GetTicks();
SDL_Event event;
+ startFrame = SDL_GetTicks();
while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) {
done = 1;
diff --git a/Xcode-iOS/Demos/src/mixer.c b/Xcode-iOS/Demos/src/mixer.c
index a2cc74d..8c21ba8 100644
--- a/Xcode-iOS/Demos/src/mixer.c
+++ b/Xcode-iOS/Demos/src/mixer.c
@@ -278,6 +278,7 @@ main(int argc, char *argv[])
Uint32 startFrame; /* holds when frame started processing */
Uint32 endFrame; /* holds when frame ended processing */
Uint32 delay; /* calculated delay, how long should we wait before next frame? */
+ int i;
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) {
fatalError("could not initialize SDL");
@@ -342,7 +343,6 @@ main(int argc, char *argv[])
}
/* cleanup code, let's free up those sound buffers */
- int i;
for (i = 0; i < NUM_DRUMS; i++) {
SDL_free(drums[i].buffer);
}
diff --git a/Xcode-iOS/Demos/src/touch.c b/Xcode-iOS/Demos/src/touch.c
index c81dcbc..fc5fd46 100644
--- a/Xcode-iOS/Demos/src/touch.c
+++ b/Xcode-iOS/Demos/src/touch.c
@@ -26,15 +26,17 @@ drawLine(SDL_Renderer *renderer, float startx, float starty, float dx, float dy)
float dx_prime = dx / iterations; /* x-shift per iteration */
float dy_prime = dy / iterations; /* y-shift per iteration */
SDL_Rect dstRect; /* rect to draw brush sprite into */
+ float x;
+ float y;
+ int i;
dstRect.w = BRUSH_SIZE;
dstRect.h = BRUSH_SIZE;
/* setup x and y for the location of the first sprite */
- float x = startx - BRUSH_SIZE / 2.0f;
- float y = starty - BRUSH_SIZE / 2.0f;
+ x = startx - BRUSH_SIZE / 2.0f;
+ y = starty - BRUSH_SIZE / 2.0f;
- int i;
/* draw a series of blots to form the line */
for (i = 0; i < iterations; i++) {
dstRect.x = x;