|
Question about al_clear_to_color |
Bob Keane
Member #7,342
June 2006
|
I am trying to write a game based on battleship. The plan is to draw one grid, get user input to place the ships, make a network connection then draw the second grid. I need to clear part of the screen between each step and during gameplay. Is it possible to use al_clear_to_color to erase only a specific part of the screen? By reading this sig, I, the reader, agree to render my soul to Bob Keane. I, the reader, understand this is a legally binding contract and freely render my soul. |
SiegeLord
Member #7,827
October 2006
|
It's possible, but it's a lot easier to just use al_draw_filled_rectangle. Stepping a bit back, it's likely better all around to re-draw everything each frame, and only draw what you need. "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
Bob Keane
Member #7,342
June 2006
|
I considered redrawing each frame, but am having problems conceptualizing it. My biggest worry is the program will keep prompting the players to input the coordinates for the ships and pegs each loop. Is it possible to save the screen, write the updates then flip the updated screen to the display? edit: I believe I am looking ahead of myself. I should be looking at routines to get the input first, but if there is a way to save the display and printing it when updated, I would appreciate knowing. By reading this sig, I, the reader, agree to render my soul to Bob Keane. I, the reader, understand this is a legally binding contract and freely render my soul. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
You can use a bitmap buffer you can redraw the screen every time or you can use dirty rectangles. 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 |
Bob Keane
Member #7,342
June 2006
|
Thanks for the advise. I think I'll worry about getting a keyboard routine working before I do the redrawing. By reading this sig, I, the reader, agree to render my soul to Bob Keane. I, the reader, understand this is a legally binding contract and freely render my soul. |
Rodolfo Lam
Member #16,045
August 2015
|
Consider this: A 3D game has to draw everything every single frame, and the computer doesn’t struggle at all doing it. It’s the job it was built for. What I am seen here actually is that you might be having a logical problem with the internal states of your game. Focus on your game logic first, and then look into graphics. Be aware that you need a Game Loop, which is different than a normal, sequential text-mode loop. Use events, single step iterations, flags, or whatever you need to know the game state. Draw in between updates.
|
Bob Keane
Member #7,342
June 2006
|
Rodolfo Lam said: Focus on your game logic first, and then look into graphics. Be aware that you need a Game Loop, which is different than a normal, sequential text-mode loop. Use events, single step iterations, flags, or whatever you need to know the game state. Draw in between updates. I think that is the issue. Thanks. By reading this sig, I, the reader, agree to render my soul to Bob Keane. I, the reader, understand this is a legally binding contract and freely render my soul. |
|