changed Vector2D to Vector2f insted and added sound but the sound is not finnishd yet.

and added a update method to entity for ex the sound entity to update its position in the 
world. Added loging support to whit MultiPrintStream.java
This commit is contained in:
Ziver Koc 2007-03-15 19:52:28 +00:00
parent b2cf5d543b
commit 9d4810d38e
37 changed files with 1262 additions and 39 deletions

View file

@ -0,0 +1,93 @@
package ei.engine.util;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.text.ParseException;
import java.text.SimpleDateFormat;
/**
* @author Ziver
* this class kan print strings to multiple PrintStreams
*/
public class MultiPrintStream extends PrintStream {
//the printstreams that will print
private PrintStream[] streams;
//a instance of this class
public static MultiPrintStream out;
/**
* this constructor makes a simple PrintStream that prints to the console and to a file
* @param file the file name to outpu to
*/
public MultiPrintStream(String file){
super(new PrintStream(System.out));
try {
streams = new PrintStream[2];
streams[0] = new PrintStream(System.out);
streams[1] = new PrintStream(new File(file));
} catch (FileNotFoundException e) {
System.out.println("Error when declaring PrintStream!!");
e.printStackTrace();
}
}
/**
* this constructor takes a array of PrintStreams to be used
* @param streams a array of the streams that will be used
*/
public MultiPrintStream(PrintStream[] streams){
super(streams[0]);
this.streams = streams;
}
/**
* this constructor takes a array of PrintStreams to be used
* @param streams a array of the streams that will be used
*/
public static void makeInstance(MultiPrintStream instanceStream){
out = instanceStream;
}
public boolean checkError(){
for(int i=0; i<streams.length ;i++)
if(streams[i].checkError())
return true;
return false;
}
/**
* closes all the PrintStreams
*/
public void close(){
for(int i=0; i<streams.length ;i++)
streams[i].close();
}
/**
* prints whit a new line to all the PrintStreams
*/
public void println(String s){
s = getTime() + s;
for(int i=0; i<streams.length ;i++)
streams[i].println(s);
}
/**
* prints to all the PrintStreams
*/
public void print(String s){
for(int i=0; i<streams.length ;i++)
streams[i].print(s);
}
private String getTime(){
try {
return "" + (new SimpleDateFormat("yyyy/MM/dd HH:mm:ss")).parse(""+(new java.util.Date()));
} catch (ParseException e) {
return "";
}
}
}