Jump to content
  • Advertisement
Sign in to follow this  
Soundstone

Allegro bitmaps at runtime?

This topic is 2091 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone,

 

I have recently run into a problem that I'm not sure Allegro 5 can handle. I was curious if anyone knew whether or not the following functionality existed for the Allegro graphics library.

 

I am aware that to get a scrolling background one can provide an image and load it in as a ALLEGRO_BITMAP *background. I have done this just fine. However, for the particular game I am trying to code I generate the level at random.

 

Basically I generate two arrays of points, one for my ceiling and one for my floor. These arrays are size top[333] and bottom[333]. The distance between each point is between 36 - 48 pixels, thus my final point in both arrays is someone just over 12,050 as the X coord.

 

My question is this, does Allegro have a way to create an image at runtime based on the plot placement of these randomly generated points?

I've tried looking at the Allegro5 manual and it doesn't really provide any information on bitmap creation at runtime. Does anyone have experience with this sort of thing, or am I doomed to choose a new graphics library or create static images instead of random?

 

Thanks for taking the time to read and any advice that may be offered.

 

 

Share this post


Link to post
Share on other sites
Advertisement
Sure; first, create a BITMAP. Then, lock your new bitmap and set the target bitmap. You then can use any of the drawing operations such as al_put_pixel or al_draw_bitmap to draw to your dynamically created bitmap. Don't forget to unlock the bitmap when you're done. Remember that creating bitmaps are expensive operations, so use al_clear_to_color on the same bitmap instead of creating it each frame, if needed.

Note: It's been a quite a few years since I've touched Allegro, so I might not be quite accurate.

Share this post


Link to post
Share on other sites

Hi Fastcall, 

 

Thanks for the reply! The information was a relief to hear. Would you recommend printing the entire thing to one bitmap and then drawing a region of that bitmap with al_draw_bitmap_region() or just keep a bitmap the size of my screen and keep clearing / drawing the new sets of points to it before blitting to the display? Thanks again.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!