// Emergency Supply Grid - TEACHER EXEMPLAR / ALTERNATE FINISHED SOLUTION // Do not use this as the Day 1 starter or Day 2 student-authorship scaffold. // Mission A: a 4 x 5 priority grid that remains visible in the simulator. let missionName: string = "Storm Supply Grid" let rows: number = 4 let columns: number = 5 let xSpacing: number = 28 let ySpacing: number = 25 let priorityMode: boolean = true let suppliesPlaced: number = 0 if (priorityMode) { scene.setBackgroundColor(2) } else { scene.setBackgroundColor(1) } game.splash(missionName) for (let row = 0; row < rows; row++) { for (let column = 0; column < columns; column++) { let supply = sprites.create(img` . 2 2 2 . 2 4 4 4 2 2 4 5 4 2 2 4 4 4 2 . 2 2 2 . `, SpriteKind.Food) supply.setPosition(20 + column * xSpacing, 20 + row * ySpacing) suppliesPlaced += 1 } } info.setScore(suppliesPlaced) if (priorityMode && suppliesPlaced == rows * columns) { game.splash("Priority grid ready", "" + suppliesPlaced + " supplies") } else { game.splash("Check the grid", "" + suppliesPlaced + " supplies") }