PDA

View Full Version : 2D Game - bitmaps



Macok
4th March 2009, 18:21
I'm planning to write a simple 2d game, looking similar to this:
http://www.gamedev.pl/screens/cef1db26efb74031dbe36cc8cf8cf477.jpg
As you can see, screen is divided by a squares, and at every square there's some bitmap displayed.
I could use SDL library, but maybe is there simpler way to do it in Qt?

PS. Probably I could use openGL Qt module, but I think that openGL isn't a good idea for 2D graphics.

Lykurg
4th March 2009, 18:52
Spontaneous thinking of QGraphicsScene with constant sized items arranged in a QGraphicsGridLayout...

Macok
4th March 2009, 19:07
Thanks, but how do you think, is it good idea to use this class for such a game?
Maybe it's still better to use SDL, or some other feature of Qt?

Lykurg
4th March 2009, 19:20
First I don't have ever worked with SDL. But for your case: You have as you said an simple 2d game. OpenGl would be overkill for that. In your view won't be much changes. Only some people or monsters will walk around. Therefore QGraphicsView is perfect! (See the new accelerations in 4.5) You also need a label for displaying further informations and you might want to brovide a menu bar etc. So you would mix Qt with SDL. This maybe causes trouble while compiling on different platforms...

So better stay for your purpose on Qt alone. Even since your game dosen't need much cpu/gpu you can truly forget about some advantages or disadvantages of Qt or SDL.

Lykurg

Macok
4th March 2009, 19:38
Thanks, but I have doubts...
Imagine we have some creature on a screen, and it's moving on another square.
It'll be something like this:
void Move(){
ui->square1->setItem("Grass");
ui->square2->setItem("Creature");
}But it'll looks ugly, becouse creature will "jump" from square to square.
I'd like it to move fluently.
Is there any way to reach such an effect?

Lykurg
4th March 2009, 19:57
For that you can lay an "Creature-item" over the landscape and move it freely over the screen using QTimer for example. That's not that difficult and because you only want move from field a to field b you can create a function "moveItemFromTo(Item creature, Item startitem, Item enditem)" and in that you handle all necessary things. This keeps you code nice and easy.

You may be also have a look at Kinetic (http://labs.trolltech.com/page/Projects/Graphics/Kinetic).

Lykurg