Jump to content

  • Log In with Google      Sign In   
  • Create Account

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   Members   

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.

 

 



#2   Moderators   

9738
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.
zlib: eJzVVLsSAiEQ6/1qCwoK i7PxA/2S2zMOZljYB1TO ZG7OhUtiduH9egZQCJH9 KcJyo4Wq9t0/RXkKmjx+ cgU4FIMWHhKCU+o/Nx2R LEPgQWLtnfcErbiEl0u4 0UrMghhZewgYcptoEF42 YMj+Z1kg+bVvqxhyo17h nUf+h4b2W4bR4XO01TJ7 qFNzA7jjbxyL71Avh6Tv odnFk4hnxxAf4w6496Kd OgH7/RxC

#3   Members   

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.