virtual pong

Download Virtual Pong

If you can't read please download the document

Upload: intoshblef

Post on 18-Jan-2016

8 views

Category:

Documents


0 download

DESCRIPTION

Easy Java Program source code

TRANSCRIPT

import java.awt.Color;import java.awt.Graphics;import java.awt.Rectangle;public class AIPaddle {int x;//Horizontalint y;//Verticalint width = 15;int heigth = 40;int speed = 4;boolean isTwoPlayer = false;Rectangle boundingBox;boolean goingUp = false;boolean goingDown = false;public AIPaddle(int x, int y){this.x = x;this.y = y;boundingBox = new Rectangle( x, y, width, heigth);boundingBox.setBounds( x, y, width, heigth);}public void tick(Game game){boundingBox.setBounds( x, y, width, heigth);if (!isTwoPlayer){if(Game.ball.y < y && y >= 0){y -= speed;}else if(Game.ball.y > y&& y + heigth = 0){y -= speed;}else if (goingDown && y+heigth y){y += speed;}*//* if (!isTwoPlayer){if(game.ball.y < y && y >= 0){y -= speed;}else if(game.ball.y > y&& y + heigth right neg