r
This commit is contained in:
parent
aff6562cfe
commit
4fa2c17e4a
@ -96,6 +96,7 @@ void movenorth(Housearray* f, char direction){
|
||||
int grid_x = f->x·coord - f->x_coord_origin;
|
||||
int grid_y = f->y·coord - f->y_coord_origin;
|
||||
f->houses[grid_y][grid_x]++;
|
||||
//comment
|
||||
}
|
||||
|
||||
void movesouth(Housearray* f, char direction){
|
||||
@ -106,7 +107,7 @@ void movesouth(Housearray* f, char direction){
|
||||
//update y coordinate
|
||||
f->y·coord++;
|
||||
//check if expansion needed
|
||||
if (f->y·coord > f->rows·in·array){
|
||||
if (f->y·coord - f->y_coord_origin >= f->rows·in·array){
|
||||
//Expand south
|
||||
int new_rows = old_rows +1;
|
||||
int new_cols = old_cols;
|
||||
@ -115,12 +116,12 @@ void movesouth(Housearray* f, char direction){
|
||||
for (int i = 0; i< old_rows; ++i){
|
||||
new_grid[i] = f->houses[i];
|
||||
}
|
||||
new_grid[0] = (int*)calloc(new_cols, sizeof(int));//Initialising the new row to empty
|
||||
new_grid[new_rows - 1] = (int*)calloc(new_cols, sizeof(int));//Initialising the new row to empty
|
||||
free(f->houses);
|
||||
f->houses = new_grid;
|
||||
f->rows·in·array = new_rows;
|
||||
f->columns·in·array = new_cols;
|
||||
f->y_coord_origin++;
|
||||
|
||||
}
|
||||
//updating the visit count
|
||||
int grid_x = f->x·coord - f->x_coord_origin;
|
||||
|
Loading…
x
Reference in New Issue
Block a user