Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. [Moved] Duck hunt game
Forum Updated to NodeBB v4.3 + New Features

[Moved] Duck hunt game

Scheduled Pinned Locked Moved Game Development
15 Posts 7 Posters 6.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vinb
    wrote on last edited by
    #3

    This post is not really readable.
    Mayby you can change the question in a normal question instead of screaming and demanding?
    After that, please wrap your code in "@" tags so people can read it.
    This way you dont have to expect a lot of help.

    @secretNinja:
    when i wrote my post, i didnt saw yours yet. :)

    1 Reply Last reply
    0
    • A Offline
      A Offline
      audrensitas
      wrote on last edited by
      #4

      I updated my post.. Sorry for my demands and screamings, this project just getting me to death... I must to do it, but teacher doesn't explain how to.... All the stuff i have to do myself.. So forums is my last hope..

      1 Reply Last reply
      0
      • U Offline
        U Offline
        ucomesdag
        wrote on last edited by
        #5

        Maybe changing the title, removing the screaming caps and the asap, might help!?
        I only replied because I got big time annoyed by the title and didn't bother reading your post.

        Write “Qt”, not “QT” (QuickTime).

        1 Reply Last reply
        0
        • A Offline
          A Offline
          audrensitas
          wrote on last edited by
          #6

          is it ok now

          1 Reply Last reply
          0
          • S Offline
            S Offline
            secretNinja
            wrote on last edited by
            #7

            Actually, it's almost perfect :)

            1 Reply Last reply
            0
            • U Offline
              U Offline
              ucomesdag
              wrote on last edited by
              #8

              [quote author="audrensitas" date="1303734384"]is it ok now[/quote]Aaah that's much better...

              Maybe having a look at "DoodleDrive":https://projects.forum.nokia.com/doodledrive might give you some inspiration.

              Write “Qt”, not “QT” (QuickTime).

              1 Reply Last reply
              0
              • V Offline
                V Offline
                vinb
                wrote on last edited by
                #9

                Reads much better now!

                Is there a special reason that you use a QPushButton for the display of a picture? Mayby you can use a "pixmap":http://doc.qt.nokia.com/4.7/qpixmap.html ?
                As for the "moving" , i suggest that u use a "timer":http://doc.qt.nokia.com/4.7/qtimer.html or even a "timeline":http://doc.qt.nokia.com/4.7/qtimeline.html combined with the setgeometrie() function of the widget u use.

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  audrensitas
                  wrote on last edited by
                  #10

                  I use QPushButton in order that when there will be on game, when duck will be flying on X axis, when clicked on it, it should go down in a state - dead. That is why I use QPushButton.

                  1 Reply Last reply
                  0
                  • V Offline
                    V Offline
                    vinb
                    wrote on last edited by
                    #11

                    So if i "tab" to the button i can kill the duck with my eyes closed?
                    Mayby u can use a mouseclick or touch event on the coordinates of the duck widget?

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      audrensitas
                      wrote on last edited by
                      #12

                      Hi all,

                      I am trying to create Duck Hunt game in qt creator.
                      There is my code to create duck in constructor:
                      @ QMovie *movie = new QMovie(":/Antis/paveiksl/duck1111.gif");
                      l = new QLabel(this);
                      l->setMovie(movie);
                      movie->start();
                      l->setGeometry(-5,0,55,39);
                      l->show();
                      xas = 1;
                      yas = rand()$0; // DUCK IS RANDOM POSITION GENERATED ON Y AXIS.
                      @

                      • First of all, is there a possibility to set duck start position in X axis in -5 coordinate, so that when the game start the duck would fly from the corner or from the left part of my background, it wouldn't be seen when the game just starts. Is there a possibility to set this with setGeometry or do i need to use some other function?
                      • Secondly, can someone advice how to create dynamic array or dynamic slot to create ducks. I don't need one duck, i need many ducks that would be flying in the screen after more time have passed.
                      • Moreover is it also a possibility to set delay after random duck creation that one duck is flying, then after few seconds more ducks start flying?

                      I am using QTimer for movement of the duck
                      @ QTimer *t = new QTimer(this);
                      connect(t,SIGNAL(timeout()),this,SLOT(Metodas()));
                      t->setInterval(1/30);
                      t->start(50); @

                      @void CFrameWnd::Metodas()
                      {
                      xas +=1;
                      l->move(xas,yas);
                      }@

                      However, what is the best idea to do when the duck reaches X axis end or end of the screen? To stop qtimer or to quit application with results or ?...
                      And finally, can someone advice for the duck killing? Do i have to create a pushbutton, that will be connected with the duck object and when clicked the duck would change to 'dead' position and will be moving to a certain coordinate down Y axis and then disappear .

                      Any advices are appreciated.
                      Thanks in advance.

                      1 Reply Last reply
                      0
                      • T Offline
                        T Offline
                        tobias.hunger
                        wrote on last edited by
                        #13

                        Merged yet another duck hunt thread with one of the existing.

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          andre
                          wrote on last edited by
                          #14

                          /me feels sorry for those poor ducks...

                          [quote author="audrensitas" date="1304401454"]

                          • First of all, is there a possibility to set duck start position in X axis in -5 coordinate, so that when the game start the duck would fly from the corner or from the left part of my background, it wouldn't be seen when the game just starts. Is there a possibility to set this with setGeometry or do i need to use some other function?[/quote]

                          Sure. Doesn't your current method work properly?
                          [quote]

                          • Secondly, can someone advice how to create dynamic array or dynamic slot to create ducks. I don't need one duck, i need many ducks that would be flying in the screen after more time have passed.
                            [/quote]
                            You are asking two very different things. Look into Qt's container classes to store your duck objects. Don't even think of trying to create "dynamic slots" or something like that. Re-think your design instead. Just create an class that manages a single duck (you might want to call that class Duck), and create multiple Duck objects. You can give this Duck class slots and signals if you need, and those would only be related to that single Duck object. I would also make this object responsible for animating itself from left to right.

                          [quote]

                          • Moreover is it also a possibility to set delay after random duck creation that one duck is flying, then after few seconds more ducks start flying?
                            [/quote]
                            Sure. You are already using random in your code. Why not apply the same idea to a QTimer object who's interval you change at every trigger and that you have create your new Duck objects?
                            [quote]
                            However, what is the best idea to do when the duck reaches X axis end or end of the screen? To stop qtimer or to quit application with results or ?...
                            [/quote]
                            What do your requirements say you need to do? How should we know? The fact that you need to be able to show multiple ducks, tells me that you probably should not quit the application. After your duck moves off-screen, you probably can destroy the Duck object and increase some counter for the number of missed ducks, or something like that.
                            [quote]
                            And finally, can someone advice for the duck killing? Do i have to create a pushbutton, that will be connected with the duck object and when clicked the duck would change to 'dead' position and will be moving to a certain coordinate down Y axis and then disappear .
                            [/quote]
                            That would depend on how you plan to actually make the hunting work. You did not tell us about that.
                          1 Reply Last reply
                          0
                          • R Offline
                            R Offline
                            rachol
                            wrote on last edited by
                            #15

                            QGraphicsView is something I would use for creating such game.

                            You can reimplement QGraphicsItem, so you get a DuckItem, where you can implement all the logic for moving a duck. You will get QMouseEvents directly to your item, so killing a duck is just a proper handling of events sent to your class.

                            Qt Certified Specialist in Widget UI and Core C++

                            1 Reply Last reply
                            0

                            • Login

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Groups
                            • Search
                            • Get Qt Extensions
                            • Unsolved