Results 1 to 3 of 3
  1. #1
    cvt is offline Member
    Join Date
    Oct 2012
    Rep Power

    Exclamation Need help with this whole thing :(

    Need help with this whole thing :(
    theres some images and other files that could help but i cant upload them :(

    Pong is one of the first computer games, created back in 1972. We are making a customised version of
    Pong, with game-play that is not exactly the same as the original. You are expected to make your
    implementation of Pong look and behave almost exactly like what is described here. You are free to
    define your own parameters for things like colours, fonts, the size and shape of the paddles, and the size
    of the ball. Note that the window should not be resizable!
    Below is the initial state of our version of Pong. You can see how the high scores from assignment 1 are
    incorporated into the overall program. When the program is first executed, any previously saved high
    scores are loaded from a data file. When the program window is closed, the current list of high scores
    overwrites the high scores in the data file.
    If the “start match” button is pressed before the player names are entered, then we should see a modal
    popup that indicates user error, something like:
    But your version of this popup is expected to make this popup indicate which player name(s) need to be
    entered. The player names should be non-empty strings of letters only. Putting a single space between
    letters is acceptable. The maximum length of a player name is 20 characters.

    Once the player names are entered and the “start match” button is pressed, then the player names cannot
    be changed again until the “end match” button is pressed (i.e. the name fields are disabled). Notice also
    that the “start match” button becomes disabled until the “end match” button is pressed:
    Game-play is controlled by keyboard interaction. You program should implement keyboard event
    handling via KeyEvents. The game-play is as follows:
    • Pressing the space-bar starts the ball moving, it is placed in the centre of the window with a
    randomly chosen speed and direction
    • The left-side paddle can be controlled by pressing ‘q’ for moving up and ‘a’ for moving down
    • The right-side paddle can be controlled by pressing ‘p’ for moving up and ‘l’ for moving down
    • The paddles can be moved regardless of whether or not the ball is moving (while a match is
    Smooth paddle motion can be achieved by implementing a “state machine” (to be discussed in lectures).
    Other requirements on game-play are as follows:
    • The ball speed is independent in both axes
    • When the ball hits the top or bottom edge of the window, the ball’s direction is adjusted
    appropriately so that the ball remains completely within the bounds of the window and appears to
    “bounce” off the edge of the window
    • If the ball reaches the left or right edge then it stops and the appropriate player’s score is
    incremented by one
    • If the ball hits a paddle, then the ball “bounces” off that paddle such that the horizontal direction
    reverses and the ball’s speed is randomly changed
    Game-play should be implemented using background threading and synchronization:
    • Frame-animation should be controlled by a background Thread or Timer object that forces the
    display to refresh and update the position of the ball
    • Since the user can also force the paddles to move independently of the frame-animation, you
    should use the synchronized keyword where appropriate

    When the “end match” button is pressed, the player with the higher score has their score updated in the
    high scores table – as defined by the behaviour coded in Assignment 1. Notice that the high scores are
    now sorted into descending order of value. Also notice that the “start match” button and the player name
    fields become enabled, and the “end match” button becomes disabled, and that the Scores are reset to
    zero, but the player names are not cleared:
    There are a number of other characteristics that you must incorporate into your program:
    • Create a “test” package and a “software” package and use them appropriately
    • Incorporate the source code for the Score class and HighScores class into your NetBeans project
    • Adjust the Score class and HighScores class so that the methods don’t return true/false values,
    but rather they generate ScoreException objects and HighScoreException objects (which you
    need to write classes for)
    • The visual shapes (Ball, Paddle, ScoreDisplay, …) should be derived types of Shape
    o The Shape class
     Must be an abstract class
     It records speed, width, height, 2D position, and direction information
     It defines an abstract method called draw(Graphics)
    o You should adapt the code for Ball code from Assignment 1 for this purpose
    • The game-play must be controlled by a Field object (a modified version of Assignment 1 code)
    o The Field has a fixed size of width = 600 and height = 400
    o The Field implements a frame-by-frame animation for game-play and displays updates
    o The Field reacts to user input from the keyboard (i.e. KeyEvents)
    • Adjust the Score class so that it uses the Comparable interface – this will allow you to easily
    sort the scores in the high scores table
    • The Shape class can throw ShapeException objects:
    o The speed value can only be in the range 0 – 10
    o The range of widths of shapes can only be 3 – 200
    o The range of heights of shapes can only be 3 – 200
    • Note: Your exception classes should be derived from RuntimeException only
    • Add appropriate tests for classes (e.g. Shape, Ball, etc.) if you think it is valuable
    • The Pong class is the main class for the program – use it to setup the JFrame and the Field
    o Pong’s main() method must contain local variables for the JFrame and the Field objects

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power

    Default Re: Need help with this whole thing :(

    Quote Originally Posted by cvt View Post
    Need help with this whole thing :(
    My experience with this forum (and all Java forums that I'm acquainted with) is that we aren't well equipped to handle this type of question and that often your best served to try to make time with your instructor or a tutor for intense face-to-face instruction.

    In the mean time, do try to divide up your project into small bites and try to solve each bite one at a time and in isolation, and if you run into a specific problem, then post your code and ask your question here and we'll more than likely be much better able to help you.


  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

    Default Re: Need help with this whole thing :(

    1. Moved from Advanced Java. There's nothing 'advanced' about a homework dump.

    2. Please find and go through the Forum Rules, particularly the third paragraph.

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. about static thing
    By ryozkidz in forum New To Java
    Replies: 8
    Last Post: 07-08-2011, 07:44 PM
  2. JTable whole thing changes
    By MarkusHendersonicus in forum New To Java
    Replies: 3
    Last Post: 01-12-2011, 04:09 PM
  3. the variable thing
    By fleg in forum New To Java
    Replies: 8
    Last Post: 11-02-2010, 03:54 PM
  4. Trying to understand the whole 2D thing.
    By xael in forum Java 2D
    Replies: 4
    Last Post: 10-06-2010, 01:41 AM
  5. PLz i really need help on this final thing
    By jason27131 in forum New To Java
    Replies: 2
    Last Post: 08-03-2007, 02:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts