We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import javax.swing.; import java.awt.; import java.awt.event.*;
public class BrickBreaker extends JFrame {
private static final int WIDTH = 800; private static final int HEIGHT = 600; private static final int PADDLE_WIDTH = 100; private static final int PADDLE_HEIGHT = 20; private static final int BALL_SIZE = 20; private int paddleX; private int ballX, ballY; private int ballXSpeed = 1, ballYSpeed = -1; public BrickBreaker() { setTitle("Brick Breaker"); setSize(WIDTH, HEIGHT); setResizable(false); setDefaultCloseOperation(EXIT_ON_CLOSE); setVisible(true); addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { int keyCode = e.getKeyCode(); if (keyCode == KeyEvent.VK_LEFT) { paddleX -= 20; } else if (keyCode == KeyEvent.VK_RIGHT) { paddleX += 20; } } }); paddleX = WIDTH / 2 - PADDLE_WIDTH / 2; ballX = WIDTH / 2 - BALL_SIZE / 2; ballY = HEIGHT / 2 - BALL_SIZE / 2; gameLoop(); } private void gameLoop() { while (true) { ballX += ballXSpeed; ballY += ballYSpeed; if (ballX <= 0 || ballX >= WIDTH - BALL_SIZE) { ballXSpeed *= -1; } if (ballY <= 0 || ballY >= HEIGHT - BALL_SIZE) { ballYSpeed *= -1; } if (ballY + BALL_SIZE >= HEIGHT - PADDLE_HEIGHT && ballX + BALL_SIZE >= paddleX && ballX <= paddleX + PADDLE_WIDTH) { ballYSpeed *= -1; } repaint(); try { Thread.sleep(5); } catch (InterruptedException e) { e.printStackTrace(); } } } public void paint(Graphics g) { super.paint(g); g.setColor(Color.BLACK);
The text was updated successfully, but these errors were encountered:
please assign to me #gssoc24
Sorry, something went wrong.
could you please assign this to me
No branches or pull requests
import javax.swing.;
import java.awt.;
import java.awt.event.*;
public class BrickBreaker extends JFrame {
The text was updated successfully, but these errors were encountered: