I am interested in making a GUI-intensive strategy game with C++ and GTK+. What I would like to know is how feasible it would be to add 2D game graphics to a GTK program. Basically I would be wanting something like a game screen, with interactable 2D graphics, flanked by menus and the ability to navigate to other screens that would be GUI only.
Note that I have never used GTK before, nor have I before programed a GUI (nor graphics either).
It's certainly possible with GTK, but you have to ask yourself whether you're using the right tool for the job. Use Clutter, which is much more suited to animation and integrates with GTK; or perhaps better yet, use a game programming toolkit.
Here's an example of two non-intensive proof-of-concept games written with Clutter, with links to their source code.
It's possible. I did it with GTK and Vala some time ago. Here is a blog post I wrote about it. Basically it's very much like the games you make with Java and Swing. Just override the expose
signal and create a timer
for regular redraws. Here's an article on developing a 2D Snake game in PyGTK.
In pseudocode, all you do for the game infrastructure is:
start()
{
tick_timer( 1.0 / FPS );
load_all_sprites_etc();
}
tick()
{
update();
game_board.expose(); // game_board is a GTKWidget, preferably a DrawingArea
}
expose_event() // connected to game_board
{
drawing_code();
}
update()
{
game_physics();
game_logic();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With