I have made a simple Java game, when I load the game a start-up menu pops up with a simple play button and a close button, if I press the start button Java changes to another class which takes the user to the game, if I press close the game shuts down. At the moment the game menu is very boring I wish to add a video to the start-up menu, is this possible using Java code and if so, is it complicated?
My code so far for my menu is shown bellow, the main two methods are the render and update methods, the render tells java what to add to the screen and the update method tells java what to do if a button is pressed:
package javagame;
import org.lwjgl.input.Mouse;
import org.newdawn.slick.*;
import org.newdawn.slick.state.*;
public class Menu extends BasicGameState{
//public String mouse= "no input yet";//COORDS if needed
Image bg;
public Menu(int state){
}
public void init(GameContainer gc, StateBasedGame sbg) throws SlickException{
bg = new Image("res/croftbg.png");
}
public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException{
bg.draw(0,0);
//g.drawString(mouse, 10, 50);//COORDS if needed
}
public void update(GameContainer gc, StateBasedGame sbg, int delta)throws SlickException{
int posX = Mouse.getX();
int posY = Mouse.getY();
//mouse = "mouse pos:" +posX+" " +posY;//Coords if needed
//play now button
if((posX>110 && posX<140) && (posY>5 && posY<25)){//checks if mouse is inside play now button
if(Mouse.isButtonDown(0)){//checks if left mouse pressed
sbg.enterState(1);//change to play state ie(1)
}
}
//exit button
if((posX>510 && posX<535) && (posY>5 && posY<25)){
if(Mouse.isButtonDown(0)){
System.exit(0);//closes the widow
}
}
}
public int getID(){
return 0;
}
Also, I do not require any audio, I only need the video.
Thank you in advance.
I would suggest you taking a look at Xuggler, as I think JMF is not widely used anymore.
I would also take a look at this Stack Overflow Question/Answer as it really does answer your question quite nicely.