Added ai player and fixed so player kan create units

This commit is contained in:
Ziver Koc 2007-05-06 20:35:09 +00:00
parent e7403858f8
commit c83605d5c4
22 changed files with 373 additions and 123 deletions

View file

@ -132,7 +132,14 @@ public class LWJGLGameWindow {
// Depth Buffer Setup
GL11.glClearDepth(1.0f);
//Enable Blending
GL11.glEnable(GL11.GL_BLEND);
//GL11.glBlendFunc(GL11.GL_SRC_ALPHA,GL11.GL_ONE);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glViewport(0,0,width,height);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
//Select The Projection Matrix
GL11.glMatrixMode(GL11.GL_PROJECTION);
//Reset The Projection Matrix
@ -142,15 +149,9 @@ public class LWJGLGameWindow {
// Select The Modelview Matrix (controls model orientation)
GL11.glMatrixMode(GL11.GL_MODELVIEW);
//Enable Blending
GL11.glEnable(GL11.GL_BLEND);
//GL11.glBlendFunc(GL11.GL_SRC_ALPHA,GL11.GL_ONE);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
// Enable vsync if we can (due to how OpenGL works, it cannot be guarenteed to always work)
Display.setVSyncEnabled(true);
//Display.setVSyncEnabled(true);
// The last steps
@ -217,9 +218,9 @@ public class LWJGLGameWindow {
private void mainRender() {
// clear the screen
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
//GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();
cam.setWorldTranslationGL();
GL11.glPushMatrix();
//let subsystem paint

View file

@ -18,8 +18,9 @@ public class Node extends Sprite {
/**
* Add a Entity
* @param s the Sprite to add
* @return false if the Entity alredy exist else true
*
* @param s The Sprite to add
* @return False if the Entity alredy exist else true
*/
public boolean add(Entity s){
if(!entities.contains(s)){
@ -30,8 +31,25 @@ public class Node extends Sprite {
return false;
}
/**
* Add a Entity to a specific pos
*
* @param s The Sprite to add
* @param pos the pos to put the entity to
* @return False if the Entity alredy exist else true
*/
public boolean add(Entity s,int pos){
if(!entities.contains(s)){
MultiPrintStream.out.println("Adding Entity To Node("+getName()+"): "+s.getName());
entities.add(pos,s);
return true;
}
return false;
}
/**
* get a Entity
*
* @param name the name of Entity to get
* @return null if the Entity wasnt found
*/
@ -62,7 +80,8 @@ public class Node extends Sprite {
}
/**
* remove a Entity
* Remove a Entity
*
* @param name the name of Entity to remove
* @return false if the Entity alredy exist else true
*/
@ -121,6 +140,7 @@ public class Node extends Sprite {
/**
* Searches for the given name of a Entity
*
* @param name The name of the Entity
* @return The index of the Entity
*/
@ -140,4 +160,16 @@ public class Node extends Sprite {
}
return rect;
}
public int size(){
return entities.size();
}
public String toString(){
String msg = "Node[";
for(int i=0; i<entities.size() ;i++){
msg += entities.get(i).getName()+",";
}
return msg+"]";
}
}

View file

@ -69,7 +69,7 @@ public class MultiPrintStream extends PrintStream {
* prints whit a new line to all the PrintStreams
*/
public void println(String s){
s = getTime() + s;
if(!s.equals(""))s = getTime() + s;
for(int i=0; i<streams.length ;i++)
streams[i].println(s);
}