Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
bucaar committed Sep 27, 2015
2 parents 2705f04 + ee3a3c2 commit fd81d69
Show file tree
Hide file tree
Showing 13 changed files with 109 additions and 4 deletions.
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# PongServer
The Pong Game Engine used for an AI Experiment

PongClient Protocol:
| Query | Response
--------------------+------------------------------+-----------------------
Commands: | "MOVE " + {"up [n]", | "OK"
| "down [n]", |
| "stop"} |
| | "ERROR"
| |
Requests: | "GET " + {"screenSize", | "[sizeX],[sizeY]"
| "ballLocation", | "[ballX],[ballY]"
| "ballSize", | "[ballD]"
| "BallVelocity", | "[ballDX],[ballDY]"
| "myPaddle", | "[pX],[pY],[pV]"
| "opponentPaddle", | "[pX],[pY],[pV]"
| "paddleSize", | "[pW],[pH]"
| "score"} | "[myScore],[opponentScore]"
| | "ERROR"
| |
Status: | "DONE" | "DONE"
| | "NO"
| | "ERROR"



What's New:

V1.2
Protocol *Added "DONE" to display current running state of Server. If response is "DONE" the client socket should be closed.

Ball.java *Set default ball speed to 20

Player.java *Fixed "ERROR" responses unexpectedly closing server.
*Added log method to verbos output from the server to command line.

PongApplet.java *Added log method to verbox output from the game to command line.
*Modified running variable for protocol access

V1.1
Ball.java *Split update into intervals based on speed.
*Fixed passing through paddles when ball is moving exceptionally fast.
*Removed unused if statements.
4 changes: 4 additions & 0 deletions build/built-jar.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#Sat, 26 Sep 2015 21:30:50 -0500


C\:\\Users\\Aaron\\Documents\\NetBeansProjects\\PongServer=
Binary file not shown.
Binary file added build/classes/com/bucaar/pongapplet/Paddle.class
Binary file not shown.
Binary file added build/classes/com/bucaar/pongapplet/Player.class
Binary file not shown.
Binary file not shown.
Binary file added build/classes/pongserver/PongServer.class
Binary file not shown.
Binary file added dist/PongServer.jar
Binary file not shown.
32 changes: 32 additions & 0 deletions dist/README.TXT
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
========================
BUILD OUTPUT DESCRIPTION
========================

When you build an Java application project that has a main class, the IDE
automatically copies all of the JAR
files on the projects classpath to your projects dist/lib folder. The IDE
also adds each of the JAR files to the Class-Path element in the application
JAR files manifest file (MANIFEST.MF).

To run the project from the command line, go to the dist folder and
type the following:

java -jar "PongServer.jar"

To distribute this project, zip up the dist folder (including the lib folder)
and distribute the ZIP file.

Notes:

* If two JAR files on the project classpath have the same name, only the first
JAR file is copied to the lib folder.
* Only JAR files are copied to the lib folder.
If the classpath contains other types of files or folders, these files (folders)
are not copied.
* If a library on the projects classpath also has a Class-Path element
specified in the manifest,the content of the Class-Path element has to be on
the projects runtime path.
* To set a main class in a standard Java project, right-click the project node
in the Projects window and choose Properties. Then click Run and enter the
class name in the Main Class field. Alternatively, you can manually type the
class name in the manifest Main-Class element.
2 changes: 2 additions & 0 deletions nbproject/private/private.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
compile.on.save=true
user.properties.file=C:\\Users\\Aaron\\AppData\\Roaming\\NetBeans\\8.0.2\\build.properties
7 changes: 7 additions & 0 deletions nbproject/private/private.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group/>
</open-files>
</project-private>
11 changes: 7 additions & 4 deletions src/com/bucaar/pongapplet/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,13 @@ public void run(){
if(input == null || input.equals("")){
break;
}
else if(input.startsWith("DONE")){
out.println(a.running?"NO":"DONE");
}
else if(input.startsWith("MOVE")){
if(input.length()<5){
out.println("ERROR");
return;
continue;
}
input = input.substring(5);
if(input.startsWith("up")){
Expand Down Expand Up @@ -84,13 +87,13 @@ else if(input.equals("stop")){
else if(input.startsWith("GET")){
if(input.length()<4){
out.println("ERROR");
return;
continue;
}
input = input.substring(4);
String[] requests = input.split(",");
if(requests.length == 0){
out.println("ERROR");
return;
continue;
}
StringBuilder output = new StringBuilder();
boolean follows = false;
Expand Down Expand Up @@ -153,7 +156,7 @@ else if(s.equals("score")){
}
else{
out.println("ERROR");
return;
continue;
}
}
out.println(output.toString());
Expand Down
13 changes: 13 additions & 0 deletions src/com/bucaar/pongapplet/PongApplet.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,37 @@
* @author Aaron
*/
public class PongApplet extends Applet implements Runnable{
<<<<<<< HEAD
private boolean running = true;
=======
>>>>>>> master
private Graphics graphics;
private BufferedImage image;
private int x = 0;
private boolean p1Win = false;
private boolean p2Win = false;

protected boolean running = true;
protected final int scoreToWin = 1;
protected Ball ball;
protected Paddle p1;
protected Paddle p2;

@Override
public void update(Graphics g){
<<<<<<< HEAD
if(p1.score == 1){
p1Win = true;
running = false;
}
else if(p2.score == 1){
=======
if(p1.score == scoreToWin){
p1Win = true;
running = false;
}
else if(p2.score == scoreToWin){
>>>>>>> master
p2Win = true;
running = false;
}
Expand Down

0 comments on commit fd81d69

Please sign in to comment.