Awesome forum! I've been getting a lot of information here but now I'm stuck and hope someone here can assist me.
I'm currently busy creating a 2D side scroller (like Shinobi, Sonic etc).
I've worked through the Sonic example in the samples folder of SGDK and I've worked through this tutorial: https://under-prog.ru/en/sgdk-creating- ... a-genesis/ for collision detection.
The tutorial creates a 2D array
Code: Select all
u8 level[row][col] //size of whole stage
Code: Select all
for(s16 i=leftTile; i <=rightTile; i++)
{
for(s16 j=topTile; j <=bottomTile; j++)
{
if(level [j][i] == 0) {
return FALSE;
}
}
}
return TRUE;
I tried then to apply the collision detection to the Sonic example and ran into the problem that I cannot create a 2D array for a stage that is 160 x 1280 tiles big. If I create the array as a global variable the code does not compile and if I create it inside my stage_1() function then I get an "illegal instruction" error once the stage tries to load.
What I found interesting is that I can create the array and even have the following:
Code: Select all
if(level [j][i] == 0) {
//return FALSE;
int dummy = 0;
}
So my question is: What is the right way to code collision detection in 2D side scrollers that have stages that are bigger then just a screen or two's width?
I am assuming this is a RAM space issue, how can I then load the array into RAM for a big stage? My code is failing even with a 30 x 100 array (which is very small for a stage in any case)