Results 1 to 2 of 2

Thread: Checkers in Qt - ideas for board and pieces representation

  1. #1
    Join Date
    Dec 2011
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Checkers in Qt - ideas for board and pieces representation

    Hi all.

    I'm working on a multiplayer checkers game in Qt and I wonder what board and pieces representation should I implement.

    Currently, I have a main window class responsible for GUI and network connection. It contains an object of class Board (based on QGraphicsScene). Board class contains an array of 32 objects of class Square (based on QGraphicsItem) and an array of 24 objects of class Piece (based on QGraphicsItem). I thought to create access methods (to squares and pieces) in Board class and add needed members to square and piece classes (ident, pointer to occuping piece for square and color, type, pointer to occupied square for piece). In my idea piece should be responsible for checking for possible moves and making them etc.

    Is that good idea? I wonder wheter I should bind game logic and graphical interface that much. Do you have any advices or other solutions to this problem? This is my first "serious" application and I'm confused a little. Thanks in advance for your help and sorry for my poor english.

  2. #2
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Checkers in Qt - ideas for board and pieces representation

    Make the GUI to be your view.
    View should have a bunch of elements that have methods related to their visual appearnce, ie move( MyGame::Left ), changeColor() but they don't have any business logic.

    Then you should have a controller object that will use the view to reflect what's going on and will know what is where, what can be done etc.
    This pattern is called MVC (in this case just VC).

    That would be my approach.

Similar Threads

  1. single board computer embeddede board, mini2440v2, sky2440v2
    By wujianwen in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 2nd November 2016, 07:29
  2. Image/Pixmap after scaling parcelled into 4 pieces.
    By Douglish in forum Qt Programming
    Replies: 2
    Last Post: 19th February 2011, 09:28
  3. Chess Program Drag and drop pieces
    By cwnelatury in forum Newbie
    Replies: 2
    Last Post: 29th April 2009, 22:43
  4. Tree related representation
    By aegis in forum Qt Programming
    Replies: 1
    Last Post: 12th August 2007, 12:20
  5. In what order do you create program pieces?
    By Backslash in forum Newbie
    Replies: 2
    Last Post: 15th July 2007, 18:18

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.