-
Notifications
You must be signed in to change notification settings - Fork 0
/
pull.c
43 lines (41 loc) · 768 Bytes
/
pull.c
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
41
42
43
/*
* NAME : LOOIKIANJOHN
* ID : 19741767
* PURPOSE : Implement of pull method to the box
* DATE : 15/4/23
* DATE MOD : 15/4/23
*/
#include <stdio.h>
#include "pull.h"
/* FUnction that let the player to pull the box */
void pull(int* mRow, int* mCol, int* pRow, int* pCol, int* bRow, int* bCol)
{
if (*pRow < *bRow)
{
if (*bRow > 2)
{
*bRow = *bRow - 1;
}
}
else if (*pRow > *bRow)
{
if (*bRow < *mRow - 3)
{
*bRow = *bRow + 1;
}
}
else if (*pCol < *bCol)
{
if (*bCol > 2)
{
*bCol = *bCol - 1;
}
}
else
{
if (*bCol < *mCol - 3)
{
*bCol = *bCol + 1;
}
}
}