Hi all, I've an interesting problem....
I've a game Im developing, it consists of a background image, then 2 other levels of graphics placed on top of it..... semi background items, tree etc (layer 1), then foreground items (layer 2). the background image is just stored in a buffer, while the other two layers are stored in 2-d arrays as they are larger than the screen, they contain "tile" numbers that are to be drawn in that location, what I currently do is copy all of the layer1 items (pics) to a large buffer and overlay it to the screen and then add layer2 item, the problem is that layer 1 contains transparent pixels, and can't be memcpy'ed to the screen buffer, as can the bg layer, same as layer 2. what I've done is copied the layer1 and layer 2 pics to a buffer to be drawn to the screen.... this is quicker, then use the following code to place the visual part of the "level" to the user. eg:
but this does not draw them trans, since they have all been copied to the buffer previously (level setup code), the trans color is always black, is the a simple bit of code to draw this buffer to the screen with trans (ignoring the black) without if's, or fast.....
I've a game Im developing, it consists of a background image, then 2 other levels of graphics placed on top of it..... semi background items, tree etc (layer 1), then foreground items (layer 2). the background image is just stored in a buffer, while the other two layers are stored in 2-d arrays as they are larger than the screen, they contain "tile" numbers that are to be drawn in that location, what I currently do is copy all of the layer1 items (pics) to a large buffer and overlay it to the screen and then add layer2 item, the problem is that layer 1 contains transparent pixels, and can't be memcpy'ed to the screen buffer, as can the bg layer, same as layer 2. what I've done is copied the layer1 and layer 2 pics to a buffer to be drawn to the screen.... this is quicker, then use the following code to place the visual part of the "level" to the user. eg:
- Code:
void draw_items()
{
for (int ly = 0; ly < 300; ly++)
{
memcpy(screen_buffer_p+(240 * ly),levelbg_scr_p+(level.sizex * level.tile_size * (ly + level.tile_size * player.viewy) + player.viewx * level.tile_size),480);
}
}
but this does not draw them trans, since they have all been copied to the buffer previously (level setup code), the trans color is always black, is the a simple bit of code to draw this buffer to the screen with trans (ignoring the black) without if's, or fast.....