Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Scroll window within a background BMP

This thread is locked; no one can reply to it. rss feed Print
Scroll window within a background BMP
AceBlkwell
Member #13,038
July 2011
avatar

I'm using Allegro 4.4.2. Writing a console game. I'm putting final touches on a game I'm writing. The instruction screen has grown larger than one screen. I can probably figure a way to do a page 1 then page 2 but thought it would be cool to have the examples and words scroll within a background set window.

Assuming this is a possibility, can someone give me a few command words to look into or an example to look up so I can get an understanding on how these things work?

Thanks,
Ace

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

You need the size of your window, and the size of your buffer. ScrollMax is the difference of the two. Set a variable called scroll to [0,ScrollMax] and create a scroll bar the size of your window with the size of the handle proportional to the percentage of your view that you are showing. Drag the handle of the scroll bar to change the value of your scroll variable. Display the contents of your window based on your scroll variable.

Here's my scroller class if you want an example.

Scroller.hpp

Scroller.cpp

It uses several classes from my GUI, namely LayoutRectangle and WidgetArea, but it should give you an idea of what you need to make a scroller. The repeat delay is for when someone clicks on an area outside of the scroll handle but inside the scroll bar because they want to scroll by a page.

AceBlkwell
Member #13,038
July 2011
avatar

Edgar,

Thanks, I'll look in to this. I think this is the next step for my next program attempt. Looks well written. I can learn from that if nothing else.

What I was looking for was something similar to the movement in a scroll game. Push down and the info scrolls up pixel roll by pixel roll. If you have my previous DAT file you can see the background picture has a smaller section that I write into. I was thinking if I can change the writable screen to the interior of the background BMP. then I could scroll the data within that window. Ive read about something similar before I just didn't know the allegro commands that i would use. ;D honestly I was trying avoid days of research.

Thanks Again,
Ace

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Just increment your scroll variable when your mouse is over the bottom 10 pixels, and limit it to the size of the background bitmap - the size of the view.

Similarly, decrement your scroll to zero when mouse is above 10 pixels of the screen top. You'll have to monitor ALLEGRO_EVENT_MOUSE_AXES and ALLEGRO_EVENT_TIMER messages and once every timer if the mouse is in the scroll area of the screen, then scroll.

Go to: