Added a main menu and fixed som things. added explotions to and fixed the economy
This commit is contained in:
parent
5bb373573d
commit
88771fad29
56 changed files with 1859 additions and 1999 deletions
|
|
@ -1,5 +1,8 @@
|
|||
package ei.game.gamestate;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
|
||||
|
|
@ -9,6 +12,7 @@ import ei.engine.sound.SoundLoader;
|
|||
import ei.engine.state.GameState;
|
||||
import ei.engine.state.GameStateManager;
|
||||
import ei.engine.texture.TextureLoader;
|
||||
import ei.engine.util.FileFinderHasher;
|
||||
|
||||
/**
|
||||
* This class handels the loading of the
|
||||
|
|
@ -17,6 +21,13 @@ import ei.engine.texture.TextureLoader;
|
|||
* @author Ziver
|
||||
*/
|
||||
public class LoadingState extends GameState{
|
||||
//The extensions of the files
|
||||
private static final String[] TEXTURES = {
|
||||
"jpg","png","bmp"
|
||||
};
|
||||
private static final String[] SOUNDS = {
|
||||
"wav","ogg"
|
||||
};
|
||||
// The things to load
|
||||
private Queue<String> loadTextures;
|
||||
private Queue<String> loadSounds;
|
||||
|
|
@ -32,6 +43,10 @@ public class LoadingState extends GameState{
|
|||
public LoadingState(String name,String nextState) {
|
||||
super(name);
|
||||
this.nextState = nextState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
loadTextures = new LinkedList<String>();
|
||||
loadSounds = new LinkedList<String>();
|
||||
|
||||
|
|
@ -40,6 +55,33 @@ public class LoadingState extends GameState{
|
|||
progress.setBarTexture(new Sprite("ProgressBar","data/loadbar_front.png"));
|
||||
progress.setProgressTexture(new Sprite("Progress","data/loadbar.png"));
|
||||
progress.setBackgroundTexture(new Sprite("progressBackground","data/loadbar_back.png"));
|
||||
|
||||
try {
|
||||
File dir = new File(getClass().getClassLoader().getResource("data/").toURI());
|
||||
ArrayList<File> files = FileFinderHasher.Search(dir);
|
||||
for(int i=0; i<files.size() ;i++){
|
||||
String ext = files.get(i).getName();
|
||||
ext = ext.substring(ext.lastIndexOf ('.')+1,ext.length());
|
||||
|
||||
if(contains(TEXTURES,ext)){
|
||||
addTexture(files.get(i).getPath().substring(files.get(i).getPath().lastIndexOf("data"), files.get(i).getPath().length()));
|
||||
}
|
||||
else if(contains(SOUNDS,ext)){
|
||||
addSound(files.get(i).getPath().substring(files.get(i).getPath().lastIndexOf("data"), files.get(i).getPath().length()));
|
||||
}
|
||||
}
|
||||
} catch (URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean contains(String[] array, String search){
|
||||
for(int i=0; i<array.length ;i++){
|
||||
if(array[i].equals(search)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -73,7 +115,7 @@ public class LoadingState extends GameState{
|
|||
progress.setValue(progress.getValue()+1);
|
||||
}
|
||||
else{
|
||||
progress.setValue(progress.getValue()+1);
|
||||
//progress.setValue(progress.getValue()+1);
|
||||
if(progress.getProcent() >= 100){
|
||||
//deactivate this state and activate the next one
|
||||
GameStateManager.getInstance().removeState(this);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue