Noob Questions From Nickropheliac : My Stupid Interval Bug

Sorry for flood this forum so often, but I always need help so I can apply my new knowledge to my games in the future. What I’m trying to do, is increase the ballDeltaX, ballDeltaY, and paddleSpeed every rallyInterval. When I run this it will only do this once. I tried running it in a loop, but my effort was futile. Please help, JGO

p.s Sorry for posting 50 times a day.


		import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.image.BufferStrategy;
import java.util.Random;

import javax.swing.JPanel;
import javax.swing.Timer;

public class PongPanel extends JPanel implements ActionListener, KeyListener {
	private Game game;

	private boolean running = true;

	private boolean upPressed = false;
	private boolean downPressed = false;
	private boolean wPressed = false;
	private boolean sPressed = false;

	private int ballX = 400;
	private int ballY = 200;
	private int diameter = 20;
	private int ballDeltaX = -5;
	private int ballDeltaY = 5;

	private int playerOneX = 25;
	private int playerOneY = 220;
	private int playerOneWidth = 20;
	private int playerOneHeight = 60;

	private int playerTwoX = 750;
	private int playerTwoY = 220;
	private int playerTwoWidth = 20;
	private int playerTwoHeight = 60;

	private int paddleSpeed = 10;

	Random random = new Random();
	private final float hue = random.nextFloat();
	private final float saturation = 0.9f; 
	 private float luminance = 1.0f; 

	
	private int deaths;
	private int rallyScore = 0;
	private int rallyInterval = rallyScore & 5;

	private long currentTime = System.currentTimeMillis();
	public static Thread thread;

	private int[] Colors = new int[getWidth() * getHeight()];

	public PongPanel() {
		Random rand = new Random();
		setBackground(new Color(rand.nextInt(0xFF4AF6)));

		setFocusable(true);
		addKeyListener(this);

		Timer timer = new Timer(1000 / 60, this);
		timer.start();
	}

	public void actionPerformed(ActionEvent e) {
		step();
	}

	public void step() {

		if (upPressed) {
			if (playerTwoY - paddleSpeed > 0) {
				playerTwoY -= paddleSpeed;
			}
		}
		if (downPressed) {
			if (playerTwoY + paddleSpeed + playerTwoHeight < getHeight()) {
				playerTwoY += paddleSpeed;
			}
		}

		if (wPressed) {
			if (playerOneY - paddleSpeed > 0) {
				playerOneY -= paddleSpeed;
			}
		}
		if (sPressed) {
			if (playerOneY + paddleSpeed + playerOneHeight < getHeight()) {
				playerOneY += paddleSpeed;
			}
		}

		int nextBallLeft = ballX + ballDeltaX;
		int nextBallRight = ballX + diameter + ballDeltaX;
		int nextBallTop = ballY + ballDeltaY;
		int nextBallBottom = ballY + diameter + ballDeltaY;

		int playerOneRight = playerOneX + playerOneWidth;
		int playerOneTop = playerOneY;
		int playerOneBottom = playerOneY + playerOneHeight;

		float playerTwoLeft = playerTwoX;
		float playerTwoTop = playerTwoY;
		float playerTwoBottom = playerTwoY + playerTwoHeight;

		if (nextBallTop < 0 || nextBallBottom > getHeight()) {
			ballDeltaY *= -1;
	
		}

		if (nextBallLeft < playerOneRight) {

			if (nextBallTop > playerOneBottom || nextBallBottom < playerOneTop) {

				System.out.println("You died. Your rally was " + rallyScore + ".");
				deaths++;
				ballX = 400;
				ballY = 200;
			} else {
				rallyScore++; 
				ballDeltaX *= -1;
			   rallyInterval++; 
			}
		}

		if (nextBallRight > playerTwoLeft) {

			if (nextBallTop > playerTwoBottom || nextBallBottom < playerTwoTop) {

				System.out.println("You died. Your rally was " + rallyScore + ".");

				deaths++;

				ballX = 400;
				ballY = 200;
			} else {
				rallyScore++;
				ballDeltaX *= -1;
			    rallyInterval++;
			}
		}

		ballX += ballDeltaX;
		ballY += ballDeltaY;
		
		if ( rallyInterval == 5){
			ballDeltaX = ballDeltaX -2; 
			ballDeltaY = ballDeltaY +2; 
			paddleSpeed = paddleSpeed + 2 ;
		}
		
		repaint();
	}

	public synchronized void Score() {

	}

	public void RandomColor() {

	}

	public void paintComponent(Graphics g) {

		super.paintComponent(g);
		Random rand = new Random();
	
		for (int lineY = 0; lineY < getHeight(); lineY += 50) {
			g.setColor(new Color(rand.nextInt(0xFF4AF6)));
			g.fillRoundRect(400, lineY, 20, 800, 0, 0);
		}

		g.setColor(Color.WHITE);
		g.fillRoundRect(ballX, ballY, 25, 25, 5, 25);
	for (int tick = 0; tick > getHeight(); tick--){
	
            g.setColor(new Color (rand.nextInt(0xFF4AF6)));
	}
	g.setColor(new Color(rand.nextInt(0xFF4AF6)));
	g.fillRoundRect(playerOneX, playerOneY, playerOneWidth,
					playerOneHeight, 50, 5);

			g.fillRoundRect(playerTwoX, playerTwoY, playerTwoWidth,
					playerTwoHeight, 50, 5);
	
			g.setColor(Color.WHITE);
			g.fillRoundRect(335, 180, 150, 150 , 50, 50);
			  g.setFont(new Font(Font.DIALOG, Font.BOLD, 150));
		      String rally = " " + rallyScore;
			  g.setColor(new Color (0xFF2172));
		      g.drawString(rally, 328, 310);
			  g.dispose();	
	}

	

	public void keyTyped(KeyEvent e) {
	}

	public void keyPressed(KeyEvent e) {
		if (e.getKeyCode() == KeyEvent.VK_UP) {
			upPressed = true;
		} else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
			downPressed = true;
		} else if (e.getKeyCode() == KeyEvent.VK_W) {
			wPressed = true;
		} else if (e.getKeyCode() == KeyEvent.VK_S) {
			sPressed = true;
		}
	}

	public void keyReleased(KeyEvent e) {
		if (e.getKeyCode() == KeyEvent.VK_UP) {
			upPressed = false;
		} else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
			downPressed = false;
		} else if (e.getKeyCode() == KeyEvent.VK_W) {
			wPressed = false;
		} else if (e.getKeyCode() == KeyEvent.VK_S) {
			sPressed = false;
		}
	}

;