Skip to content

Commit 7082d7f

Browse files
committed
Working on a general sysout class
1 parent 8375d35 commit 7082d7f

File tree

3 files changed

+69
-3
lines changed

3 files changed

+69
-3
lines changed

src/com/redomar/game/Game.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.redomar.game.net.GameClient;
2929
import com.redomar.game.net.GameServer;
3030
import com.redomar.game.net.packets.Packet00Login;
31+
import com.redomar.game.script.Printing;
3132
import com.thehowtotutorial.splashscreen.JSplash;
3233

3334
public class Game extends Canvas implements Runnable {
@@ -41,6 +42,7 @@ public class Game extends Canvas implements Runnable {
4142
private static final int SCALE = 3;
4243
private static final String NAME = "Game";
4344
private static Game game;
45+
private static Time time = new Time();
4446
private static int Jdata_Host;
4547
private static String Jdata_UserName = "";
4648
private static String Jdata_IP = "127.0.0.1";
@@ -67,7 +69,6 @@ public class Game extends Canvas implements Runnable {
6769
private Player player;
6870
private Dummy dummy;
6971
private Music music = new Music();
70-
private Time time = new Time();
7172
private Font font = new Font();
7273
private Thread musicThread = new Thread(music, "MUSIC");
7374
private String nowPlaying;
@@ -76,6 +77,7 @@ public class Game extends Canvas implements Runnable {
7677
private int trigger = 0;
7778
private GameClient socketClient;
7879
private GameServer socketServer;
80+
private Printing print = new Printing();
7981

8082

8183
public Game() {
@@ -248,7 +250,8 @@ public void render() {
248250
musicThread.start();
249251
notActive = false;
250252
} else {
251-
System.out.println("[GAME] Canceled music option");
253+
//System.out.println("[GAME] Canceled music option");
254+
print.print(" Canceled music option", 1);
252255
input.setPlayMusic(false);
253256
}
254257
}
@@ -386,6 +389,14 @@ public void setLevel(LevelHandler level) {
386389
this.level = level;
387390
}
388391

392+
public static Time getTime() {
393+
return Game.time;
394+
}
395+
396+
public void setTime(Time time) {
397+
Game.time = time;
398+
}
399+
389400
public WindowHandler getWindow() {
390401
return window;
391402
}

src/com/redomar/game/lib/Time.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public Time(){
99

1010
}
1111

12-
public String getTime(){
12+
public synchronized String getTime(){
1313
Calendar cal = Calendar.getInstance();
1414
cal.getTime();
1515
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package com.redomar.game.script;
2+
3+
import com.redomar.game.lib.Time;
4+
5+
public class Printing {
6+
7+
private int type = 0;
8+
private Time time = new Time();
9+
private String message;
10+
private String typeName = "[System]";
11+
12+
public Printing(){
13+
14+
}
15+
16+
public void print(String message, int type){
17+
setType(type);
18+
setMessage(message);
19+
System.out.println("["+time.getTime()+"]"+type()+getMessage());
20+
}
21+
22+
private String type(){
23+
if (getType() == 1){
24+
this.typeName = "[GAME]";
25+
}else if(getType() == 2){
26+
this.typeName = "[MUSIC]";
27+
}
28+
29+
return this.typeName;
30+
}
31+
32+
public int getType() {
33+
return type;
34+
}
35+
36+
public void setType(int type) {
37+
this.type = type;
38+
}
39+
40+
public String getTypeName() {
41+
return typeName;
42+
}
43+
44+
public void setTypeName(String typeName) {
45+
this.typeName = typeName;
46+
}
47+
48+
public String getMessage() {
49+
return message;
50+
}
51+
52+
public void setMessage(String message) {
53+
this.message = message;
54+
}
55+
}

0 commit comments

Comments
 (0)