Results 1 to 1 of 1

Thread: game slows down when I click on maximize window

  1. #1
    Join Date
    Sep 2013
    Posts
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Question game slows down when I click on maximize window

    hello;
    When I click on maximize window my app slows down becose of large workspace(1080x1900);
    help me to solve this problem;
    my gameloop is correct or no? thanks;
    ubuntu 12.04 KDE4 Qt5.1
    Qt Code:
    1. ###########main.qml##############
    2. import QtQuick 2.0
    3. Rectangle {
    4. width: 360
    5. height: 360
    6. focus: true
    7. Tank{id: myTank; objectName: "myTank"; x: 100; y: 100}
    8. Timer {
    9. running: true
    10. repeat: true
    11. interval: 16
    12. onTriggered: {
    13. myTank.move();
    14. }
    15. }
    16. Keys.onUpPressed: { myTank.moveUp = true}
    17. Keys.onDownPressed: { myTank.moveDown = true }
    18. Keys.onLeftPressed: { myTank.rotateLeft = true }
    19. Keys.onRightPressed: { myTank.rotateRight = true }
    20. Keys.onReleased: {
    21. switch(event.key) {
    22. case Qt.Key_Up:
    23. myTank.moveUp = false
    24. break
    25. case Qt.Key_Down:
    26. myTank.moveDown = false
    27. break
    28. case Qt.Key_Left:
    29. myTank.rotateLeft = false
    30. break
    31. case Qt.Key_Right:
    32. myTank.rotateRight = false
    33. }
    34. }
    35. }
    36. ##############Tank.qml##############
    37. import QtQuick 2.0
    38. Item {
    39. width: 30
    40. height: 30
    41. property bool rotateLeft: false
    42. property bool moveUp: false
    43. property bool rotateRight: false
    44. property bool moveDown: false
    45. property double xpos: x
    46. property double ypos: y
    47. property double rspeed: 3
    48. property double speed: 3
    49. rotation: 120
    50. function move() {
    51. if(rotateLeft) rotation -= rspeed
    52. else if(rotateRight) rotation += rspeed
    53. var diffX = speed * Math.sin(rotation * 0.0174532925);
    54. var diffY = speed * Math.cos(rotation * 0.0174532925)
    55. if(moveUp) {
    56. xpos += diffX
    57. ypos -= diffY
    58. } else if(moveDown) {
    59. xpos -= diffX
    60. ypos += diffY
    61. }
    62. x = xpos
    63. y = ypos
    64. }
    65. Image {
    66. anchors.fill: parent
    67. source: "qrc:///Battle_City_Tank_Player1.png"
    68. }
    69. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by qwe522y; 22nd September 2013 at 14:58.

Similar Threads

  1. How to maximize window to full screen ?
    By vsthakur1 in forum Newbie
    Replies: 4
    Last Post: 11th December 2012, 12:54
  2. Maximize Window in Background
    By qtoptus in forum Qt Programming
    Replies: 2
    Last Post: 16th March 2012, 14:28
  3. maximize grid with maximize window
    By bibhukalyana in forum Qt Programming
    Replies: 2
    Last Post: 19th May 2011, 08:16
  4. Maximize Window button of Manin Window
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 1st August 2007, 08:20
  5. Maximize Window Signal
    By ToddAtWSU in forum Qt Programming
    Replies: 9
    Last Post: 8th May 2006, 20:05

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.