
-----------------------------------
ify
Sun Jun 20, 2004 5:56 pm

EARTH QUAKE PONG
-----------------------------------
i know that you all were amazed by my programming skills in my pong game and in my drunk  walking in snow simulator but i have made a new game EARTHQUAKE PONG!!! (note i used "ready to program" to make it and if u had trouble with my pong game working then this one wont work sory :( , if u wanna realy know it just makes the paddles shakey and the ball is wacky its the same a pong only shakey.)









// The "EARTHQUAKEPONG" class.
import java.awt.*;
import javax.swing.*;

public class EARTHQUAKEPONG extends Frame
{

    // declaiations of variables
    int ballX = 200;
    int ballY = 330;
    int xTwenty = 20;
    int yFive = 7;
    int playerY = 200;
    int computerY = 200;
    int playerScore = 0;
    int computerScore = 0;
    int x2 = 0;
    int y2 = 0;

    Image offScreenImage;
    Graphics offScreenBuffer;



    MenuItem newOption, exitOption, helpOption, aboutOption;



    public EARTHQUAKEPONG ()
    {
        super ("EARTHQUAKE PONG");  // Set the frame's name
        setResizable (false);
        setSize (600, 400);     // Set the frame's size
        setLocation (360, 25);

        setBackground (Color.black);

        newOption = new MenuItem ("New");
        exitOption = new MenuItem ("Exit");
        helpOption = new MenuItem ("Help");
        aboutOption = new MenuItem ("Info");

        Menu gameMenu = new Menu ("Game");
        Menu gameMenuTwo = new Menu ("Help");

        gameMenu.add (newOption);
        gameMenu.addSeparator ();
        gameMenu.add (exitOption);

        gameMenuTwo.add (helpOption);
        gameMenuTwo.addSeparator ();
        gameMenuTwo.add (aboutOption);

        // Set up the Game Menu


        MenuBar mainMenu = new MenuBar ();
        mainMenu.add (gameMenu);
        mainMenu.add (gameMenuTwo);
        // Set the menu bar for this frame to mainMenu
        setMenuBar (mainMenu);

        show ();                // Show the frame
        // Constructor
    }


    public void newGame ()
    {
        ballX = 200;
        ballY = 330;
        playerScore = 0;
        computerScore = 0;

        repaint ();
    }


    public boolean action (Event evt, Object arg)
    {
        if (evt.target == newOption)
        {

            newGame ();
        }
        else if (evt.target == exitOption)
        {
            hide ();
            System.exit (0);
        }
        else if (evt.target == helpOption)
        {
            JOptionPane.showMessageDialog (null, "electronic tennis earthquake stylz to the max", "Help window", JOptionPane.INFORMATION_MESSAGE);
        }
        else if (evt.target == aboutOption)
        {
            JOptionPane.showMessageDialog (null, "programed by: IFY", "About", JOptionPane.INFORMATION_MESSAGE);
        }
        else
            return false;
        return true;
    }


    // handles imput from the mouse
    public boolean mouseMove (Event event, int x, int y)
    {
        if (y >= 30 || y  350)
        {
            yFive = -yFive;

        }

        //this is incase the ball hits a corner and doesnt get stuck in the wall or if the ball hits the pattle





        else if (ballX = 50 && ballY >= playerY & ballY = computerY & ballY  350)
        {
            y2 = 1;

        }
        else if (ballY < 55)
        {
            y2 = 0;
        }


        if (y2 == 0)
        {
            yFive = (int) (Math.random () * 10) + 1;

        }
        else if (y2 == 1)
        {
            yFive = (int) (Math.random () * -10) + 1;

        }

        if (x2 == 0)
        {
            xTwenty = (int) (Math.random () * 10) + 1;
        }
        else if (x2 == 1)
        {
            xTwenty = (int) (Math.random () * -10) + 1;
        }







        if (ballX = 600)
        {
            ballX = 200;
            ballY = 330;
            playerScore++;
            JOptionPane.showMessageDialog (null, playerScore + " / " + computerScore, "Score", JOptionPane.INFORMATION_MESSAGE);
        }
        // drawing the ball
        ballX = ballX + xTwenty;
        ballY = ballY + yFive;
        offScreenBuffer.setColor (Color.white);
        offScreenBuffer.fillRect (ballX, ballY, 10, 10);


        //draws the pattle which is the player&and the computer pattle
        if (pat == 1)
        {
            offScreenBuffer.setColor (Color.LIGHT_GRAY);
            offScreenBuffer.fillRect (53, playerY + 2, 10, 100);
        }
        else if (pat == 2)
        {
            offScreenBuffer.setColor (Color.LIGHT_GRAY);
            offScreenBuffer.fillRect (45, playerY + 4, 10, 100);
        }
        else if (pat == 3)
        {
            offScreenBuffer.setColor (Color.LIGHT_GRAY);
            offScreenBuffer.fillRect (50, playerY, 10, 100);
        }

        if (pat == 1)
        {
            offScreenBuffer.setColor (Color.LIGHT_GRAY);
            offScreenBuffer.fillRect (534, computerY - 5, 10, 100);
        }
        else if (pat == 2)
        {
            offScreenBuffer.setColor (Color.LIGHT_GRAY);
            offScreenBuffer.fillRect (527, computerY + 2, 10, 100);
        }
        else if (pat == 3)
        {
            offScreenBuffer.setColor (Color.LIGHT_GRAY);
            offScreenBuffer.fillRect (530, computerY, 10, 100);
        }
        //repaints the screen so we dont have old images on the screen
        repaint ();

        // Transfer the offScreenBuffer to the screen
        g.drawImage (offScreenImage, 0, 0, this);


        // Place the drawing code here
    } // paint method



    public void update (Graphics g)
    {
        paint (g);
    }


    public void destroy ()
    {
        offScreenBuffer.dispose ();
    }




    public static void main (String[] args)
    {
        new EARTHQUAKEPONG ();     // Create a EARTHQUAKEPONG frame
    } // main method
} // EARTHQUAKEPONG class



-----------------------------------
Jekate
Sat Oct 16, 2004 1:20 pm


-----------------------------------
As I said in my other post, I use ready to program as well. This program does not work either. I'm not sure why.

-----------------------------------
Dan
Sat Oct 16, 2004 1:29 pm


-----------------------------------
Why are you replying to posts that are so out of date? Also the code is fine (if you consider that RTP code could be fine). I am beting you ethere do not have RTP set up right, an out of date verson or you are naming the file wrong....

-----------------------------------
Kenster102.5
Wed Jan 14, 2009 7:24 pm

Re:earth Quake Pong
-----------------------------------
The reason why it doesn't work is because he didn't put 
import hsa.Console;
