Page 3 of 3 FirstFirst 123
Results 41 to 51 of 51

Thread: 4 in a row

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

    Default Re: 4 in a row

    thank u very much wysota. I got it . thanx again.....

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

    Default Re: 4 in a row

    Qt Code:
    1. Rectangle {
    2. width: 320
    3. height: 480
    4. id:mainPage
    5.  
    6. Image {
    7. id: firstPage
    8. width: mainPage.width;height: mainPage.height
    9. source: "pics/M_FCCmainScreen1.jpg"
    10. }
    11.  
    12.  
    13. Rectangle{
    14. id:playIcon
    15. width: mainPage.width/5;height: mainPage.height/5
    16. color: "transparent"
    17. x:mainPage.width/4;y:-40
    18. Image {
    19. anchors.fill: parent
    20. id: playImage
    21. source: "pics/M_playDown.png"
    22. }
    23.  
    24.  
    25. SequentialAnimation on y {
    26. loops: 1
    27.  
    28. SmoothedAnimation { target: playIcon; property: "y"; to: 200; duration: 1500; }
    29. // SmoothedAnimation { target: playIcon; property: "x"; to:75; duration: 1500; }
    30. //SmoothedAnimation { target: playIcon; property: ""; to: 400; duration: 1500; }
    31.  
    32. }
    33.  
    34.  
    35.  
    36.  
    37. MouseArea{
    38. id:playArea
    39. anchors.fill: parent
    40. onClicked: {
    41. playImage.source="pics/M_playUp.png"
    42. }
    43. }
    44.  
    45.  
    46. }
    47. }
    To copy to clipboard, switch view to plain text mode 

    In this code when we click in "M_playDown.png" image it get changed to "M_playUp.png". I want to load a new page here asking "who goes first"?. I used Loader here to load the page

    Qt Code:
    1. MouseArea{
    2.  
    3. i MouseArea{
    4. id:playArea
    5. anchors.fill: parent
    6. onEntered: {playImage.source="pics/M_playUp.png"}
    7. onClicked: {
    8. loader.source = "Game.qml" }
    9. }
    To copy to clipboard, switch view to plain text mode 

    I want it to load in vertical orientation. can some one help me in this.

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

    Default Re: 4 in a row

    What is the problem?
    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.


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

    Default Re: 4 in a row

    My output is this.

    When we click in the play button
    [IMG]



    we get this image.

    but at the same time a new page should come from the bottom of the screen asking who goes first( I used Listview and orientation: Qt.Horizontal)but didn't get the desired result(may be problem of my code).

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

    Default Re: 4 in a row

    The code you posted is not enough to determine what is wrong or even what you are trying to do. I would just use a state machine that would slide the screen for me, I certainly don't see a point in using some separate qml file for asking which player should go first (as if it made any difference whatsoever) and I definitely see no use for ListView here.

    Using "Behavior on y" and adding an animation there should be enough to do what you want.

    javascript Code:
    1. import QtQuick 1.0
    2.  
    3. Rectangle {
    4. width: 360
    5. height: 360
    6. id: rct
    7. Text {
    8. id: txt
    9. anchors.centerIn: parent
    10. text: "Hello World"
    11. }
    12. MouseArea {
    13. anchors.fill: parent
    14. onClicked: {
    15. newtxt.opacity = 1
    16. txt.opacity = 0
    17. newtxt.y = txt.y
    18. }
    19. }
    20.  
    21. Text {
    22. id: newtxt
    23. text: "Goodbye World"
    24. opacity: 0
    25. y: 360
    26. anchors.horizontalCenter: parent.horizontalCenter
    27.  
    28. Behavior on y {
    29. SmoothedAnimation { }
    30. }
    31. }
    32. }
    To copy to clipboard, switch view to plain text mode 
    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. The following user says thank you to wysota for this useful post:

    vinayaka (6th July 2011)

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

    Default Re: 4 in a row

    thanx
    I have more than one page to do so. I mean when we click to the play icon a new page will come from the vertical direction seeking who goes first? if we click an option another page arrives containing 4 in a row game in horizontal direction or if we click cancel icon from this page it wil show the first page (in horizontal direction)

    [IMG] [/URL][/IMG]
    how can we inactive a page. Exit game is a new page which comes up when we click main menu icon. but the problem i can still play the game .how can disable that.
    Last edited by vinayaka; 6th July 2011 at 13:35.

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

    Default Re: 4 in a row

    Change opacity of the page to 0. Or disable interactive areas of the page (like MouseArea elements).
    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. #48
    Join Date
    May 2011
    Posts
    120
    Thanks
    33
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: 4 in a row

    hai , mainmenu( in the above image lose it controls after on click).

    when we click in the mainmenu exit msg page(i call it as letmeout.qml) is shown with choice letmeout and keep playing. if we click keep playing. the exit msg page's opacity changes to 0. we can play then but have no control on main menu button.it doesn't work anymore

    LetMeOut.qml
    Qt Code:
    1. import QtQuick 1.0
    2. //Exit msg........
    3.  
    4. Item{
    5. id:exitItem
    6. width: exitAlert.width;height: exitAlert.height
    7. PauseAnimation { id:pausing;duration: 5000 }
    8. //exitAlert open ups...
    9. Rectangle {
    10. id:exitAlert
    11. width: 320
    12. height: 480
    13. color: "#60FFFFFF"
    14. x:-width+width-5
    15. y:-height+60
    16. MouseArea{id:exitAlertArea;anchors.fill: parent;
    17. onClicked: {exitAlert.opacity=0}
    18. }
    19. PropertyAnimation{id:exitAnim;target:exitAlert;property: "x";to:exitAlert.width+200;duration: 2000 }
    20. Image {
    21. width: parent.width/1.1
    22. height: parent.height/2.5
    23. id: exitIcon
    24. source: "pics/M_exitAlertCl.png"
    25. anchors.centerIn: parent
    26. }
    27. //LetMeOut Icon .....
    28. Rectangle{
    29. width: letMeOutImage.width;height: letMeOutImage
    30. id:letMeOutId
    31. color: "transparent"
    32. x:exitIcon.width-259
    33. y:exitIcon.height+90
    34.  
    35.  
    36. Image {
    37. id: letMeOutImage
    38. source: "pics/M_letUpCl.png"
    39. }
    40. MouseArea{id:letMeOutArea
    41. anchors.fill:letMeOutImage
    42. onClicked: {
    43. letMeOutImage.source="pics/M_letDownCl.png"
    44. loadFirstPage.source="Mainpage.qml"
    45. keepPlaying.opacity=0
    46.  
    47. }
    48. }
    49. Loader{id:loadFirstPage
    50. y:-280
    51. x:-exitAlert.width+285
    52. }
    53. }
    54. //LetMeOut Icon ends.....
    55.  
    56. //////////////////////////////////////////////////////////////
    57.  
    58. //KeepPlaying starts...../**
    59. Rectangle{
    60.  
    61. id:keepPlaying
    62. width:keepPlayIcon.width;height: keepPlayIcon.height
    63. color: "transparent"
    64. x:letMeOutId.x+135
    65. y:letMeOutId.y
    66.  
    67. MouseArea{
    68. id:keepPlayArea
    69. anchors.fill: parent
    70. onPressed: { keepPlayIcon.source="pics/M_keepDownCl.png"}
    71. onClicked: {
    72. exitItem.opacity=0
    73. }
    74. }
    75. Image {
    76. id: keepPlayIcon
    77. source: "pics/M_keepUpCl.png"
    78.  
    79. }
    80.  
    81.  
    82. }
    83.  
    84.  
    85. }
    86. //exitAlert closed....
    87. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. Mainmenu
    2.  
    3. //mainMenu in gamescreen
    4. Rectangle{id:mainMenu
    5. anchors.bottom: playGround1.bottom
    6. width: gameCanvas.width/4;height: gameCanvas.height/8
    7. color: "transparent"
    8. MouseArea{id:menuArea
    9. anchors.fill: mainMenuImage
    10. onClicked: {
    11. loadletmeout.source="LetMeOut.qml"}
    12.  
    13. }
    14. Image {
    15. id: mainMenuImage
    16. source: "pics/M_mainMenuUp.png"
    17. anchors.centerIn: parent
    18. width: parent.width;height: parent.height
    19. }
    20.  
    21. Loader {
    22. id: loadletmeout
    23. focus: true
    24. }
    25.  
    26.  
    27. }
    28.  
    29. //mainMenu ends
    30.  
    31. }
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: 4 in a row

    Qt Code:
    1. Rectangle{id:mainMenu
    2. anchors.bottom: playGround1.bottom
    3. width: gameCanvas.width/4;height: gameCanvas.height/8
    4. color: "transparent"
    5.  
    6. Timer {
    7. interval: 500; running: menuArea.pressed ; repeat: true
    8. onTriggered: loadletmeout.source="LetMeOut.qml"
    9. //triggeredOnStart: true
    10. }
    11. Image {
    12. id: mainMenuImage
    13. source: "pics/M_mainMenuUp.png"
    14. anchors.centerIn: parent
    15. width: parent.width;height: parent.height
    16. }
    17. MouseArea{id:menuArea
    18. anchors.fill: parent
    19. onPressed: {loadletmeout.source="LetMeOut.qml"}
    20. }
    21.  
    22.  
    23.  
    24. Loader {
    25. id: loadletmeout
    26. focus: true
    27. }
    28.  
    29.  
    30. }
    To copy to clipboard, switch view to plain text mode 


    Even if i added Timer Menuarea button doesn't work after one click. Is there any problem in the code? what can I do ?

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

    Default Re: 4 in a row

    hai wysota, how can we change the opacity of the win balls from the core.js(in your code). i want to set a state instead of opacity . i did it but the problem is that the rest of the balls state change instead of the win balls. i want to change the first ball's state to state "blue" and second ball to "black". how can i do it? any help would be great.
    thanx in advance.

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

    Default Re: 4 in a row

    hai this i have a problem in the javascript.
    the horizontal position not changes its state when it wins(bottom row works fine, no other rows most of the times donot change its state when it wins). all diagonal and vertical position works well.can you help me i this?(if we command the "diagonall" code all the horizontal win row change its state)

    Qt Code:
    1. function checkWin(col, row) {
    2. ply = ply == 0 ? 1 : 0
    3. var connected = 1
    4. var connected1 = 1
    5.  
    6. var curCol = col
    7. var type = board[index(col,row)].type
    8. var connArr = new Array()
    9. connArr.push(board[index(col,row)])
    10.  
    11. var ind;
    12. // go left
    13. for(var i = col-1; i>=0; i--) {
    14. ind = index(i,row)
    15. if(board[ind]==null) break;
    16. if(board[ind].type != type)
    17. break;
    18. connArr.push(board[ind])
    19. // console.log(board.toString());
    20. connected++;
    21. connected1++;
    22.  
    23. }
    24. for(var i = col+1; i<=7; i++) {
    25. ind = index(i,row)
    26. if(board[ind]==null) break;
    27. if(board[ind].type != type)
    28. break;
    29. connArr.push(board[ind])
    30. connected++;
    31. connected1++;
    32.  
    33. }
    34. if(connected<4) {
    35. connArr = []
    36. connArr.push(board[index(col,row)])
    37. connected = 1
    38. connected = 1
    39.  
    40. }
    41. // go up
    42. for(var i = row-1; i>=0; i--) {
    43. ind = index(col,i)
    44. if(board[ind]==null) break;
    45. if(board[ind].type != type)
    46. break;
    47. connArr.push(board[ind])
    48. connected++;
    49. connected1++;
    50.  
    51. }
    52.  
    53. for(var i = row+1; i<=6; i++) {
    54. ind = index(col,i)
    55. if(board[ind]==null) break;
    56. if(board[ind].type != type)
    57. break;
    58. connArr.push( board[ind])
    59. connected++;
    60. connected1++;
    61.  
    62. }
    63. if(connected<4) {
    64. connArr = []
    65. connArr.push(board[index(col,row)])
    66. connected = 1
    67.  
    68. }
    69. // go left-up
    70. for(var i = 1; col-i>=0 && row-i>=0; i++) {
    71. ind = index(col-i,row-i)
    72. if(board[index(col-i,row-i)]==null) break;
    73. if(board[index(col-i,row-i)].type != type)
    74. break;
    75. connArr.push( board[ind])
    76. connected++;
    77. }
    78.  
    79. for(var i = 1; col+i<=5 && row+i<=5; i++) {
    80. ind = index(col+i,row+i)
    81. if(board[index(col+i,row+i)]==null) break;
    82. if(board[index(col+i,row+i)].type != type)
    83. break;
    84. connArr.push( board[ind])
    85. connected++;
    86. }
    87. if(connected<4) {
    88. connArr = []
    89. connArr.push(board[index(col,row)])
    90. connected = 1
    91. }
    92. // go right-up
    93. for(var i = 1; col+i<=6 && row-i>=0; i++) {
    94. ind = index(col+i,row-i)
    95. if(board[index(col+i,row-i)]==null) break;
    96. if(board[index(col+i,row-i)].type != type)
    97. break;
    98. connArr.push( board[ind])
    99. connected++;
    100. }
    101. for(var i = 1; col-i>=0 && row+i<=5; i++) {
    102. ind = index(col-i,row+i)
    103. if(board[index(col-i,row+i)]==null) break;
    104. if(board[index(col-i,row+i)].type != type)
    105. break;
    106. connArr.push( board[ind])
    107. connected++;
    108. }
    109.  
    110. for(var u=0;u<=42;u++)
    111. {
    112. if(connArr.length==4 && ply==0)
    113. {
    114. connArr[u].state="red"
    115. mainMenu.opacity=0;
    116. playAgain.opacity=1;
    117. help.opacity=0;
    118. quit.opacity=1;
    119. gameFinished1();
    120. scoreBoard.scorer();
    121.  
    122. }
    123. else if(connArr.length==4 && ply!=0)
    124. {
    125. connArr[u].state="black"
    126. mainMenu.opacity=0;
    127. playAgain.opacity=1;
    128. help.opacity=0;
    129. quit.opacity=1;
    130. gameFinished();
    131. scoreBoard.scoreb();
    132.  
    133. }
    134. }
    To copy to clipboard, switch view to plain text mode 

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.