🔒 Locked
2d background object
Advertisement
Original Post
if I am creating a 2d tiled background so a sprite can move around eg tress and rocks on the map. q)How do program the objects to collide with in directx. Do I draw things like tress onto a map as a seperate sprite(s), or draw them onto a map before loading? q) If I use tiles of about 32 pixels then I need to work out before hand what part of the tile can you move on which may involve hard coding the location of these points somewhere, is this the done thing to do?
Quote:
Original post by jagguy
q)How do program the objects to collide with in directx. Do I draw things like tress onto a map as a seperate sprite(s), or draw them onto a map before loading?
q) If I use tiles of about 32 pixels then I need to work out before hand what part of the tile can you move on which may involve hard coding the location of these points somewhere, is this the done thing to do?
That really all depends on how your map data is setup and the size of your objects. If everything is a 32x32 tile then you can probably use some sort of grid system, or bounding box collision. If your objects have really complex images, you'll need to implement some sort of rectangle + pixel-pixel collision.
Edit: Also what are you making your maps with? Perhaps you should try out TileStudio.
I am making my maps in paint to just test. However it loks like I need to create objects on a map with some sort of grid and just have every collision happen in small 4X4 or 8X8 chunks eg rocks must be collided with in an area of 8X8 chunks and its location in the world needs to be worked out.
It sounds like you need a map maker or make your own to get these details at design time.
It sounds like you need a map maker or make your own to get these details at design time.
Quote:
Original post by Scet
How big are your maps going to be? Hand making everything in paint sounds like a royal pain, plus you'll probably run into memory/fillrate problems with large bitmaps.
well i just did a 1024 X 1024 map no problem which is small, and you just display the required tiles to the screen. What problems are you talking about and is there a better way for really large maps?
Paint was just an experiment but i am looking for others.
I really think it isn't an issue but correct me if I am wrong.
Well even an 1024x1024 8bpp bitmap is going to take 1MB RAM, expand that to 32bpp for D3D and you'll probably using 4MBs of video memory. Plus a 1024x1024 bitmap is always going to be large even if it uses one tile repeatedly.
I still think you should go with a traditional map editor, there's a reason why you've never heard of anyone making whole game maps in paint.
Edit: Anyway how big(in pixels) do you intend to make your maps. Using huge bitmaps for everything can chew up memory quickly, plus it increase the downlaod size of your program. Consider how much less memory you could use by using just a "tile sheet" and rendering the map using a proper map format.
Edit 2: Sleep time.
I still think you should go with a traditional map editor, there's a reason why you've never heard of anyone making whole game maps in paint.
Edit: Anyway how big(in pixels) do you intend to make your maps. Using huge bitmaps for everything can chew up memory quickly, plus it increase the downlaod size of your program. Consider how much less memory you could use by using just a "tile sheet" and rendering the map using a proper map format.
Edit 2: Sleep time.
I agree paint isn't very good.
Well I am using paint to just test my program, it isn't professional enough to be serious about.
I mean could you explain how much better a map editor could be exactly. I want a map editior to create a whole 2d scene and not to just create a single tile. It seems every tile will take the same memory as a bmp tile with its add ons.
Where can I get just a map editor from and what savings does this cost on memory.
Well I am using paint to just test my program, it isn't professional enough to be serious about.
I mean could you explain how much better a map editor could be exactly. I want a map editior to create a whole 2d scene and not to just create a single tile. It seems every tile will take the same memory as a bmp tile with its add ons.
Where can I get just a map editor from and what savings does this cost on memory.
Let's say you have a 1024x1024 pixel map made of 32x32 pixel tiles, so the map would be 32x32 tiles big.
Now let's say the map contains (rough guess here) 20 different tiles. So if you where to make those tiles in TileStudio, it would create a 82KB bitmap(32x32x4x20). Now say that the map data uses 32bit integers to represent tile indices. The map is 32x32 tiles is it would take 4KB of space(32x32x4).
Let's compare shall we:
Tile method(using a 1024x1024 map with 20 different tiles): ~86KB
1024x1024 8bit bitmap: 1MB
1024x1024 32bit bitmap: 4MB
See. With the tile method extending the map doesn't take much more space because all you need is an integer index into a tile sheet(a big bitmap with all the different tiles). As for the size of the tile sheet itself, you would need 1024 different tiles before you even used the space of one 1024x1024 bitmap, that's a whole crapload of tiles.
Again I suggest TileStudio. The screenshots on the page don't really show what it's capable of. Just give it a try and load a few of the example projects that come with. If you need any help using it with your program you can always ask me or Rob Loach.
Now let's say the map contains (rough guess here) 20 different tiles. So if you where to make those tiles in TileStudio, it would create a 82KB bitmap(32x32x4x20). Now say that the map data uses 32bit integers to represent tile indices. The map is 32x32 tiles is it would take 4KB of space(32x32x4).
Let's compare shall we:
Tile method(using a 1024x1024 map with 20 different tiles): ~86KB
1024x1024 8bit bitmap: 1MB
1024x1024 32bit bitmap: 4MB
See. With the tile method extending the map doesn't take much more space because all you need is an integer index into a tile sheet(a big bitmap with all the different tiles). As for the size of the tile sheet itself, you would need 1024 different tiles before you even used the space of one 1024x1024 bitmap, that's a whole crapload of tiles.
Again I suggest TileStudio. The screenshots on the page don't really show what it's capable of. Just give it a try and load a few of the example projects that come with. If you need any help using it with your program you can always ask me or Rob Loach.
so how come a 32 pixel tile as a bmp id so much more space consuming than 1 in Tilestudio, what is the secret.
What I might do is just finish off what I am doing , eg learn basics and then to create a better looking map then use a map editior for sure.
q) what about having objects on the screen eg a house or a picket fence where you can walk behind it and still see only part of you. Then a tile would need to be redrawn and allow for sprites to still see. Is this a programming problem or a graphics problem.
What I might do is just finish off what I am doing , eg learn basics and then to create a better looking map then use a map editior for sure.
q) what about having objects on the screen eg a house or a picket fence where you can walk behind it and still see only part of you. Then a tile would need to be redrawn and allow for sprites to still see. Is this a programming problem or a graphics problem.
Quote:
Original post by jagguy
so how come a 32 pixel tile as a bmp id so much more space consuming than 1 in Tilestudio, what is the secret.
Here I'll simplify it a little:
Let's say you have a small 4x4 tile map, using 6 different tiles.
Using you're current method you end up with a 128x128 bitmap(the number of different tiles doesn't matter) which stored at 32bpp will take 64KB of space.
Now make the same map in TileStudio. See what tile editors do is rather that store the whole map as one big image, they one store the different tiles needed and store "tile indices"(mapping into the saved tile images) in a grid like pattern.
0 1 2 4 3 3 4 4 2 2 5 34 0 3 1OK I just threw a bunch of numbers together, but see that in order to represent the actual map data, you only need 16 integers. The bitmap generated by TS would only contain the 6 different tiles(in a certain order), the bitmap would be 192x32 in size and take up 24KB. Of course showing the map tile-by-tile using the map data requires more programming then just using large bitmaps.
This is a small example, but if your maps are big and they use the same tiles repeatedly then a tile map is the way to go.
Quote:
Original post by jagguy
What I might do is just finish off what I am doing , eg learn basics and then to create a better looking map then use a map editor for sure.
I guess that's a good idea. Since releasing my TileStudio stuff I've received numerous e-mails and pm's from people that didn't know how to load images or manage sprites and read in the map to begin with, and where thus very confused.
Quote:
q) what about having objects on the screen eg a house or a picket fence where you can walk behind it and still see only part of you. Then a tile would need to be redrawn and allow for sprites to still see. Is this a programming problem or a graphics problem.
If you want your sprites to want "behind" a tile then you need to use a method called "layering", where in this case you would render the base tile map, then your sprites and then the tile map with transparent tiles.
Ok I might go into transparant stuff later. I seem to have enough to do now and will look into a map editor next because I want better graphics.
Was the tile editor created using MFC c++ or directx or what?
I will give each tile a code to determine what part you can't move on, get the sprites xy point and see if it matches. The hard part seems having to work this out for each tile.
Don't know about pixel to pixel matching as that seems really slow the game down with the constant checking
Was the tile editor created using MFC c++ or directx or what?
I will give each tile a code to determine what part you can't move on, get the sprites xy point and see if it matches. The hard part seems having to work this out for each tile.
Don't know about pixel to pixel matching as that seems really slow the game down with the constant checking
Quote:
Original post by jagguy
Was the tile editor created using MFC c++ or directx or what?
What was used to make the editor isn't important, what's important is that your program can input the map file it exports. In TileStudio you can actually tell it how you want the file(s) export using a simple script. This confuses people too since they're used to fixed file formats or one's the fit nicely with their API of choice. Aw in other words, TS doesn't care what API you use.
Quote:
Original post by jagguy
Don't know about pixel to pixel matching as that seems really slow the game down with the constant checking
If you should need to do pixel-pixel collision for really fancy tiles/objects the best method is to implement both rectangle-rectangle and pixel-pixel testing. You use the rectangle-rectangle method first to tell what possible objects you might be colliding with, plus two intersecting rects gives a nice little "intersection" rect. This can really help speed up pixle-pixel testing.
See let's say we have two 32x32(to keep things simple) sprites, one named Bob and the other Jim. Let's say Bob is at 10,20 and Jim at 26,36.
(10,20)|-----------------|| Bob || || (26,36) || |--------|--------|| | | Jim || | | || | | ||-----------------| | | | | | | | |-----------------|First you test the rectangles to see if there's a collision. Now since this is true you get the "intersection" rectangle which starts at (26,36) and is 16x16 in size. So now all you have to do is compare the pixels in Bob's lower-right quadrant to the pixels in Jim's upper-left corner.
I knew about part rectangles and thats what i am doing. A tile is a rectangle and I can code to check only part of the tile that intersects with another sprite.
With a 32 pixel tile I would test up to a 1/4 of its size 8 pixels X 8 pixels. I thought you were talking about sizes smaller than that, and to test each pixel and not each small area.
I would like to know for interest sake what tile studio was made in because I would like to do other graphical apps but I have vc++ 2005 express and vc6c++ with mfc ( I can't load both on).
With a 32 pixel tile I would test up to a 1/4 of its size 8 pixels X 8 pixels. I thought you were talking about sizes smaller than that, and to test each pixel and not each small area.
I would like to know for interest sake what tile studio was made in because I would like to do other graphical apps but I have vc++ 2005 express and vc6c++ with mfc ( I can't load both on).
Rather than literally checking the pixels in the intersected rectangle, it would be faster to generate a map of each image at the start of the game in system memory that you check instead.
When memory was more of an issue, this was generally done with bitmasks and sections could be ANDed together to check for collisions which would be very quick indeed, but the code to determine which bits to compare and shifting bits about can get complex and now computers are faster and have more memory, a mask with a bool for each pixel is a lot simpler and probably fast enough.
I don't really know why you are interested in what TileStudio was written with. I don't know anything about it but I would guess it is a tool that allows you to generate map files from a set of tiles and output the map file in whatever format you want.
So you have a list of the tiles, each one occuring just once in the list, then a 2D map where each tile contains an index into the list of tile images. Using this file in your program would be entirely unrelated to the program that generated the file and you would still have to write the code that turned the map information into an actual graphical representation of the map, either on the fly each turn or by prerendering it at the start.
When your sprite intersects with a map rectangle, you would get the index in the map (by doing literalx/maptilewidth,literaly/maptileheight), use that to find the collision mask associated with that tile index, then compare the intersected rectangles of your sprite and the map tile by examining the values in the collision mask.
When memory was more of an issue, this was generally done with bitmasks and sections could be ANDed together to check for collisions which would be very quick indeed, but the code to determine which bits to compare and shifting bits about can get complex and now computers are faster and have more memory, a mask with a bool for each pixel is a lot simpler and probably fast enough.
I don't really know why you are interested in what TileStudio was written with. I don't know anything about it but I would guess it is a tool that allows you to generate map files from a set of tiles and output the map file in whatever format you want.
So you have a list of the tiles, each one occuring just once in the list, then a 2D map where each tile contains an index into the list of tile images. Using this file in your program would be entirely unrelated to the program that generated the file and you would still have to write the code that turned the map information into an actual graphical representation of the map, either on the fly each turn or by prerendering it at the start.
When your sprite intersects with a map rectangle, you would get the index in the map (by doing literalx/maptilewidth,literaly/maptileheight), use that to find the collision mask associated with that tile index, then compare the intersected rectangles of your sprite and the map tile by examining the values in the collision mask.
Quote:
Original post by jagguy
I would like to know for interest sake what tile studio was made in because I would like to do other graphical apps but I have vc++ 2005 express and vc6c++ with mfc ( I can't load both on).
TileStudio was made using Delphi. Anyway it shouldn't matter, that's like someone saying they want to make an FPS in 16-bit assembler because of DooM. Maybe it was the best option then, but it sure as hell isn't now.
Stick with VS2005 and please move VC6 to the recycle bin where it belongs. When VC6 came out, dinosaurs roamed the Earth [smile].
Can you use windows forms as a splash screen or program setting page, for a directx program. I mean can you pass information directly or do both programs need to read from a file start startup?
Maybe a vb or mfc form is easier to do , I don't know.
I take it windows forms or part of the new .net .
Maybe a vb or mfc form is easier to do , I don't know.
I take it windows forms or part of the new .net .
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement