Browse Source

update

main
fdai4616 2 years ago
parent
commit
74c71e7246
  1. 19
      src/main/java/PingPong/GamePanel.java
  2. BIN
      target/classes/PingPong/GamePanel$AL.class
  3. BIN
      target/classes/PingPong/GamePanel.class

19
src/main/java/PingPong/GamePanel.java

@ -38,16 +38,32 @@ public class GamePanel extends JPanel implements Runnable {
gameThread.start();
}
public void checkCollision() {
}
public void run() {
long lastTime = System.nanoTime();
double amountOfTicks = 60.0;
double nanoseconds = 1000000000 / amountOfTicks;
double delta = 0;
while (true) {
long now = System.nanoTime();
delta += (now - lastTime) / nanoseconds;
lastTime = now;
if (delta >= 1) {
move();
checkCollision();
repaint();
delta--;
}
}
}
public void draw(Graphics g) {
@ -57,6 +73,7 @@ public class GamePanel extends JPanel implements Runnable {
ball.draw(g);
}
public void move() {
paddle_1.move();

BIN
target/classes/PingPong/GamePanel$AL.class

BIN
target/classes/PingPong/GamePanel.class

Loading…
Cancel
Save