Question about al_clear_to_color
Bob Keane

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?

SiegeLord

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.

Bob Keane

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.

Edgar Reynaldo

You can use a bitmap buffer you can redraw the screen every time or you can use dirty rectangles.

Bob Keane

Thanks for the advise. I think I'll worry about getting a keyboard routine working before I do the redrawing.

Rodolfo Lam

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

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.

Thread #617801. Printed from Allegro.cc