11 Replies Latest reply on Nov 27, 2006 9:03 AM by vevelynn

    Pong game

    Lakerol
      I am making a pong kind of game... (you have to catch the ball with a paddle and it bounces back to the top and over again...)
      I'm having trouble programming the paddle to not go out of the playfield...
      I have added this "sprite(me.spriteNum).locH = _mouse.mouseH" so that it follows your mouse, but you can drag it horizontally like endlessly...
        • 1. Re: Pong game
          Level 7
          Put something like this on your paddle sprite:

          on enterFrame me
          sprite(me.spriteNum).locH = _mouse.mouseH

          --left edge
          if sprite(me.spriteNum).locH<(the stage).sourceRect[1]-the stageLeft then
          sprite(me.spriteNum).locH=0
          end if

          --right edge
          if sprite(me.spriteNum).locH>(the stage).sourceRect[3]-the stageLeft then
          sprite(me.spriteNum).locH=(the stage).sourceRect[3]-the stageLeft
          end if
          end

          You will probably need to dd or subtract a few pixels from one or both
          of these tests depending on where the registration point is of the
          sprite you are using. It works well if the reg point is in the center.
          If it is not in the center, then you will need to edit it a bit.
          • 2. Re: Pong game
            Lakerol Level 1
            Thank you Mike
            Does anybody have any experience with this kind of game?
            • 3. Re: Pong game
              Level 7
              With pong? Yeah. I had a pong console back in the early 80s. Before
              you young whippersnappers with your Atari 2600s and your new-fangled
              cartridges and "color" games. My machine played Pong, and that's all it
              played. And that's all I played for hours on end. And I enjoyed it!
              • 4. Re: Pong game
                Lakerol Level 1
                But you haven't made anything like it with Director?
                • 5. Re: Pong game
                  Level 7
                  It wouldn't be too hard, but I haven't seen too much of a need for it.
                  The employers haven't exactly been breaking down my door for
                  pong-related gaming experiences. Though I really dug Arkanoid back in
                  the day...
                  • 6. Re: Pong game
                    Lakerol Level 1
                    :-) Good point...
                    Thanks anyway
                    • 7. Re: Pong game
                      Level 7
                      >>I have added this "sprite(me.spriteNum).locH = _mouse.mouseH" so that it
                      >>follows your mouse, but you can drag it horizontally like endlessly...

                      You can add a test to see if the mouse is on stage:

                      if _mouse.mouseH > 0 and mouse.mouseH < 800 then
                      sprite(me.spriteNum).locH = _mouse.mouseH
                      end if

                      Also, there's a tutorial on making a 3D version of pong in 'Director 8.5
                      Shockwave Studio: The Complete Reference'


                      --
                      Dave -
                      Head Developer
                      www.blurredistinction.com
                      Adobe Community Expert
                      http://www.adobe.com/communities/experts/


                      • 8. Re: Pong game
                        vevelynn
                        I'm also making a pong game for school.
                        But I'm a fresh lingo starter so I'm habing some troubles.
                        For now I have a Paddle and a bouncing ball.
                        but the refuses tou bounce on th paddle.
                        And I really don't know how to say that the ball may not fall under the paddle.

                        (sry for my crappy english)
                        Please can somebody help me?
                        • 9. Re: Pong game
                          Lakerol Level 1
                          KHM? :-D
                          • 10. Re: Pong game
                            vevelynn Level 1
                            indeed
                            • 11. Re: Pong game
                              vevelynn Level 1
                              I'm also making a pong game for school.
                              But I'm a fresh lingo starter so I'm having some troubles.
                              For now I have a Paddle and a bouncing ball.
                              but the refuses tou bounce on th paddle.
                              And I really don't know how to say that the ball may not fall under the paddle.

                              (sry for my crappy english)
                              Please can somebody help me?