Jump to content
  • Advertisement
Sign in to follow this  
raptorstrike

tile map or large image

This topic is 5131 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

whitch one would be better for a game with some basic maps that you have to load that have fairly varying diffrences in each one i have tried to make a tile map class at least 3 times now and have failed horribly (end up ripping my hair out) because there are alot of long and tedious arrays then it hit me. it would be easyer to just make a map in the editor save it as a bitmap then underlay a black and white image for collision detection or would it? i know the first part would be easyer (saving the bitmaps) but ive never worked with the second part (making a black\white underlay) and i just want to know whats involved thanks alot [smile]

Share this post


Link to post
Share on other sites
Advertisement
The black/white underlay would essentially be another bitmap [although it would be a 1 bit map rather than 32 bits, or whatever color depth the actual map is]. So doing collision detection will involve parsing through the entire bitmap and as the scene changes you'll get to edit the bitmap directly to change what areas are "solid".

The long and the short of it is that you'll be dealing with lengthy arrays either way you handle it. Personally, I can't stand dealing with arrays after using an object oriented replacement like the STL's vector [though I use my own linked list class because I'm stubborn].

Share this post


Link to post
Share on other sites
Telastyn is right, I'm just I don't think like him, so I'll state it my way. XD

You basically have the same thing, either an array of black & white 1 bit pixels or an array of tiles with a bool variable(pass or not pass).
~~
However, a map like the one you're talking about is a popular way of creating maps(exp. single screen games). The advantage is a unique map for every scene. The disadvantage is that it maps will take a hell of a lot longer to create, since every scene will require a brand new giant image. A large map images will also take a lot more HD space than a tiled map, which is important if your game is going to be download-able.

Creating the underlay black & white image shouldn't be too difficult, since you can put it in a new layer and edit it until it covers everything that is inpassable.

Share this post


Link to post
Share on other sites
ok (sorry it took a while to get back to you guys i was asleep) any way from what i gathered hear they both need arrays (but it also seems one needs less. the black and white one needs a pixle array but a tile map needs a tile array and an array of images it also needs to flip through those tiles and draw them indavidualy). would it be possible to do somthing that uses more then one bit say 8 bit or would that hog too much memory per map? my thoughts are that black and white is fine but if i want to identify seprate surfaces like a green area for grass and a brown area for dirt, black would still be impassible and white would be under passable (you go under it), everything else would be normal but would have varying atributes based on the coulor.

Share this post


Link to post
Share on other sites
ok well ill let this post die after this but if any one cares i did decide to go with the map under lay and my collision function looks like this


Direction Sprite_Collision(Player* Hitter,Object* Hittee,Direction Flag)
{


Uint8 R,G,B;
int w = 3;
int h = 26;
if(Flag == UP)
{
h++;
};
if(Flag == DOWN)
{
h--;
}
if(Flag == LEFT)
{
w++;
};
if(Flag == RIGHT)
{
w--;
};
for(int i = 0; i < 19; i++)
{
SDL_GetRGB(getpixel(Hittee->I_Object,Hitter->R_Player.x+w+i,Hitter->R_Player.y+h+5), BackGround->I_Object->format, &R, &G, &B);
if(R == 0 && G == 0 && B == 0)
{
if( i < 2)
{
return LEFT;
}
if( i > 2)
{
return RIGHT;
};
}

}
for(int j = 0; j < 6; j++)
{
SDL_GetRGB(getpixel(Hittee->I_Object,Hitter->R_Player.x+w+2,Hitter->R_Player.y+h+j), BackGround->I_Object->format, &R, &G, &B);
if(R == 0 && G == 0 && B == 0)
{
if( j < 2)
{
return UP;
}
}
};
SDL_GetRGB(getpixel(Hittee->I_Object,Hitter->R_Player.x+w+2,Hitter->R_Player.y+h+9), BackGround->I_Object->format, &R, &G, &B);
if(R == 0 && G == 0 && B == 0)
{
return DOWN;
};



return NONE;

};



it basicly returns the direction you cannto move and dierection is a simple typedef const so i could return ints instead i just find words better ;) as for the rest of the stuff Get_RGB gets the RGB values for the pixel entered at getpixel whitch takes an image and 2 cordaninths. the number i added to the initial top right of the image (R_Player) corrosponds to were the feet are located in the image.

dont know if any one cares but im proud of it (strange as it may sound) because ive been trying to get some kind of map collision set up and i finally did it thanks to every one who helped me figure this stuff out (especally the anonomus poster who helped my figure out how to get the RGB values of a single pixel within a bit amp)

[grin]

Share this post


Link to post
Share on other sites
Ok, deleted a long post there cus it got too long winded. My first comment is to not use large bitmaps as a tilemap. A tilemap is not that difficult to handle and is much more flexible in the end. I have used both methods before and if I were to remake the one I used large bitmaps for (starfields for space invaders/galaga type game) I would use a randomly generated tilemap instead. I have the code for these somewhere on here... if you want to take a look, e-mail me and I will be more than happy to send them to you. They both use DirectDraw but I don't think that really matters as they were both more proof of concept tpye programs than anything else.

Share this post


Link to post
Share on other sites
Quote:
Original post by raptorstrike
ok (sorry it took a while to get back to you guys i was asleep) any way from what i gathered hear they both need arrays (but it also seems one needs less. the black and white one needs a pixle array but a tile map needs a tile array and an array of images it also needs to flip through those tiles and draw them indavidualy). would it be possible to do somthing that uses more then one bit say 8 bit or would that hog too much memory per map? my thoughts are that black and white is fine but if i want to identify seprate surfaces like a green area for grass and a brown area for dirt, black would still be impassible and white would be under passable (you go under it), everything else would be normal but would have varying atributes based on the coulor.


Yes, of course you could use more bits if you need more information. 1 byte per pixel, assuming 1600x1200 is... what? 2 megs?

Share this post


Link to post
Share on other sites
dang well this sucks i was glad to get a underlay map working and now i get all these people saying DOH! well ill have to decide if im switching i dont think that it would be THAT hard but this just seems more elgant and presise it is also easyer to add details without being confined to a set of tiles that are a set way, whatever though thanks alot for you guys imput [grin]

edit also i dont need EVERY pixel in the array. as you can see from the above mentioned code i just test a few pixels by my charictures feet

edit2: what do you think is the exceptable amount of memory required for an RPG?

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!