I don't know how to optimize it to MD, it takes 0.5 sec to create the path (20 x 14 grid).
I have to generate a partial path or improve speed.
I need a timeout parameter, the code was modified to don't let pass by blocked diagonals.
Please, help to make this code better.
Thank you!
Code: Select all
#include <genesis.h>
#include "res\gfx.h"
#include "res\sprite.h"
#include "res\sound.h"
#define ROW 9
#define COL 10
fix32 FLT_MAX = 65000;
int lineText = 4;
// Creating a shortcut for int, int pair type
typedef struct {
s16 first;
s16 second;
}Pair;
// Creating a shortcut for int, int pair type
typedef struct {
fix32 first;
Pair second;
}PairList;
// Creating a shortcut for pair<int, pair<int, int>> type
//typedef pair<double, pair<int, int>> pPair;
// A structure to hold the neccesary parameters
typedef struct
{
// Row and Column index of its parent
// Note that 0 <= i <= ROW-1 & 0 <= j <= COL-1
int parent_i, parent_j;
// f = g + h
double f, g, h;
}cell;
// A Utility Function to check whether given cell (row, col)
// is a valid cell or not.
int isValid(int row, int col)
{
// Returns true if row number and column number
// is in range
return (row >= 0) & (row < ROW) & (col >= 0) & (col < COL);
}
// A Utility Function to check whether the given cell is
// blocked or not
int isUnBlocked(int grid[][COL], int row, int col)
{
// Returns true if the cell is not blocked else false
if (grid[row][col] == 1)
return (TRUE);
else
return (FALSE);
}
// A Utility Function to check whether destination cell has
// been reached or not
int isDestination(int row, int col, Pair dest)
{
if (row == dest.first && col == dest.second)
return (TRUE);
else
return (FALSE);
}
// A Utility Function to calculate the 'h' heuristics.
double calculateHValue(int row, int col, Pair dest)
{
// Return using the distance formula
return ((fix16)fix16Sqrt ((row-dest.first)*(row-dest.first) + (col-dest.second)*(col-dest.second)));
//return 1;
}
Pair make_pair(int row, int col){
Pair newPair;
newPair.first = row;
newPair.second = col;
return newPair;
}
void printf(char str[30]){
VDP_drawText(str, 25, lineText);
lineText ++;
}
// A Utility Function to trace the path from the source
// to destination
void tracePath(cell cellDetails[][COL], Pair dest)
{
printf ("The Path is ");
fix16 row = dest.first;
fix16 col = dest.second;
Pair Path[600];
fix16 posArr = 0;
while (!(cellDetails[row][col].parent_i == row
&& cellDetails[row][col].parent_j == col ))
{
Path[posArr] = make_pair(row, col);
int temp_row = cellDetails[row][col].parent_i;
int temp_col = cellDetails[row][col].parent_j;
row = temp_row;
col = temp_col;
posArr ++;
}
Path[posArr] = make_pair(row, col);
char first[6];
char second[6];
char str[20];
while (posArr >=0)
{
strclr(str);
Pair p = Path[posArr];
intToStr(p.first, first, 2);
intToStr(p.second, second, 2);
strcat(str, "R");
strcat(str, first);
strcat(str, "C");
strcat(str, second);
printf(str);
posArr --;
}
return;
}
// A Function to find the shortest path between
// a given source cell to a destination cell according
// to A* Search Algorithm
void aStarSearch(int grid[][COL], Pair src, Pair dest)
{
// If the source is out of range
if (isValid (src.first, src.second) == FALSE)
{
printf ("Source is invalid");
return;
}
// If the destination is out of range
if (isValid (dest.first, dest.second) == FALSE)
{
printf ("Destination is invalid");
return;
}
// Either the source or the destination is blocked
if (isUnBlocked(grid, src.first, src.second) == FALSE ||
isUnBlocked(grid, dest.first, dest.second) == FALSE)
{
printf ("Source or the destination is blocked");
return;
}
// If the destination cell is the same as source cell
if (isDestination(src.first, src.second, dest) == TRUE)
{
printf ("We are already at the destination");
return;
}
// Create a closed list and initialise it to false which means
// that no cell has been included yet
// This closed list is implemented as a boolean 2D array
fix16 closedList[ROW][COL];
memset(closedList, FALSE, sizeof (closedList));
// Declare a 2D array of structure to hold the details
//of that cell
cell cellDetails[ROW][COL];
int i, j;
for (i=0; i<ROW; i++)
{
for (j=0; j<COL; j++)
{
cellDetails[i][j].f = FLT_MAX;
cellDetails[i][j].g = FLT_MAX;
cellDetails[i][j].h = FLT_MAX;
cellDetails[i][j].parent_i = -1;
cellDetails[i][j].parent_j = -1;
}
}
// Initialising the parameters of the starting node
i = src.first, j = src.second;
cellDetails[i][j].f = 0.0;
cellDetails[i][j].g = 0.0;
cellDetails[i][j].h = 0.0;
cellDetails[i][j].parent_i = i;
cellDetails[i][j].parent_j = j;
/*
Create an open list having information as-
<f, <i, j>>
where f = g + h,
and i, j are the row and column index of that cell
Note that 0 <= i <= ROW-1 & 0 <= j <= COL-1
This open list is implenented as a set of pair of pair.*/
PairList openList[600];
// Put the starting cell on the open list and set its
// 'f' as 0
int intAux = 0;
openList[intAux].first = 0.0;
openList[intAux].second = make_pair (i, j);
//openList.insert(make_pair (0, make_pair (i, j)));
// We set this boolean value as false as initially
// the destination is not reached.
int foundDest = FALSE;
int lowPos = 0;
//while (!openList.empty()) TODO
while (openList[lowPos].first != 65535)
{
PairList p = openList[lowPos];
openList[lowPos].first = 65535;
lowPos ++;
// Remove this vertex from the open list
//openList.erase(openList.begin()); //TODO
// Add this vertex to the open list
i = p.second.first;
j = p.second.second;
closedList[i][j] = TRUE;
/*
Generating all the 8 successor of this cell
N.W N N.E
\ | /
\ | /
W----Cell----E
/ | \
/ | \
S.W S S.E
Cell-->Popped Cell (i, j)
N --> North (i-1, j)
S --> South (i+1, j)
E --> East (i, j+1)
W --> West (i, j-1)
N.E--> North-East (i-1, j+1)
N.W--> North-West (i-1, j-1)
S.E--> South-East (i+1, j+1)
S.W--> South-West (i+1, j-1)*/
// To store the 'g', 'h' and 'f' of the 8 successors
fix16 gNew, hNew, fNew;
//----------- 1st Successor (North) ------------
// Only process this cell if this is a valid one
if (isValid(i-1, j) == TRUE)
{
// If the destination cell is the same as the
// current successor
if (isDestination(i-1, j, dest) == TRUE)
{
// Set the Parent of the destination cell
cellDetails[i-1][j].parent_i = i;
cellDetails[i-1][j].parent_j = j;
printf ("The destination cell is found");
tracePath (cellDetails, dest);
foundDest = TRUE;
return;
}
// If the successor is already on the closed
// list or if it is blocked, then ignore it.
// Else do the following
else if (closedList[i-1][j] == FALSE &&
isUnBlocked(grid, i-1, j) == TRUE)
{
gNew = cellDetails[i][j].g + 1.0;
hNew = calculateHValue (i-1, j, dest);
fNew = gNew + hNew;
// If it isn’t on the open list, add it to
// the open list. Make the current square
// the parent of this square. Record the
// f, g, and h costs of the square cell
// OR
// If it is on the open list already, check
// to see if this path to that square is better,
// using 'f' cost as the measure.
if (cellDetails[i-1][j].f == FLT_MAX ||
cellDetails[i-1][j].f > fNew)
{
intAux ++;
openList[intAux].first = fNew;
openList[intAux].second = make_pair (i-1, j);
// Update the details of this cell
cellDetails[i-1][j].f = fNew;
cellDetails[i-1][j].g = gNew;
cellDetails[i-1][j].h = hNew;
cellDetails[i-1][j].parent_i = i;
cellDetails[i-1][j].parent_j = j;
}
}
}
//----------- 2nd Successor (South) ------------
// Only process this cell if this is a valid one
if (isValid(i+1, j) == TRUE)
{
// If the destination cell is the same as the
// current successor
if (isDestination(i+1, j, dest) == TRUE)
{
// Set the Parent of the destination cell
cellDetails[i+1][j].parent_i = i;
cellDetails[i+1][j].parent_j = j;
printf("The destination cell is found");
tracePath(cellDetails, dest);
foundDest = TRUE;
return;
}
// If the successor is already on the closed
// list or if it is blocked, then ignore it.
// Else do the following
else if (closedList[i+1][j] == FALSE &&
isUnBlocked(grid, i+1, j) == TRUE)
{
gNew = cellDetails[i][j].g + 1.0;
hNew = calculateHValue(i+1, j, dest);
fNew = gNew + hNew;
// If it isn’t on the open list, add it to
// the open list. Make the current square
// the parent of this square. Record the
// f, g, and h costs of the square cell
// OR
// If it is on the open list already, check
// to see if this path to that square is better,
// using 'f' cost as the measure.
if (cellDetails[i+1][j].f == FLT_MAX ||
cellDetails[i+1][j].f > fNew)
{
intAux ++;
openList[intAux].first = fNew;
openList[intAux].second = make_pair (i+1, j);
// Update the details of this cell
cellDetails[i+1][j].f = fNew;
cellDetails[i+1][j].g = gNew;
cellDetails[i+1][j].h = hNew;
cellDetails[i+1][j].parent_i = i;
cellDetails[i+1][j].parent_j = j;
}
}
}
//----------- 3rd Successor (East) ------------
// Only process this cell if this is a valid one
if (isValid (i, j+1) == TRUE)
{
// If the destination cell is the same as the
// current successor
if (isDestination(i, j+1, dest) == TRUE)
{
// Set the Parent of the destination cell
cellDetails[i][j+1].parent_i = i;
cellDetails[i][j+1].parent_j = j;
printf("The destination cell is found");
tracePath(cellDetails, dest);
foundDest = TRUE;
return;
}
// If the successor is already on the closed
// list or if it is blocked, then ignore it.
// Else do the following
else if (closedList[i][j+1] == FALSE &&
isUnBlocked (grid, i, j+1) == TRUE)
{
gNew = cellDetails[i][j].g + 1.0;
hNew = calculateHValue (i, j+1, dest);
fNew = gNew + hNew;
// If it isn’t on the open list, add it to
// the open list. Make the current square
// the parent of this square. Record the
// f, g, and h costs of the square cell
// OR
// If it is on the open list already, check
// to see if this path to that square is better,
// using 'f' cost as the measure.
if (cellDetails[i][j+1].f == FLT_MAX ||
cellDetails[i][j+1].f > fNew)
{
intAux ++;
openList[intAux].first = fNew;
openList[intAux].second = make_pair (i, j+1);
// Update the details of this cell
cellDetails[i][j+1].f = fNew;
cellDetails[i][j+1].g = gNew;
cellDetails[i][j+1].h = hNew;
cellDetails[i][j+1].parent_i = i;
cellDetails[i][j+1].parent_j = j;
}
}
}
//----------- 4th Successor (West) ------------
// Only process this cell if this is a valid one
if (isValid(i, j-1) == TRUE)
{
// If the destination cell is the same as the
// current successor
if (isDestination(i, j-1, dest) == TRUE)
{
// Set the Parent of the destination cell
cellDetails[i][j-1].parent_i = i;
cellDetails[i][j-1].parent_j = j;
printf("The destination cell is found");
tracePath(cellDetails, dest);
foundDest = TRUE;
return;
}
// If the successor is already on the closed
// list or if it is blocked, then ignore it.
// Else do the following
else if (closedList[i][j-1] == FALSE &&
isUnBlocked(grid, i, j-1) == TRUE)
{
gNew = cellDetails[i][j].g + 1.0;
hNew = calculateHValue(i, j-1, dest);
fNew = gNew + hNew;
// If it isn’t on the open list, add it to
// the open list. Make the current square
// the parent of this square. Record the
// f, g, and h costs of the square cell
// OR
// If it is on the open list already, check
// to see if this path to that square is better,
// using 'f' cost as the measure.
if (cellDetails[i][j-1].f == FLT_MAX ||
cellDetails[i][j-1].f > fNew)
{
intAux ++;
openList[intAux].first = fNew;
openList[intAux].second = make_pair (i, j-1);
// Update the details of this cell
cellDetails[i][j-1].f = fNew;
cellDetails[i][j-1].g = gNew;
cellDetails[i][j-1].h = hNew;
cellDetails[i][j-1].parent_i = i;
cellDetails[i][j-1].parent_j = j;
}
}
}
//----------- 5th Successor (North-East) ------------
// Only process this cell if this is a valid one
if (isValid(i-1, j+1) == TRUE)
{
// If the destination cell is the same as the
// current successor
if (isDestination(i-1, j+1, dest) == TRUE)
{
// Set the Parent of the destination cell
cellDetails[i-1][j+1].parent_i = i;
cellDetails[i-1][j+1].parent_j = j;
printf ("The destination cell is found");
tracePath (cellDetails, dest);
foundDest = TRUE;
return;
}
// If the successor is already on the closed
// list or if it is blocked, then ignore it.
// Else do the following
else if (closedList[i-1][j+1] == FALSE &&
isUnBlocked(grid, i-1, j+1) == TRUE && (isUnBlocked(grid, i-1, j) == TRUE) && (isUnBlocked(grid, i, j+1) == TRUE))
{
gNew = cellDetails[i][j].g + 1.414;
hNew = calculateHValue(i-1, j+1, dest);
fNew = gNew + hNew;
// If it isn’t on the open list, add it to
// the open list. Make the current square
// the parent of this square. Record the
// f, g, and h costs of the square cell
// OR
// If it is on the open list already, check
// to see if this path to that square is better,
// using 'f' cost as the measure.
if (cellDetails[i-1][j+1].f == FLT_MAX ||
cellDetails[i-1][j+1].f > fNew)
{
intAux ++;
openList[intAux].first = fNew;
openList[intAux].second = make_pair (i-1, j+1);
// Update the details of this cell
cellDetails[i-1][j+1].f = fNew;
cellDetails[i-1][j+1].g = gNew;
cellDetails[i-1][j+1].h = hNew;
cellDetails[i-1][j+1].parent_i = i;
cellDetails[i-1][j+1].parent_j = j;
}
}
}
//----------- 6th Successor (North-West) ------------
// Only process this cell if this is a valid one
if (isValid (i-1, j-1) == TRUE)
{
// If the destination cell is the same as the
// current successor
if (isDestination (i-1, j-1, dest) == TRUE)
{
// Set the Parent of the destination cell
cellDetails[i-1][j-1].parent_i = i;
cellDetails[i-1][j-1].parent_j = j;
printf ("The destination cell is found");
tracePath (cellDetails, dest);
foundDest = TRUE;
return;
}
// If the successor is already on the closed
// list or if it is blocked, then ignore it.
// Else do the following
else if (closedList[i-1][j-1] == FALSE &&
isUnBlocked(grid, i-1, j-1) == TRUE && (isUnBlocked(grid, i-1, j) == TRUE) && (isUnBlocked(grid, i, j-1) == TRUE))
{
gNew = cellDetails[i][j].g + 1.414;
hNew = calculateHValue(i-1, j-1, dest);
fNew = gNew + hNew;
// If it isn’t on the open list, add it to
// the open list. Make the current square
// the parent of this square. Record the
// f, g, and h costs of the square cell
// OR
// If it is on the open list already, check
// to see if this path to that square is better,
// using 'f' cost as the measure.
if (cellDetails[i-1][j-1].f == FLT_MAX ||
cellDetails[i-1][j-1].f > fNew)
{
intAux ++;
openList[intAux].first = fNew;
openList[intAux].second = make_pair (i-1, j-1);
// Update the details of this cell
cellDetails[i-1][j-1].f = fNew;
cellDetails[i-1][j-1].g = gNew;
cellDetails[i-1][j-1].h = hNew;
cellDetails[i-1][j-1].parent_i = i;
cellDetails[i-1][j-1].parent_j = j;
}
}
}
//----------- 7th Successor (South-East) ------------
// Only process this cell if this is a valid one
if (isValid(i+1, j+1) == TRUE)
{
// If the destination cell is the same as the
// current successor
if (isDestination(i+1, j+1, dest) == TRUE)
{
// Set the Parent of the destination cell
cellDetails[i+1][j+1].parent_i = i;
cellDetails[i+1][j+1].parent_j = j;
printf ("The destination cell is found");
tracePath (cellDetails, dest);
foundDest = TRUE;
return;
}
// If the successor is already on the closed
// list or if it is blocked, then ignore it.
// Else do the following
else if (closedList[i+1][j+1] == FALSE &&
isUnBlocked(grid, i+1, j+1) == TRUE && (isUnBlocked(grid, i, j+1) == TRUE) && (isUnBlocked(grid, i+1, j) == TRUE))
{
gNew = cellDetails[i][j].g + 1.414;
hNew = calculateHValue(i+1, j+1, dest);
fNew = gNew + hNew;
// If it isn’t on the open list, add it to
// the open list. Make the current square
// the parent of this square. Record the
// f, g, and h costs of the square cell
// OR
// If it is on the open list already, check
// to see if this path to that square is better,
// using 'f' cost as the measure.
if (cellDetails[i+1][j+1].f == FLT_MAX ||
cellDetails[i+1][j+1].f > fNew)
{
intAux ++;
openList[intAux].first = fNew;
openList[intAux].second = make_pair (i+1, j+1);
// Update the details of this cell
cellDetails[i+1][j+1].f = fNew;
cellDetails[i+1][j+1].g = gNew;
cellDetails[i+1][j+1].h = hNew;
cellDetails[i+1][j+1].parent_i = i;
cellDetails[i+1][j+1].parent_j = j;
}
}
}
//----------- 8th Successor (South-West) ------------
// Only process this cell if this is a valid one
if (isValid (i+1, j-1) == TRUE)
{
// If the destination cell is the same as the
// current successor
if (isDestination(i+1, j-1, dest) == TRUE)
{
// Set the Parent of the destination cell
cellDetails[i+1][j-1].parent_i = i;
cellDetails[i+1][j-1].parent_j = j;
printf("The destination cell is found");
tracePath(cellDetails, dest);
foundDest = TRUE;
return;
}
// If the successor is already on the closed
// list or if it is blocked, then ignore it.
// Else do the following
else if (closedList[i+1][j-1] == FALSE &&
isUnBlocked(grid, i+1, j-1) == TRUE && (isUnBlocked(grid, i+1, j) == TRUE) && (isUnBlocked(grid, i, j-1) == TRUE))
{
gNew = cellDetails[i][j].g + 1.414;
hNew = calculateHValue(i+1, j-1, dest);
fNew = gNew + hNew;
// If it isn’t on the open list, add it to
// the open list. Make the current square
// the parent of this square. Record the
// f, g, and h costs of the square cell
// OR
// If it is on the open list already, check
// to see if this path to that square is better,
// using 'f' cost as the measure.
if (cellDetails[i+1][j-1].f == FLT_MAX ||
cellDetails[i+1][j-1].f > fNew)
{
intAux ++;
openList[intAux].first = fNew;
openList[intAux].second = make_pair (i+1, j-1);
// Update the details of this cell
cellDetails[i+1][j-1].f = fNew;
cellDetails[i+1][j-1].g = gNew;
cellDetails[i+1][j-1].h = hNew;
cellDetails[i+1][j-1].parent_i = i;
cellDetails[i+1][j-1].parent_j = j;
}
}
}
}
// When the destination cell is not found and the open
// list is empty, then we conclude that we failed to
// reach the destiantion cell. This may happen when the
// there is no way to destination cell (due to blockages)
if (foundDest == FALSE)
printf("Failed to find the Destination Cell");
return;
}
static void updateCamera(fix32 x, fix32 y);
// sprites structure (pointer of Sprite)
Sprite* arrPlayers[1];
Sprite* arrObjects[11];
Sprite* arrItens[7];
Sprite* arrEnemies[2];
Sprite* icon_p1;
Sprite* icon_p2;
fix32 camposx;
fix32 camposy;
static void updateCamera(fix32 x, fix32 y)
{
if ((x != camposx) || (y != camposy))
{
camposx = x;
camposy = y;
VDP_setHorizontalScroll(PLAN_A, fix32ToInt(-camposx));
VDP_setHorizontalScroll(PLAN_B, fix32ToInt(-camposx) >> 3);
VDP_setVerticalScroll(PLAN_A, fix32ToInt(camposy));
VDP_setVerticalScroll(PLAN_B, fix32ToInt(camposy) >> 3);
}
}
int main()
{
u16 palette[64];
camposx = -1;
camposy = -1;
// disable interrupt when accessing VDP
SYS_disableInts();
// initialization
VDP_setScreenWidth320();
// init sprites engine
SPR_init(16, 256, 256);
// set all palette to black
VDP_setPaletteColors(0, (u16*) palette_black, 64);
// VDP process done, we can re enable interrupts
SYS_enableInts();
// init scrolling
updateCamera(FIX32(0), FIX32(0));
arrPlayers[0] = SPR_addSprite(&char01_sprite, 160, 160, TILE_ATTR(PAL1, TRUE, FALSE, FALSE));
arrPlayers[1] = SPR_addSprite(&char01_sprite, 190, 160, TILE_ATTR(PAL1, TRUE, FALSE, FALSE));
arrEnemies[0] = SPR_addSprite(&enemy01_sprite, 160, 64, TILE_ATTR(PAL3, TRUE, FALSE, FALSE));
arrEnemies[1] = SPR_addSprite(&enemy01_sprite, 190, 64, TILE_ATTR(PAL3, TRUE, FALSE, FALSE));
icon_p1 = SPR_addSprite(&icon01_sprite, 6, 10, TILE_ATTR(PAL2, FALSE, FALSE, FALSE));
icon_p2 = SPR_addSprite(&icon01_sprite, 200, 10, TILE_ATTR(PAL2, FALSE, FALSE, FALSE));
arrItens[0] = SPR_addSprite(&item01_sprite, 16, 64, TILE_ATTR(PAL2, FALSE, FALSE, FALSE));
arrItens[1] = SPR_addSprite(&item02_sprite, 16, 80, TILE_ATTR(PAL2, FALSE, FALSE, FALSE));
arrItens[2] = SPR_addSprite(&item03_sprite, 32, 80, TILE_ATTR(PAL2, FALSE, FALSE, FALSE));
arrItens[3] = SPR_addSprite(&item04_sprite, 48, 80, TILE_ATTR(PAL2, FALSE, FALSE, FALSE));
arrItens[4] = SPR_addSprite(&item02_sprite, 64, 128, TILE_ATTR(PAL2, FALSE, FALSE, FALSE));
arrItens[5] = SPR_addSprite(&item03_sprite, 80, 128, TILE_ATTR(PAL2, FALSE, FALSE, FALSE));
arrItens[6] = SPR_addSprite(&item04_sprite, 96, 128, TILE_ATTR(PAL2, FALSE, FALSE, FALSE));
arrObjects[0] = SPR_addSprite(&object01_sprite, 16, 160, TILE_ATTR(PAL2, FALSE, FALSE, FALSE));
arrObjects[1] = SPR_addSprite(&object02_sprite, 16, 176, TILE_ATTR(PAL2, FALSE, FALSE, FALSE));
arrObjects[2] = SPR_addSprite(&object03_sprite, 32, 96, TILE_ATTR(PAL2, FALSE, FALSE, FALSE));
arrObjects[3] = SPR_addSprite(&object03_sprite, 48, 160, TILE_ATTR(PAL2, FALSE, FALSE, FALSE));
arrObjects[4] = SPR_addSprite(&object01_sprite, 48, 176, TILE_ATTR(PAL2, FALSE, FALSE, FALSE));
arrObjects[5] = SPR_addSprite(&object02_sprite, 64, 64, TILE_ATTR(PAL2, FALSE, FALSE, FALSE));
arrObjects[6] = SPR_addSprite(&object01_sprite, 80, 80, TILE_ATTR(PAL2, FALSE, FALSE, FALSE));
arrObjects[7] = SPR_addSprite(&object03_sprite, 96, 96, TILE_ATTR(PAL2, FALSE, FALSE, FALSE));
arrObjects[8] = SPR_addSprite(&object02_sprite, 112, 112, TILE_ATTR(PAL2, FALSE, FALSE, FALSE));
arrObjects[9] = SPR_addSprite(&object03_sprite, 128, 128, TILE_ATTR(PAL2, FALSE, FALSE, FALSE));
arrObjects[10] = SPR_addSprite(&object03_sprite, 144, 144, TILE_ATTR(PAL2, FALSE, FALSE, FALSE));
SPR_update();
// prepare palettes
memcpy(&palette[0], char01_sprite.palette->data, 16 * 2);
memcpy(&palette[16], char01_sprite.palette->data, 16 * 2);
memcpy(&palette[32], item01_sprite.palette->data, 16 * 2);
memcpy(&palette[48], enemy01_sprite.palette->data, 16 * 2);
/* Description of the Grid-
1--> The cell is not blocked
0--> The cell is blocked */
int grid[ROW][COL] =
{
{ 1, 0, 1, 1, 1, 1, 0, 1, 1, 1 },
{ 1, 1, 1, 0, 1, 1, 1, 0, 1, 1 },
{ 1, 1, 1, 0, 1, 1, 0, 1, 0, 1 },
{ 0, 0, 1, 0, 1, 0, 0, 0, 0, 1 },
{ 1, 1, 1, 0, 1, 1, 1, 0, 1, 0 },
{ 1, 0, 1, 1, 1, 1, 0, 1, 0, 0 },
{ 1, 0, 1, 1, 1, 1, 0, 0, 0, 1 },
{ 1, 0, 1, 1, 1, 1, 1, 1, 1, 1 },
{ 1, 1, 1, 0, 0, 0, 1, 0, 0, 1 }
};
// Source is the left-most bottom-most corner
//ROW //COL
Pair src = make_pair(8, 9);
// Destination is the left-most top-most corner
Pair dest = make_pair(0, 0);
aStarSearch(grid, src, dest);
// fade in
VDP_fadeIn(0, (4 * 16) - 1, palette, 20, FALSE);
while(TRUE)
{
//if (!reseted)
// update sprites
SPR_update();
VDP_waitVSync();
}
return 0;
}