From 5e5b08b2db1c6257d5979b7cc3ff936ec9c46d3c Mon Sep 17 00:00:00 2001
From: Lenz Wiechers <>
Date: Fri, 14 Feb 2020 23:13:28 +0100
Subject: [PATCH] Uploading project
---
.classpath | 10 +++
.project | 17 ++++++
.settings/org.eclipse.jdt.core.prefs | 14 +++++
bin/Ball.class | Bin 0 -> 1912 bytes
bin/Game.class | Bin 0 -> 1215 bytes
bin/Main.class | Bin 0 -> 408 bytes
bin/Player.class | Bin 0 -> 958 bytes
src/Ball.java | 88 +++++++++++++++++++++++++++
src/Game.java | 55 +++++++++++++++++
src/Main.java | 10 +++
src/Player.java | 33 ++++++++++
11 files changed, 227 insertions(+)
create mode 100644 .classpath
create mode 100644 .project
create mode 100644 .settings/org.eclipse.jdt.core.prefs
create mode 100644 bin/Ball.class
create mode 100644 bin/Game.class
create mode 100644 bin/Main.class
create mode 100644 bin/Player.class
create mode 100644 src/Ball.java
create mode 100644 src/Game.java
create mode 100644 src/Main.java
create mode 100644 src/Player.java
diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..038a0e7
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/.project b/.project
new file mode 100644
index 0000000..a957399
--- /dev/null
+++ b/.project
@@ -0,0 +1,17 @@
+
+
+ Pong with Frames
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..ef28d2b
--- /dev/null
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,14 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=13
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=13
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
+org.eclipse.jdt.core.compiler.release=enabled
+org.eclipse.jdt.core.compiler.source=13
diff --git a/bin/Ball.class b/bin/Ball.class
new file mode 100644
index 0000000000000000000000000000000000000000..42370a1849c4e0d7f6728023be6fc01acdf51702
GIT binary patch
literal 1912
zcmZ`)O;a035Pd6F5{LzaV$0^k2K<4=g25(Eu)zk$0$GxUO+d(ogd~eJhK+@!S}g|U
zluJ%Nx+>R@6BiD4RUoMx@&jCzTmDOKsl1sL!mf~_*zWD=nSSqe&+6SjzyAT?4nz<>
z4f+GCSPVkf5c$@6Y3+_xckI%}SUTZYTg(V(=$7#@YsVcEFGa~6dn9TZyXuOPa5RLg
z!m+JlPB>M&Tv|@eYS7Xe+T!I>)wN1)&MIyT|KGEJy?gz7?u`b2wIW1;NePzTT_{&+
zYRdR`m+bEZS5nNXd48ZMp1aEx23IvS%a_^mPDw-1u{So=LW}aeXyC40vfXJ7O|hXI
z&yAN0B7`RN8aR(G{npPNZ(5+C&wzn8J^mvgUoRPGN1ODn80hf4K?7lQ%2>=m1f3yz
zrh#FMXlS_p{b#q+&pSv3^z2KuL^foJh!%sZoF8oiYFD}ST2<#+*r!X
z9XIeXZfOWHH)mJv^&(Z#W2=%=N5(FR$J<-$!pT}{A(AQQslUZ8@Vy??-A$Xy1~Rg_
zQiES2*YMA52ovX)#c|6<;%
z)Ty=-(4r^`i-^dWrMzj1#nVHaq)@(Gb_#aMa^+|djIZE^@DwXSJmd5#;6;lApWSqX
zRWPuMFXWUKh2Yrfv9#>T8omzVD-9P<(o-c@IL>y(6@|Ioyr{??8u$iX>`}$BORj>M
zb*#K>o@;N>^n1Fha;NQQqe4sNZ6_}hw(NO}?B1xXi2*9n#D70R=tdCD^jmm~eSG)H
zaaKO(SXoXnE$N|CSx&IB6kJ)#tt`b>mQvFOxP$kE&u+eb&vP}}ar0O7n2`&IxM)WD
z4>6#gm(6hD5LeannrR+k$P66ex~U)G=3DOa;S)Yhq5~VL(}svLOk7dkwqD+|ORRK_
zl}6Bmo49~anQ3?xF@f8B)A)^=tfP^q`DElE(tso`GZh(DPl
zk60N#!gToQ9>S)6h*`7g5Q%+6Rdi_&Z8DmW(ODH5tS2UAD1Dq5t0$&qG--xIN61KM
zO^WvU5s)
z)ByBoFx>d?xDr}1p}`Rdcrl&
zzx?W;>7XHGlmibuBxb-vKQsvSO
ziI!Hmb7T1d?%etn;^`R#UCiz7)93c<_I&&O=?j2McoIOJf^XbhwgT`eM3&5#W`EHv
z75b;PY#i6^4OkjYjMVpoN%Z2qTK-5ES-m)WaXZKIZmfhSBc14rqkY
zAf$sDTC^xSHM-Evs@AghYl{`81nto{;-c$ZV~8sRRxQV4*2hz+L_WmeJ(8hU
zwBs5l%>b#(T0AWnc0GBFWE)&VE2^6>U`8sqU|$V^@tOH|gQGi9?<^
zT*Fan9flm6NYs!N&9nMMgbbsGlQoGACsH0otu(@mh1WVW-L1B
z-E`AO)<_$!;VMO2WPRJH;YRW!Myg1OAegeM82$?}dn8OyY8&Rq9&USLYNx(`v+vUG
zdbAmj_HJu~Lo{%o=OkKqHp0hIHlZ0E+<~KL#bxY8ivNU(eOMyu-~iqrhPOC~4Rqow
rpY1!DKhTSx{Am=DDvln^GMe_D19Nyl>!F8ik*?f_qW2N8Iz0XZ7MJk~
literal 0
HcmV?d00001
diff --git a/bin/Main.class b/bin/Main.class
new file mode 100644
index 0000000000000000000000000000000000000000..3742c576134515c76b6202060307e9a04fd4e45d
GIT binary patch
literal 408
zcmZusO-sX25S*8$NfWD$R;wPpwI0k_DuM`liF&96#M4U+@s)f)n)<&y6%_md{wQ&_
z6?%~eyF0tHGjG3tKE42)O9u95&YM*n^!ZZS|na$>J-chgW+?u
z@ticZDYNk?cCky!tuAO4z+*c@gginc6J+n-d6dYaxC`Hd%rXX1eq@Cx1y
zSgiPaMwcjLR?O|wB|7h`vCk-Dp>8pD*97KmA`d(0u_Mb@WLVPsMDVoa@f!huHE_`3
X6OqB1h(7j-IutlyPrMI_Egby<+A~HG
literal 0
HcmV?d00001
diff --git a/bin/Player.class b/bin/Player.class
new file mode 100644
index 0000000000000000000000000000000000000000..1d1f3b1716b52607f854bc27823e094ce0f07024
GIT binary patch
literal 958
zcmZuuO-~b16g{tG6h!#RO4YfFZ0?9@nANtRt|g9W1@@3-nZ
z(t4vmeFvEjwSW_N|^4ggm6<}_&?7oR&h%p)O7!-d8_4I
z^1dn?`dUr;QRYTfbDwXKqN7)yZtBe*^>EQ_Srxf%xLXf&`7gRdFhgzpR6B?X1bA`+
zGaveh=nJuMUGXBV@FI=yB5h#wv4V#39AVaGH^G?JJ|nKh#yUu7(QpS7+6X2)n9`!v
z4o+)B_};;+7CgqBrW_;r!E1D$=RA!ET~|mXOdRDoMk1$3V~$yh?k{rO1y-ruQOwiK
z1TNxIkH#CW65w6tBQ9&7Fm;UOQ->JSwuzZ1reEy6+$Ej27>_H582RU+;__tSt0Q*s
z!(}zWe!wWXB*<+X)4W;0B$hGdG117E(|Sx?l<~xL(QT}G5@&FSNWooJD)7z5$ut
GL+&pRv#tOD
literal 0
HcmV?d00001
diff --git a/src/Ball.java b/src/Ball.java
new file mode 100644
index 0000000..7e1fe9b
--- /dev/null
+++ b/src/Ball.java
@@ -0,0 +1,88 @@
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+
+import javax.swing.JFrame;
+
+public class Ball extends JFrame implements KeyListener {
+
+ private static final long serialVersionUID = -629144081400642128L;
+
+ private float speed = 0.0000003f;
+
+ private float xPos = 300;
+ private float yPos = 300;
+ public int xSize = 100;
+ public int ySize = 100;
+
+ public boolean leftUp;
+ public boolean leftDown;
+
+ public boolean rightUp;
+ public boolean rightDown;
+
+ public Ball() {
+
+ this.addKeyListener(this);
+ this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ this.setVisible(true);
+
+ }
+
+ public void keyTyped(KeyEvent e) {
+
+ }
+
+ public void keyPressed(KeyEvent e) {
+ if (e.getKeyCode() == 87) {
+ leftUp = true;
+ leftDown = false;
+ } else if (e.getKeyCode() == 83) {
+ leftDown = true;
+ leftUp = false;
+ }
+ if (e.getKeyCode() == 38) {
+ rightUp = true;
+ rightDown = false;
+ } else if (e.getKeyCode() == 40) {
+ rightDown = true;
+ rightUp = false;
+ }
+ delay(10);
+ }
+
+ public void keyReleased(KeyEvent e) {
+
+ if (e.getKeyCode() == 87) {
+ leftUp = false;
+ } else if (e.getKeyCode() == 83) {
+ leftDown = false;
+ }
+
+ if (e.getKeyCode() == 38) {
+ rightUp = false;
+ } else if (e.getKeyCode() == 40) {
+ rightDown = false;
+ }
+
+ }
+
+ public int getPos(char coordinate, long dt) {
+
+ if (coordinate == 'x') {
+ return (int) xPos;
+ } else if (coordinate == 'y') {
+ return (int) yPos;
+ } else
+ return 0;
+ }
+
+ public void delay(int time) {
+
+ try {
+ Thread.sleep(time);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/src/Game.java b/src/Game.java
new file mode 100644
index 0000000..c202589
--- /dev/null
+++ b/src/Game.java
@@ -0,0 +1,55 @@
+
+public class Game {
+
+ Ball ball;
+
+ // Delta time: siehe https://en.wikipedia.org/wiki/Delta_timing
+ private long dt;
+ private long lastT;
+
+ private Player leftPlayer;
+ private Player rightPlayer;
+
+ public Game() {
+
+ ball = new Ball();
+
+ leftPlayer = new Player();
+ rightPlayer = new Player();
+
+ ball.setSize(ball.xSize, ball.ySize);
+
+ leftPlayer.setSize(0, leftPlayer.ySize);
+ leftPlayer.setLocation(leftPlayer.xPos, leftPlayer.getPos(0, false, false));
+ leftPlayer.setTitle("left Player");
+
+ rightPlayer.xPos = 1000;
+ rightPlayer.setSize(0, rightPlayer.ySize);
+ rightPlayer.setLocation(rightPlayer.xPos, rightPlayer.getPos(0, false, false));
+ rightPlayer.setTitle("right Player");
+
+ ball.setLocation(ball.getPos('x', dt), ball.getPos('y', dt));
+
+ lastT = System.nanoTime(); // delta time
+
+ while (true) {
+
+ dt = System.nanoTime() - lastT; // delta time
+ lastT = System.nanoTime(); // delta time
+
+ leftPlayer.setLocation(10, leftPlayer.getPos(dt, ball.leftUp, ball.leftDown));
+
+ rightPlayer.setLocation(rightPlayer.xPos, rightPlayer.getPos(dt, ball.rightUp, ball.rightDown));
+
+ // ball.setLocation(ball.getPos('x', dt), ball.getPos('y', dt));
+
+ // ball.leftPlayer.setLocation(10, 700);
+ // ball.xPos++;
+
+ //System.out.println(ball.leftDown + " " + ball.leftUp);
+
+ }
+
+ }
+
+}
diff --git a/src/Main.java b/src/Main.java
new file mode 100644
index 0000000..48f9a0a
--- /dev/null
+++ b/src/Main.java
@@ -0,0 +1,10 @@
+
+public class Main {
+
+ public static void main(String[] args) {
+
+ Game game = new Game();
+
+ }
+
+}
diff --git a/src/Player.java b/src/Player.java
new file mode 100644
index 0000000..785f3be
--- /dev/null
+++ b/src/Player.java
@@ -0,0 +1,33 @@
+import javax.swing.JFrame;
+
+public class Player extends JFrame {
+
+ private static final long serialVersionUID = -6213278730749915732L;
+
+ public float speed = 0.0000003f;
+
+ public int xPos = 10;
+ public double yPos = 100;
+ public int xSize = 100;
+ public int ySize = 200;
+
+ public Player() {
+
+ this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ this.setVisible(true);
+
+ }
+
+ public int getPos(long dt, boolean up, boolean down) {
+ System.out.println(yPos);
+
+ if(up) {
+ yPos -= speed * dt;
+ } else if(down) {
+
+ yPos += speed * dt;
+ }
+ return (int) yPos;
+ }
+
+}