Hello good day everyone!
I have a problem with this game I found in the internet. I want to makethis game a little bit better by adding some features.
So my problem is when im changing the value of the delay to "3" it wont change.
Because the lower the delay value, the faster the ball go in the game. So I want it to change when the totalBricks <= 25.
This is the code.
public class Gameplay extends JPanel implements KeyListener, ActionListener{ private boolean play = false; private int score = 0; public int totalBricks = 30; public Timer timer; public int delay = 7; private int playerX = 310; private int ballposX = 120; private int ballposY = 350; private int ballXdir = -1; private int ballYdir = -2; private Maps map; public Gameplay() { map = new Maps(3, 10); addKeyListener(this); setFocusable(true); setFocusTraversalKeysEnabled(false); timer = new Timer(delay, this); timer.start(); if(totalBricks <= 25){ delay = 3; } }
As you can see, in the public gameplay section. I wrote "if(totalBricks <= 25){ delay = 3; }.
But still its not working.
If you have any other questions, please do not hesitate to ask me.
Thanks advance and God Bless!!!!!