allegro, mappy, and mappyal

Started by
2 comments, last by cwl157 14 years, 6 months ago
I am using allegro, mappy, and mappyal to make a game. If anyone is familiar with these tools i need some help. Its a rectangular tile based game from a top down perspective. I am having trouble placing a character on top of the background. Even if i use the BG transparancy and have the background of the character's tile the same as the transparency color, when i place the character on the map the background color of the tile (black) still shows through. The work around i thought of is to create a tile for the character for each service he will walk on, stone, grass, etc and then place that tile of the character when he is moving. That way it looks like the background in the character tile is transparent but really it would just change based on what the character is walking on at that time. This seems to add unnessecary complexity. Anyone know how to make a character's tile background truly transparent so it appears on top of whatever tile is the surface? I know mappy has more then 1 layer maps and tiles but i don't know how to use this beacuse each tile can be set to have a FG but then if FG is shown won't it show it for every tile? Or maybe its by using multiple map layers but i am using those for the levels, and depending on which level of the game it is, it shows a different map layer. Thanks.
Advertisement
Hi, could you paste some code?

Especially the code you use to draw the map and the character.
Sure. So i use Mappy to create the map which basically takes a tile sheet and lets you put the tiles down on a map and then add attributes such as collision detection and other data onto each tile. Then i use the mappyal library which is a bunch of c functions, NOT C++ but C functions, to load the map file and manipulate the tiles. Each tile has a numeric id associated with it. So to erase a tile, lets say erase a character and replace it with a grass tile you would simply say MapSetBlock(int, int, int) and pass it the x and y coordinates on the map where the character is and replace it with the tile id matching grass.

So to draw the map i simply call this:
MapDrawBG(buffer, convertToPixels(12), 0, 0, 0, SCREEN_W-1, SCREEN_H-1);

This will draw the map to the buffer BITMAP* at the x and y in pixels. I want it to start at 12th tile for x so i multiply 12 by 32 (the size of the tile) and that gets the starting x position in pixels, then i leave the others at 0 because i want to end at 0 and then i want the map to take over the entire screen area so i set it to the screen width and height.

Now how to draw the character. So ideally, i would want the character tiles to have a transparent background however, i could not get that to work, i think it has something to do with layers in Mappy. But at any rate the work around i thought of was to just create a tile of the character for each background he could be placed on top of since there is only 6 of them.

To draw the character with the right background i have to check the tile they are moving to and tell it to MapSetBlock(int, int, int) passing it the tile id of the character tile with the proper background.

I think i can get this working for now, however, as the game expands and the character walks on more backgrounds i need to figure out how to make his background transparent.

So to answer the original question to draw the character i simply update its x and y positions and then call MapSetBlock(character.x, character.y, characterTileId) and that draws that tile to the x and y position on the map.

I hope that helps.

Carl
Alright i figured it out for now. I just had to keep track of the ID of each individual tile in one of the block's attributes. Its kind of weird that it doesn't give access to that built in and that i have to use 1 of the other attribute containers for it, but it will work for now. Player movement is definetly something i will have to improve when version 2 rolls around next year.

This topic is closed to new replies.

Advertisement