Results 1 to 9 of 9

Thread: List of cards (Game programming)

  1. #1
    Join Date
    Nov 2011
    Posts
    8
    Thanks
    2

    Red face List of cards (Game programming)

    http://www.quality-games.com/media/T...litaire-sc.jpg

    I'm writing a "card engine" which means I have to reuse code for like every card game. The most difficult part for me
    will be designing a decent user interface with Qt. I can do the basic stuff in Qt involving the normal widgets and
    deriving a clicklabel from a label etc... But my question...

    I want to design a list of cards, a hand or a game like the link above... The problem is... Qt has not much widgets I can pick and just
    reuse ...

    What would be the best option I can take to work with the qt designer, coding my game in c++... (list view will look ugly or not?)

    How do I create the "widgets" myself or is there any other alternative... available resources or something

    If someone could help me out,
    I would really appreciate

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: List of cards (Game programming)

    Use QGraphicsView, QGraphicsScene and related classes. Qt is something more than just widgets.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    dieter (1st February 2012)

  4. #3
    Join Date
    Nov 2011
    Posts
    8
    Thanks
    2

    Default Re: List of cards (Game programming)

    I have looked up them a bit... They are great for adding some rectangulars and other graphics...
    But is it also a good way to have lists of Cards (clickable images sorted in lists) I mean I need
    access to every item...
    Anyway thx for the usefull post

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: List of cards (Game programming)

    Quote Originally Posted by dieter View Post
    They are great for adding some rectangulars and other graphics...
    But is it also a good way to have lists of Cards (clickable images sorted in lists) I mean I need
    access to every item...
    To me a card is a "rectangular thing with other graphics" so graphics view seems perfect for the task.

    The way you organize your objects doesn't depend on what classes represent those objects.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #5
    Join Date
    Nov 2011
    Posts
    8
    Thanks
    2

    Default Re: List of cards (Game programming)

    So I need to drag from a QListWidget or something similar on to a QGraphicsScene. When I drop, I will create an new QGraphicsItem subclass at the drop location. How can I do this? setAcceptDrop is not even available for a QGraphicsScene.

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: List of cards (Game programming)

    What do you need QListWidget for? Why do you need to drag anything?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #7
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,319
    Thanks
    316
    Thanked 870 Times in 857 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: List of cards (Game programming)

    @dieter: What are you asking for - a container object to hold your internal description of a "card" object, or a way to display the images contained in those card objects on the screen, or a way for your game users to interact with those images? As Wysota said, the internal representation of a card and a collection of cards has almost nothing to do with displaying and interacting with card images on the screen.

    If you are looking for a completely generic representation of a card object and a "card deck" object, along with rules for the "value" of a card and how and when that card can be played, then you need to design that card game engine logic completely independently of your GUI. Likewise, your GUI should have minimum knowledge of the game and its rules, but knows how to ask the game engine about how to construct the display and whether an attempt to move a card from one place to another is allowed by the rules, etc.

    If you don't keep the card game engine separate from the card GUI, you will likely end up with a mess of spaghetti code that might be able to play one kind of game, poorly, and no way to easily change it to accommodate a different game or different rules.

  9. #8
    Join Date
    May 2010
    Posts
    24
    Thanks
    14
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: List of cards (Game programming)

    I am very interested in this topic.

    I'd like to design a card game, but am unsure on how to represent the cards on the gui. I've designed an app where a card was represented by a widget. This way, I can use its built in drag/drop capabilities and also take advantage of the fact that a card could contain several clickable components (ie, other widgets).

    However, wysota suggests using graphics views. Is that what is commonly used for representing cards in card games like Solatair, Texas Holdem, or online CCG's?

  10. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: List of cards (Game programming)

    Quote Originally Posted by Ronayn View Post
    This way, I can use its built in drag/drop capabilities and also take advantage of the fact that a card could contain several clickable components (ie, other widgets).
    You can do all that (and much more) with graphics view.

    Think how you would e.g. rotate a card using widgets.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. The following user says thank you to wysota for this useful post:

    Ronayn (16th February 2012)

Similar Threads

  1. Replies: 1
    Last Post: 8th June 2011, 05:01
  2. Replies: 1
    Last Post: 22nd May 2010, 07:38
  3. Game programming basic questions?
    By unix7777 in forum Newbie
    Replies: 3
    Last Post: 20th February 2010, 17:16
  4. Starting game programming using Qt
    By sophister in forum Qt Programming
    Replies: 4
    Last Post: 4th November 2009, 05:31
  5. QGraphicsView and game programming
    By ball in forum Newbie
    Replies: 5
    Last Post: 9th January 2007, 21:14

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.