-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmapstruct.cpp
40 lines (33 loc) · 862 Bytes
/
mapstruct.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>
#include "mapstruct.hpp"
#include "constant.hpp"
using namespace std;
void copy_map(Puzzle_struct * ptr, int map_out[SIZE_][SIZE_])
{
int i,j;
for( i = 0 ; i < SIZE_ ; i++){
for(j = 0 ; j < SIZE_ ; j++){
ptr->map[i][j] = map_out[i][j];
}
}
}
void move_up(Puzzle_struct * ptr,int x_row, int x_col)
{
ptr->map[x_row][x_col] = ptr->map[x_row-1][x_col] ;
ptr->map[x_row-1][x_col] = -1;
}
void move_down(Puzzle_struct * ptr,int x_row, int x_col)
{
ptr->map[x_row][x_col] = ptr->map[x_row+1][x_col] ;
ptr->map[x_row+1][x_col] = -1;
}
void move_left(Puzzle_struct * ptr,int x_row, int x_col)
{
ptr->map[x_row][x_col] = ptr->map[x_row][x_col-1] ;
ptr->map[x_row][x_col-1] = -1;
}
void move_right(Puzzle_struct * ptr,int x_row, int x_col)
{
ptr->map[x_row][x_col] = ptr->map[x_row][x_col+1] ;
ptr->map[x_row][x_col+1] = -1;
}