#165365 - afireohno - Thu Dec 18, 2008 4:57 am
This is my first post on here, so bear with me. I've been trying to figure out as much as I can on my own but I've run into a road block and was hoping for some help. I've been building off of the orangeShuttle tutorial and have created a very simple platform demo with a sprite that runs, walks, and jumps on a black screen.
Anyway, as the next obvious step I'd like to add some background, but I'm not sure how to set up the .grit file to create a tiled background. Do I want each tile be a separate image file and have a separate map, or will grit break it up for me? As you can probably tell I'm a little lost at this point and am not quite sure if I'm even asking the right questions?
#165384 - dovoto - Fri Dec 19, 2008 1:58 am
Generally you will create a tiled background in some sort of tile map editor which will output data in a usable format. For instance my own map editor will output each layer as a bitmap which i can then pass to grit to process.
Grit will take an image and from it build a tileset and a map and a palette. It can do this per image or it can build a cumulative tileset from multiple images. It can also take as an input a graphics file which contains your tiles (although this is not particularly useful).
http://www.coranac.com/man/grit/html/grit.htm <-- good place to start but here is a few examples of usage (as that area is marked todo for some reason ;) :
Code: |
make a map, tileset and palette from layer.bmp
grit layer.bmp -mR8
(output map with normal optimizations and 8 bpp tiles, palette and graphics data are output by default and the graphics are tiled by default)
|
Code: |
make a map per layer, a single tileset and single palette from layer1.bmp and layer2.bmp
grit layer1.bmp layer2.bmp -mR8 -pS -gSt
(same as above but process two layers and share the palette and tile graphics (not sure if the 't' is needed in -gSt but it signifies the graphics need to be tiled))
|
The output from this process would be a header file such as this:
Code: |
#define layerLen 256
extern const unsigned char layerMap[256];
#define layerTilesLen 6976
extern const unsigned int layerTiles[1744];
#define layerPalLen 512
extern const unsigned short layerPal[256];
|
The actual data comes in the form of an asm file which gets built with your project. You can access the data with the above variables.
Hope this was of some help
_________________
www.drunkencoders.com
#165389 - afireohno - Fri Dec 19, 2008 3:28 am
O.K. Well I think I understand most of that. Let me make sure though. layerTiles[1744] contains data for 27.25??? 8X8 tiles and layerMap[256] is map data for a map whose dimensions give a product of 256 * 8 (because each tile is 8X8 pixels).
My next question would involve collision detection, but I'll hold off on that until I know I've got it right so far.
#165397 - dovoto - Fri Dec 19, 2008 2:48 pm
afireohno wrote: |
O.K. Well I think I understand most of that. Let me make sure though. layerTiles[1744] contains data for 27.25??? 8X8 tiles and layerMap[256] is map data for a map whose dimensions give a product of 256 * 8 (because each tile is 8X8 pixels).
My next question would involve collision detection, but I'll hold off on that until I know I've got it right so far. |
It seems you might need a bit more help in starting out than would be appropriate in a forum post. There are a couple tutorials which may do your issue a lot more justice. I have a list of a few of them here:
http://www.drunkencoders.com/index.php?system_id=1&page=Tutorials
The first two are probably your best bet.
_________________
www.drunkencoders.com
#165400 - afireohno - Fri Dec 19, 2008 3:50 pm
I have read those tutorials and after quickly glancing back I realize my error came from oversimplifying things, and probably not reading carefully enough. Anyway, I feel like quite the dolt and please excuse me as this is my first attempt at graphics programming and thanks for the help. I'll reread them.
On an unrelated note I had a question about using hFlip and vFlip with the new API.
#165415 - dovoto - Fri Dec 19, 2008 10:47 pm
afireohno wrote: |
On an unrelated note I had a question about using hFlip and vFlip with the new API. |
The api doesnt really do anything with the map data. Your editor should properly set the flip attributes as appropriate durring export. In the example above grit would do this for you.
_________________
www.drunkencoders.com
#165421 - afireohno - Sat Dec 20, 2008 12:02 am
Sorry. I was jumping topics. I was asking about using it with sprites.