I'm writing a game in cocos2dx, and i'm trying to refactor a method thats gets called a few times. I want to return a two dimensional array from an enum of vehicletype
How can i get something like the following to work??
int Vehicle::getVehicle(VehicleTypes vehicletypes)
{
int vehicle[8][8] = {0};
switch (vehicleType) {
case Car:
// --- ARRAY 1 ------
vehicle = {
{ 0,0,0,0,0,0,0,0 },
{ 0,0,1,2,5,8,0,0 },
{ 0,0,5,3,4,5,0,0 },
{ 0,0,0,6,0,7,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 },
};
break;
case Bus:
{
// --- ARRAY 2 ------
Vehicle = {
{ 0,0,0,0,0,0,0,0 },
{ 0,0,0,0,1,2,0,0 },
{ 0,0,3,4,5,0,0,0 },
{ 0,0,6,8,7,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 },
};
break;
}
default:
break;
}
return vehicle;
}
Thanks
typedef const int (*matrix_ptr)[8];
Demo: http://ideone.com/i1Tc2