Jump to content
  • Advertisement
Sign in to follow this  
xXMr WaffleXx

Tile based array

This topic is 2963 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been trying to make a tile based array for my game for a while now XD. Tried a lot of things, but still don't get exactly how to do it. So I've decided to ask for some help. I have most of the code(don't know if it will work or not), but I only have one error and that must mean I'm close unless the code I wrote doesn't do anything. So if you can help me fix my error or tell me what I'm doing that is making it occur then I would greatly appreciate it. Thanks in advance.

Anyway here is the error I'm getting:
c:\documents and settings\compaq_administrator\my documents\visual studio 2008\projects\test\test\main.cpp(30) : error C2059: syntax error : ']'

And this is the code(Also this isn't the code in my game it's just the tile fuction and all that to test it out.):


#include "DarkGDK.h"

void mapsetup();

const int height = 3;
const int width = 3;
int x;
int y;
int n;

int test[height][width]=
{
0,0,0,
0,1,0,
2,0,3,
};

void DarkGDK ( void )
{
dbSetDisplayMode (1024,768,32);
dbSyncOn ( );
dbSyncRate ( 60 );
dbMaximizeWindow ();
dbSetImageColorKey (255,0,255);

while ( LoopGDK ( ) )
{
mapsetup(test[]);

dbSync ( );
}


return;
}
void mapsetup(int map[][height][width])
{

//tiles
dbLoadImage("brickground.bmp",21);
dbLoadImage("sky.bmp",22);
dbLoadImage("red.bmp",23);

for(y = 0, n = 31; y < height; ++y)
{
for(x = 0; x < width; ++x, ++n)
{
if (test[y][x] !=0)
{
if (test[y][x] = 1)
{
dbSprite (21,x*32,y*32,n);
}
if (test[y][x] = 2)
{
dbSprite (22,x*32,y*32,n);
}
if (test[y][x] = 3)
{
dbSprite (23,x*32,y*32,n);
}
}
}
}
}



[Edited by - Zahlman on July 7, 2010 6:49:47 PM]

Share this post


Link to post
Share on other sites
Advertisement
On this line:

mapsetup(test[]);

if you're trying to pass the 'test' array as an argument, you need to omit the brackets:

mapsetup(test);

However, this still won't work because at the top of the file, you have this declaration:

void mapsetup();

which says that mapsetup() doesn't take any arguments. You need to change it to:

void mapsetup(int map[height][width]);

Also, in the definition of mapsetup() below, you have an extra pair of brackets after 'map':

void mapsetup(int map[][height][width])

You need to remove those as well.

BTW, please use source tags when posting long code listings.

Share this post


Link to post
Share on other sites
When you pass test to map set up, you dont need the brackets unless you were to send a specific position in the map (i.e setUpMap(test[0][1]);, but thats only if you want to send a specific location, if you are sending the entire map, just pass test. Also your parameters are all messed up. I believe it is:

setUpMap(int map[height][width])
{

}

hope this helps.

Share this post


Link to post
Share on other sites
Added source tags, removed what appears to be a "I double-posted, please get rid of this" placeholder, and moved to For Beginners.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!