|
2D game with classes: Background issue |
CodeOne
Member #15,442
December 2013
|
ALLEGRO 5.0.10 with c++ I have a 800x400 display In which I have drawn a horizontal line A ball is continuously moving on this line . I used transformation to keep the ball at the centre of screen. After a while ball moves into black screen space as the line was drawn only till x=800 . Line doesnt exist beyond x=800 position. Is there a way so that I can loop this line to appear continuously ,like forever? As long as ball is moving. |
Neil Roy
Member #2,229
April 2002
|
If you want a solid line, like a ground surface that never changes on screen, just update your various game object movements, then draw the fixed ground last so it is always on screen, ie: don't move the ground. Though you may wish to make something more dynamic, like a tiled ground and you check an array which states which tile is to be drawn next and you draw it etc.. not sure what you are doing here, you're very vague. --- |
CodeOne
Member #15,442
December 2013
|
Ok, I was just wondering if I can make it happen. Solved it. But then i came across this cool software called MAPPY. I used a tile this time instead of a solid line. tile size : 64x60 But again my ball travels pretty fast. Game crashes. I think it may be that because ball crosses 6400th pixel. How to loop this thing ?? gimme an idea to implement such that it never ends. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Yeah, use a map image with twice the size that you want your wrapped background to be, then draw it twice next to each other and then each frame draw out of that buffer to the screen using modulus to find out the coordinates of the background that you should be using. Or you can draw twice, depending on clipping to get rid of the extra on the sides. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
|