Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Allegro bitmaps at runtime?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Soundstone   Members   -  Reputation: 191

Like
0Likes
Like

Posted 19 January 2014 - 03:12 PM

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.

 

 



Sponsor:

#2 fastcall22   Crossbones+   -  Reputation: 5278

Like
2Likes
Like

Posted 19 January 2014 - 03:46 PM

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.
QWxsIHRvYXN0LXRvYXN0aW5nIHRvYXN0ZXJzIGNhbiB0b2FzdCB0b2FzdGVkIHRvYXN0LCBhbHRob3Vn aCByZS10b2FzdGluZyB0b2FzdGVkIHRvYXN0IGlzIGdlbmVyYWxseSBub3QgcmVjb21tZW5kZWQgYnkg dGhlIG1hbnVmYWN0dXJlcnMgb2YgdG9hc3QtdG9hc3RpbmcgdG9hc3RlcnMuLi4=

#3 Soundstone   Members   -  Reputation: 191

Like
0Likes
Like

Posted 25 January 2014 - 08:01 PM

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS