Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Question about al_clear_to_color

Credits go to Edgar Reynaldo and SiegeLord for helping out!
This thread is locked; no one can reply to it. rss feed Print
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.
"Love thy neighbor as much as you love yourself means be nice to the people next door. Everyone else can go to hell. Missy Cooper.
The advantage to learning something on your own is that there is no one there to tell you something can't be done.

SiegeLord
Member #7,827
October 2006
avatar

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
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

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.
"Love thy neighbor as much as you love yourself means be nice to the people next door. Everyone else can go to hell. Missy Cooper.
The advantage to learning something on your own is that there is no one there to tell you something can't be done.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

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.
"Love thy neighbor as much as you love yourself means be nice to the people next door. Everyone else can go to hell. Missy Cooper.
The advantage to learning something on your own is that there is no one there to tell you something can't be done.

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

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.
"Love thy neighbor as much as you love yourself means be nice to the people next door. Everyone else can go to hell. Missy Cooper.
The advantage to learning something on your own is that there is no one there to tell you something can't be done.

Go to: