This is a big commit. Added mouse cursors and a load bar. Started whit the game. and many many other things
This commit is contained in:
parent
448fca2fdf
commit
4e7722fedb
34 changed files with 597 additions and 95 deletions
|
|
@ -1,48 +1,32 @@
|
|||
package ei.game.gamestate;
|
||||
|
||||
import ei.engine.LWJGLGameWindow;
|
||||
import ei.engine.effects.Particles;
|
||||
import ei.engine.math.Vector2f;
|
||||
import ei.engine.scene.Node;
|
||||
import ei.engine.scene.Sprite;
|
||||
import ei.engine.sound.Sound;
|
||||
import ei.engine.state.GameState;
|
||||
import ei.game.input.InGameMouseInput;
|
||||
import ei.game.scene.Map;
|
||||
|
||||
|
||||
public class InGameState extends GameState{
|
||||
private Node rootNode;
|
||||
private Sprite sprite1;
|
||||
private Sound sound1;
|
||||
private Particles p;
|
||||
private Map map;
|
||||
|
||||
public InGameState(String name){
|
||||
super(name);
|
||||
rootNode = new Node("InGameNode");
|
||||
InGameMouseInput mouse = new InGameMouseInput();
|
||||
super.getInput().addInput(mouse);
|
||||
|
||||
map = new Map(20,20);
|
||||
rootNode.add(map.getMapNode());
|
||||
|
||||
sprite1 = new Sprite("tank","data/units/tank.png");
|
||||
//sprite1.setScale(new Vector2f(0.5f,0.5f));
|
||||
//sprite1.setLocation(new Vector2f(300,300));
|
||||
rootNode.add(sprite1);
|
||||
|
||||
p = new Particles("particle");
|
||||
p.setLocation(sprite1.getLocation());
|
||||
rootNode.add(p);
|
||||
|
||||
sound1 = new Sound("sound","data/sounds/center.wav");
|
||||
sound1.loop();
|
||||
sound1.setLocation(sprite1.getLocation());
|
||||
rootNode.add(sound1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
rootNode.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
LWJGLGameWindow.getCamera().getLocation().add(new Vector2f(-1.5f,-1.5f));
|
||||
sprite1.getRotation().add(0, 0, 0.5f);
|
||||
rootNode.update();
|
||||
}
|
||||
|
||||
|
|
|
|||
115
src/ei/game/gamestate/LoadingState.java
Normal file
115
src/ei/game/gamestate/LoadingState.java
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
package ei.game.gamestate;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
|
||||
import ei.engine.LWJGLGameWindow;
|
||||
import ei.engine.math.Vector3f;
|
||||
import ei.engine.scene.Sprite;
|
||||
import ei.engine.sound.SoundLoader;
|
||||
import ei.engine.state.GameState;
|
||||
import ei.engine.state.GameStateManager;
|
||||
import ei.engine.texture.TextureLoader;
|
||||
|
||||
/**
|
||||
* This class handels the loading of the
|
||||
* images and sounds to the memmory.
|
||||
*
|
||||
* @author Ziver
|
||||
*/
|
||||
public class LoadingState extends GameState{
|
||||
// The things to load
|
||||
private Queue<String> loadTextures;
|
||||
private Queue<String> loadSounds;
|
||||
// The name of the next state to activate after loading
|
||||
private String nextState;
|
||||
|
||||
// Temp things for the loadingbar
|
||||
private int status;
|
||||
private Sprite bar;
|
||||
private Sprite loadBar;
|
||||
private Sprite background;
|
||||
|
||||
/**
|
||||
* Creates a loadingstate
|
||||
* @param name The name of the state
|
||||
*/
|
||||
public LoadingState(String name,String nextState) {
|
||||
super(name);
|
||||
this.nextState = nextState;
|
||||
status = 0;
|
||||
loadTextures = new LinkedList<String>();
|
||||
loadSounds = new LinkedList<String>();
|
||||
bar = new Sprite("Bar","data/loadbar_front.png");
|
||||
bar.setLocation(new Vector3f(
|
||||
(LWJGLGameWindow.getWidth()/2),
|
||||
(LWJGLGameWindow.getHeight()/2),0.0f));
|
||||
loadBar = new Sprite("LoadingBar","data/loadbar.png");
|
||||
loadBar.setLocation(new Vector3f(
|
||||
(LWJGLGameWindow.getWidth()/2)-loadBar.getWidth(),
|
||||
(LWJGLGameWindow.getHeight()/2)+3,0.0f));
|
||||
background = new Sprite("Bar","data/loadbar_back.png");
|
||||
background.setLocation(new Vector3f(
|
||||
(LWJGLGameWindow.getWidth()/2),
|
||||
(LWJGLGameWindow.getHeight()/2),0.0f));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a texture to be loaded
|
||||
* @param url
|
||||
*/
|
||||
public void addTexture(String url){
|
||||
loadTextures.add(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a sound to be loaded
|
||||
* @param url
|
||||
*/
|
||||
public void addSound(String url){
|
||||
loadSounds.add(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the things
|
||||
*/
|
||||
public void update() {
|
||||
if(!loadTextures.isEmpty()){
|
||||
TextureLoader.getTextureLoaderInstance().getTexture(loadTextures.poll());
|
||||
status++;
|
||||
}
|
||||
else if(!loadSounds.isEmpty()){
|
||||
SoundLoader.getInstnace().loadSound(loadSounds.poll());
|
||||
status++;
|
||||
}
|
||||
else{
|
||||
status++;
|
||||
if(status >= 100){
|
||||
//deactivate this state and activate the next one
|
||||
GameStateManager.getInstance().removeState(this);
|
||||
GameStateManager.getInstance().setActive(nextState);
|
||||
}
|
||||
|
||||
}
|
||||
background.update();
|
||||
loadBar.update();
|
||||
bar.update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the load bar
|
||||
*/
|
||||
public void render() {
|
||||
// Calculate the procentage
|
||||
float procent = (float)status/100;//(loadTextures.size()+loadSounds.size());
|
||||
System.out.println("lol: "+procent);
|
||||
loadBar.setLocation(new Vector3f(
|
||||
(LWJGLGameWindow.getWidth()/2)-loadBar.getWidth()+(loadBar.getWidth()*procent),
|
||||
(LWJGLGameWindow.getHeight()/2)+6,0.0f));
|
||||
//render the bar
|
||||
background.render();
|
||||
loadBar.render();
|
||||
bar.render();
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue