Removed non-float versions of SDL render API drawing functions
This simplifies the API and removes a level of API translation between the int variants of the functions and the float implementation Fixes https://github.com/libsdl-org/SDL/issues/6656
This commit is contained in:
@@ -28,8 +28,8 @@
|
||||
#define MAX_SPEED 1
|
||||
|
||||
static SDL_Texture *sprite;
|
||||
static SDL_Rect positions[NUM_SPRITES];
|
||||
static SDL_Rect velocities[NUM_SPRITES];
|
||||
static SDL_FRect positions[NUM_SPRITES];
|
||||
static SDL_FRect velocities[NUM_SPRITES];
|
||||
static int sprite_w, sprite_h;
|
||||
|
||||
SDL_Renderer *renderer;
|
||||
@@ -48,7 +48,7 @@ void MoveSprites()
|
||||
int i;
|
||||
int window_w = WINDOW_WIDTH;
|
||||
int window_h = WINDOW_HEIGHT;
|
||||
SDL_Rect *position, *velocity;
|
||||
SDL_FRect *position, *velocity;
|
||||
|
||||
/* Draw a gray background */
|
||||
SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
|
||||
@@ -116,15 +116,15 @@ int main(int argc, char *argv[])
|
||||
/* Initialize the sprite positions */
|
||||
srand((unsigned int)time(NULL));
|
||||
for (i = 0; i < NUM_SPRITES; ++i) {
|
||||
positions[i].x = rand() % (WINDOW_WIDTH - sprite_w);
|
||||
positions[i].y = rand() % (WINDOW_HEIGHT - sprite_h);
|
||||
positions[i].w = sprite_w;
|
||||
positions[i].h = sprite_h;
|
||||
velocities[i].x = 0;
|
||||
velocities[i].y = 0;
|
||||
positions[i].x = (float)(rand() % (WINDOW_WIDTH - sprite_w));
|
||||
positions[i].y = (float)(rand() % (WINDOW_HEIGHT - sprite_h));
|
||||
positions[i].w = (float)sprite_w;
|
||||
positions[i].h = (float)sprite_h;
|
||||
velocities[i].x = 0.0f;
|
||||
velocities[i].y = 0.0f;
|
||||
while (!velocities[i].x && !velocities[i].y) {
|
||||
velocities[i].x = (rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED;
|
||||
velocities[i].y = (rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED;
|
||||
velocities[i].x = (float)((rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED);
|
||||
velocities[i].y = (float)((rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user