/** * @(#)pong.java * * * @author * @version 1.00 2007/5/2 */import java.applet.*;import java.awt.*;public class pong extends Applet implements Runnable{ int WIDTH, HEIGHT, PADDLESIZE;//Width and height of the applet, and Paddle Size int oneScore, twoScore; public void init(){ WIDTH = getSize().width; HEIGHT = getSize().height; oneScore=0; twoScore=0; } /* // method to handle key - down events public boolean keyDown (Event e, int key){ // user presses left cursor key if (key == Event.UP){ // changing x - speed so that ball moves to the left side (x_speed negative) x_speed = -1; } // user presses right cursor key else if (key == Event.DOWN){ // changing x - speed so that ball moves to the right side (x_speed positive) x_speed = 1; } // user presses space bar (value = 32!) else if (key == 32){ // Stop ball (x_speed = 0) x_speed = 0; }else{ // Additionally the method prints out the ASCII - value if an other key is pressed. This is not necessary but a possibility for you to test which value a key has. System.out.println ("Charakter: " + (char)key + " Integer Value: " + key); } // DON'T FORGET (although it has no meaning here) return true; } */ //Ball Class public class ball{ private int ballX, ballY, ballRadius;//Ball Position private double ballAngle, ballSpeed; //Ball Direction and Speed //Constructor Method public void ball(int getX, int getY,int getSize, double getAngle, double getSpeed){ ballX=getX; ballY=getY; ballRadius=getSize; ballAngle=getAngle; ballSpeed=getSpeed; } //Move Method public void move(){ } //Collison Detection (Recreate new angle, and return if hit) public boolean collide(int pointX, int pointY, boolean changeSpeed){ //Creates the new direction for the ball on collision with the option to change speed or not(Wall/Paddle Collision) return false; } //Point Detection public boolean pointCheck(int getHeight, int Width){ twoScore += (ballX < 0) ? 1:0; oneScore += (ballX > WIDTH) ? 1:0; } } //Paddle Class public class paddle{ private int PADDLEX, paddleY;//X(cons), Y coordinates (centered) private int keyUp,keyDown;// Changeable Keys for Controlling the Paddle. private int PADDLESIZE;//Size(cons)(extending outwards from center) //Constructor Method public void paddle(int getX, int getY, int getUp, int getDown, int getSize){ PADDLEX=getX; paddleY=getY; PADDLESIZE=getSize; keyUp=getUp; keyDown=getDown; } //Move Method (Handles KeyBoard Events) public void move(){ paddleY++; } //Methods to Show Values. public int returnUp(){ return keyUp; } public int returnDown(){ return keyDown; } public int returnX(){ return PADDLEX; } public int returnY(){ return paddleY; } } public void start(){ } public void stop(){ } public void destroy(){ } public void run(){ } public void paint(Graphics g){ }}