Skip to content

Commit

Permalink
Most toasts were spawned off-screen. Fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
torunar committed Apr 26, 2023
1 parent 6a3cae6 commit 03c94d0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/flying-toasters.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,14 @@ void setToasterSpawnCoordinates(struct Toaster *toaster, int screenWidth, int sc
int slotWidth = screenWidth / GRID_WIDTH;
int slotHeight = screenHeight / GRID_HEIGHT;
toaster->x = screenHeight + (toaster->slot % GRID_WIDTH) * slotWidth + (slotWidth - SPRITE_SIZE) / 2;
toaster->y = -screenHeight + (toaster->slot / GRID_HEIGHT) * slotHeight + (slotHeight - SPRITE_SIZE) / 2;
toaster->y = -screenHeight + (toaster->slot / GRID_WIDTH) * slotHeight + (slotHeight - SPRITE_SIZE) / 2;
}

void setToastSpawnCoordinates(struct Toast *toast, int screenWidth, int screenHeight) {
int slotWidth = screenWidth / GRID_WIDTH;
int slotHeight = screenHeight / GRID_HEIGHT;
toast->x = screenHeight + (toast->slot % GRID_WIDTH) * slotWidth + (slotWidth - SPRITE_SIZE) / 2;
toast->y = -screenHeight + (toast->slot / GRID_HEIGHT) * slotHeight + (slotHeight - SPRITE_SIZE) / 2;
toast->y = -screenHeight + (toast->slot / GRID_WIDTH) * slotHeight + (slotHeight - SPRITE_SIZE) / 2;
}

void spawnToasters(struct Toaster *toasters, int screenWidth, int screenHeight, int *grid) {
Expand All @@ -249,7 +249,7 @@ void spawnToasters(struct Toaster *toasters, int screenWidth, int screenHeight,

void spawnToasts(struct Toast *toasts, int screenWidth, int screenHeight, int *grid) {
for (int i = 0; i < TOAST_COUNT; i++) {
toasts[i].slot = grid[TOASTER_COUNT + TOAST_COUNT - 1 - i];
toasts[i].slot = grid[TOASTER_COUNT + i];
toasts[i].moveDistance = 1 + rand() % MAX_TOAST_SPEED;
setToastSpawnCoordinates(&toasts[i], screenWidth, screenHeight);
}
Expand Down

0 comments on commit 03c94d0

Please sign in to comment.