Skip to content

Commit 03c94d0

Browse files
committed
Most toasts were spawned off-screen. Fixed
1 parent 6a3cae6 commit 03c94d0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/flying-toasters.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,14 @@ void setToasterSpawnCoordinates(struct Toaster *toaster, int screenWidth, int sc
228228
int slotWidth = screenWidth / GRID_WIDTH;
229229
int slotHeight = screenHeight / GRID_HEIGHT;
230230
toaster->x = screenHeight + (toaster->slot % GRID_WIDTH) * slotWidth + (slotWidth - SPRITE_SIZE) / 2;
231-
toaster->y = -screenHeight + (toaster->slot / GRID_HEIGHT) * slotHeight + (slotHeight - SPRITE_SIZE) / 2;
231+
toaster->y = -screenHeight + (toaster->slot / GRID_WIDTH) * slotHeight + (slotHeight - SPRITE_SIZE) / 2;
232232
}
233233

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

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

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

0 commit comments

Comments
 (0)