Results 1 to 6 of 6

Thread: 2D Game - bitmaps

  1. #1
    Join Date
    Jan 2009
    Posts
    51
    Thanks
    28
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default 2D Game - bitmaps

    I'm planning to write a simple 2d game, looking similar to this:

    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.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: 2D Game - bitmaps

    Spontaneous thinking of QGraphicsScene with constant sized items arranged in a QGraphicsGridLayout...

  3. The following user says thank you to Lykurg for this useful post:

    Macok (4th March 2009)

  4. #3
    Join Date
    Jan 2009
    Posts
    51
    Thanks
    28
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: 2D Game - bitmaps

    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?

  5. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: 2D Game - bitmaps

    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

  6. The following user says thank you to Lykurg for this useful post:

    Macok (4th March 2009)

  7. #5
    Join Date
    Jan 2009
    Posts
    51
    Thanks
    28
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: 2D Game - bitmaps

    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:
    Qt Code:
    1. void Move(){
    2. ui->square1->setItem("Grass");
    3. ui->square2->setItem("Creature");
    4. }
    To copy to clipboard, switch view to plain text mode 
    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?

  8. #6
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: 2D Game - bitmaps

    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.

    Lykurg

  9. The following user says thank you to Lykurg for this useful post:

    Macok (4th March 2009)

Similar Threads

  1. Replies: 0
    Last Post: 22nd February 2009, 13:15
  2. QT debug confusion
    By swistak in forum Installation and Deployment
    Replies: 2
    Last Post: 24th September 2008, 19:25
  3. BlackJack The Game
    By raphaelf in forum Newbie
    Replies: 1
    Last Post: 2nd June 2008, 17:55
  4. Just for fun game
    By vermarajeev in forum Qt-based Software
    Replies: 6
    Last Post: 13th December 2007, 21:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.