Page 1 of 3 123 LastLast
Results 1 to 20 of 51

Thread: 4 in a row

  1. #1
    Join Date
    May 2011
    Posts
    120
    Thanks
    33
    Qt products
    Qt4
    Platforms
    Windows

    Default 4 in a row

    Hai all,
    I am developing my own 4 in a row game in qt. while we play the ball falls from top to bottom of the grid the problem is that it feels like ball falls over through the grid . But I want the feel that ball falls through inside the grid . I tried what i know? but no use. Is there any way to do so?
    thanx in advance .

  2. #2
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: 4 in a row

    Could you describe a little more what is your current implementation?

  3. #3
    Join Date
    May 2011
    Posts
    120
    Thanks
    33
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: 4 in a row

    hai rachol,
    There is a 7x7 grid(image). There are two players one is comp: and another is user. There are two balls . now the ball falls to the bottom from top when we clicked on the desired position but through over the grid(Image). I want to get a feel that ball is falling through the grid cells and get placed in the position

  4. #4
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: 4 in a row

    Ok,

    But how did you think to implement it?

    QGraphicsView or custom QWidgets?

  5. #5
    Join Date
    May 2011
    Posts
    120
    Thanks
    33
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: 4 in a row

    Using QWidgets

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

    Default Re: 4 in a row

    So why are you posting your problem in Qt Quick forum?
    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.


  7. #7
    Join Date
    May 2011
    Posts
    120
    Thanks
    33
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: 4 in a row

    by mistake

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

    Default Re: 4 in a row

    So how does your widget look like? How did you implement it?
    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.


  9. #9
    Join Date
    May 2011
    Posts
    120
    Thanks
    33
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: 4 in a row

    I named my Qwidget as mainwidget and coded like this:
    Qt Code:
    1. ui->mainwidget->setStyleSheet("background-image: url(content/Pics/M_CCholder.png); "
    2. "background-position: top left; ");
    To copy to clipboard, switch view to plain text mode 


    it works for me but the problem remains the same?

  10. #10
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: 4 in a row

    Well, because you are setting background to your main widget on top of which all the children widgets are drawn, it doesn't work the way you wished for.

    What about placing another backgroundWidget on top of your mainwidget? Or using QStackedLayout::StackAll and having your backgroundWidget being the current widget in the layout?

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

    vinayaka (20th June 2011)

  12. #11
    Join Date
    May 2011
    Posts
    120
    Thanks
    33
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: 4 in a row

    hai rachol,
    I did so and it worked too but there are more than 1 ball. Can you tell me how can I move the ball .Is there any animation property to add to get the ball move?


    Added after 6 minutes:


    I solved a problem(more than 1 ball problem). but how can I animate the ball


    Added after 12 minutes:


    Is this the correct way to have one ball
    Qt Code:
    1. ui->induwidget->setStyleSheet("background-image: url(content/Pics/balla.png); "
    2. "background-position: top left ; background-repeat:none;");
    To copy to clipboard, switch view to plain text mode 
    Last edited by vinayaka; 20th June 2011 at 10:56.

  13. #12
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: 4 in a row

    I am afraid, you have to do the animation yourself. There isn't such functionality in Qt, unless you are using QML.

  14. #13
    Join Date
    May 2011
    Posts
    120
    Thanks
    33
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: 4 in a row

    so how can I animate that ball. ball is set in Qwidget. can use Qml here to animate ball(i think this is a stupid ?)

  15. #14
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: 4 in a row

    Please take a look at http://doc.qt.nokia.com/latest/qml-advtutorial.html. I think this would be the best starting point for creating "4 in row" game

  16. The following user says thank you to Rachol for this useful post:

    vinayaka (20th June 2011)

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

    Default Re: 4 in a row

    Is there any other code in your application besides stylesheets?
    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.


  18. #16
    Join Date
    May 2011
    Posts
    120
    Thanks
    33
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: 4 in a row

    not now . I deleted the codes now In have only stylesheets..
    if i do this project in qml only is it possible to open pro: in visual studio?

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

    Default Re: 4 in a row

    Quote Originally Posted by vinayaka View Post
    if i do this project in qml only is it possible to open pro: in visual studio?
    Possibility of opening the .pro file in Visual Studio doesn't depend on whether your're using qml or not.
    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.


  20. #18
    Join Date
    May 2011
    Posts
    120
    Thanks
    33
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: 4 in a row

    I mean only qml project file with Javascript

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

    Default Re: 4 in a row

    You can open any text file you want in Visual Studio.
    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.


  22. #20
    Join Date
    May 2011
    Posts
    120
    Thanks
    33
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: 4 in a row

    hai I cahnged my code to Qml and js


    Qt Code:
    1. import Qt 4.7
    2.  
    3.  
    4. import "content"
    5. import "content/Four_in_a_row.js" as Games
    6.  
    7. Rectangle {
    8. id: game
    9.  
    10. property bool running: true
    11. width: display.width; height: display.height + 10
    12.  
    13. Image {
    14. id: boardImage
    15. source: "content/pics/My_grid.png"
    16. }
    17.  
    18.  
    19. Column {
    20. id: display
    21.  
    22. Grid {
    23. id: board
    24. width: boardImage.width; height: boardImage.height
    25. columns: 3
    26.  
    27. Repeater {
    28. model: 9
    29.  
    30. Four {
    31. width: board.width/3
    32. height: board.height/3
    33.  
    34. onClicked: {
    35. if (game.running && Games.Play(index)) {
    36. if (!Games.Move(index, "k"))
    37. Games.computerTurn();
    38. }
    39. }
    40. }
    41. }
    42. }
    43.  
    44.  
    45. }
    46.  
    47. }
    To copy to clipboard, switch view to plain text mode 

    My_grid.png is a grid image. now it work like tic_tac_toe. I want to animate the ball as its falling through the grid(that's my aim).can I use 2 Grid in a qml file? how can I use it?

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.