Thread: Mearging two bitmap images

  1. #1
    Jeff
    Guest

    Mearging two bitmap images

    I'm making a game using DJGPP compile and Alagro. So far i've been using the draw_sprite () command to put my character onto a green background (grass), now i've added bridges and other terrain that i would like my character to cross without having green all around him but rather my character drawn with what ever background object, say a bridge, around him. I've heard of something called masking but i can't seem to make it work. If anyone could help me i'd be gratefull. If possible could u give me an example. Thanks

  2. #2
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    Check the docs. I t hink it is in the Bitmap section

  3. #3
    Rambling Man
    Join Date
    Jan 2002
    Posts
    1,050
    Well, what you would do is create seperate bitmaps for all objects. For instance if you're using a 640x480 resolution, then make a 640x480 bitmap of you're background. Then you could make maybe a 80x80 bitmap for your character. If the character does not fill the whole space of the bitmap then fill the rest of the space with hot pink (255 R, 0 G, 255 B). Then make your bridge the same way as the character (same method...doesn't have to be same size of course).

    Here is the code part of it:

    Code:
    blit(background, buffer, 0, 0, 0, 0, 640, 480);
    blit(bridge, buffer, 0, 0, x, y, 640, 480);
    draw_sprite(buffer, character, x, y);  
    blit(buffer, screen, 0, 0, 0, 0, 640, 480);
    This will draw the background to the screen and then over the background it will draw the bridge. At the same spot as the bridge it will draw the character over the bridge. This is what you are looking for, right? Hope that helps. If you have anymore questions just ask.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Loading a bitmap (Without using glaux)
    By Shamino in forum Game Programming
    Replies: 7
    Last Post: 03-16-2006, 09:43 AM
  2. OpenGL -- Bitmaps
    By HQSneaker in forum Game Programming
    Replies: 14
    Last Post: 09-06-2004, 04:04 PM
  3. Loading a Bitmap resource for OpenGL Texture[x]
    By the dead tree in forum Game Programming
    Replies: 4
    Last Post: 08-26-2004, 01:12 PM
  4. bitmap not going onto screen
    By stallion in forum Windows Programming
    Replies: 4
    Last Post: 02-22-2003, 10:07 AM
  5. MFC Bitmap Images
    By westie in forum C Programming
    Replies: 0
    Last Post: 12-13-2001, 10:07 AM