Question
Allowed code: int (and possibly double) variables; if statements, including all relational and logical operators; while loops; while loops within while loop, NO FOR LOOPS
Allowed code:
- int (and possibly double) variables;
- if statements, including all relational and logical operators;
- while loops; while loops within while loop, NO FOR LOOPS
- int arrays, including two dimensional arrays;
- printf and scanf; and
- functions.
For context:
Stage 0 : implements the ability to read in lines of stone and place them onto the map,
Stage 1: move the player to the left and right (and print this on the screen), using commands 1 and -1
Stage 2. Fire a laser to destroy the stones
Stage 3: implementing a command to shift everything in the map down by one position,
For the first part of stage 3, l need to shift all items in the array down by one position. This should occur whenever the program reads in a command of: 3.
There are no arguments after this command, it is another single integer command.
When your program shifts the contents of the array down, the integers which were in the bottom row will disappear, and the integers in the top row will all become
It should run like this:
if possible, any hints on how to to have End Conditions? : (you dont have to write code for this but i qant insight on how to do this ( please add comments on what i should use like loops and what if statements i should loook into and stuff ) info:
There are two ways to complete a game of Freefall:
- The game is won if the entire map is EMPTY.
- The game is lost if there is any STONE on the last row as a 3 (shift everything down) command is given. The only case in which the game is not lost when the shift everything down command is given, is when the entire bottom row of the map is EMPTY.
In stage 3 i must add code to check for these conditions. The win conditions should be checked after every fire laser command. If the game is won, the program should print the map once and then print "Game Won!" and end.
The lose condition should be checked before the contents of the array are shifted down. If the game is lost, the program should not shift the grid down, but should still print the map once and then print "Game Lost!" and end.
Please finish these steps and finish the code of completing the game for me:
Step 1: declare a function above main "void shift_down(int map[SIZE][SIZE]);".
Step 2: Define it below main "void shift_down(int map[SIZE][SIZE]){.......}".
Step 3: Use while loop from left end to right end see below.
int col;
col = 0;
while (col
// do step 4
col++;
}
// do step 5
Step 4: Inside first while loop Use another while loop from bottom to row 1 (not row 0) and inside this loop shift up element to down by using "map[row][col] = map[row-1][col];". see below
int row;
row = SIZE - 1;
while (row >= 1) {
map[row][col] = map[row-1][col];
row--;
}
Step 5: Set first row with EMPTY (col = 0; while (col
need to define it below main "void shift_down(int map[SIZE][SIZE]){.......}", and the code of completing the game
Shift Everything Down Summary: Shift Everything Down Command Command Name "Shift Everything Down" Command Number 3 Inputs (none) Examples Command Meaning 3 Move everything on the map down one position. ./freefall How many lines of stone? 2 Enter lines of stone: 11 21 5 5 5 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Shift Everything Down Summary: Shift Everything Down Command Command Name "Shift Everything Down" Command Number 3 Inputs (none) Examples Command Meaning 3 Move everything on the map down one position. ./freefall How many lines of stone? 2 Enter lines of stone: 11 21 5 5 5 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started