瀏覽代碼

Fixed color of ball

jancoow 10 年之前
父節點
當前提交
382b64a7e4
共有 2 個文件被更改,包括 6 次插入3 次删除
  1. 5 2
      server/server/match/Match.java
  2. 1 1
      src/model/objects/Ball.java

+ 5 - 2
server/server/match/Match.java

@@ -196,7 +196,9 @@ public class Match implements Runnable {
 
 		String ballsinfo = ",";
 		for (Ball b : balls) {
-			ballsinfo += b.getX() + "|" + b.getY() + "|" + b.getSize() + "|" + b.getColor().getRGB() + "|";
+			String color = Integer.toHexString(b.getColor().getRGB());
+			color = color.substring(2, color.length());
+			ballsinfo += b.getX() + "|" + b.getY() + "|" + b.getSize() + "|0x" + color + "|";
 		}
 
 		String linesinfo = ",";
@@ -241,7 +243,8 @@ public class Match implements Runnable {
 	}
 
 	public void stopMatch() {
-		timer.cancel();
+		if(timer != null)
+			timer.cancel();
 		try {
 			nwuser1.close();
 		} catch (IOException e) {

+ 1 - 1
src/model/objects/Ball.java

@@ -22,7 +22,7 @@ public class Ball {
 	// ** Drawing and Calculating **//
 
 	public void paint(Graphics2D g2d) {
-		g2d.setColor(Color.BLUE);
+		g2d.setColor(color);
 		g2d.fill(bal);
 	}