Created
September 12, 2008 18:23
-
-
Save ariejan/10490 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sep 12, 2008 8:22:15 PM com.jme.app.BaseGame start | |
INFO: Application started. | |
Sep 12, 2008 8:22:15 PM com.jme.system.PropertiesIO <init> | |
INFO: PropertiesIO created | |
Sep 12, 2008 8:22:15 PM com.jme.system.PropertiesIO load | |
INFO: Read properties | |
Sep 12, 2008 8:22:17 PM com.jme.system.PropertiesIO save | |
INFO: Saved properties | |
Sep 12, 2008 8:22:17 PM com.jme.input.joystick.DummyJoystickInput <init> | |
INFO: Joystick support is disabled | |
Sep 12, 2008 8:22:17 PM com.jme.system.lwjgl.LWJGLDisplaySystem <init> | |
INFO: LWJGL Display System created. | |
Sep 12, 2008 8:22:17 PM com.jme.renderer.lwjgl.LWJGLRenderer <init> | |
INFO: LWJGLRenderer created. W: 800H: 600 | |
Sep 12, 2008 8:22:18 PM com.jme.util.lwjgl.LWJGLTimer <init> | |
INFO: Timer resolution: 1000 ticks per second | |
Sep 12, 2008 8:22:18 PM com.jmex.game.state.GameStateManager create | |
INFO: Created GameStateManager | |
Sep 12, 2008 8:22:18 PM com.jme.scene.Node <init> | |
INFO: Node created. | |
Sep 12, 2008 8:22:18 PM com.jme.renderer.AbstractCamera <init> | |
INFO: Camera created. | |
FOUND DEVICE: InputHandlerDevice: mouse | |
FOUND DEVICE: InputHandlerDevice: keyboard | |
Sep 12, 2008 8:22:18 PM com.jme.scene.Node <init> | |
INFO: Node created. | |
Sep 12, 2008 8:22:18 PM com.jme.scene.Node attachChild | |
INFO: Child (Mouse Input) attached to this node (Cursor) | |
Sep 12, 2008 8:22:18 PM com.jme.scene.Node attachChild | |
INFO: Child (Cursor) attached to this node (login: RootNode) | |
Sep 12, 2008 8:22:18 PM com.jme.scene.Node attachChild | |
INFO: Child (title) attached to this node (login: RootNode) | |
Sep 12, 2008 8:22:21 PM com.noir.clientv2.NoirClientV2 cleanup | |
INFO: Cleaning up resources. | |
Sep 12, 2008 8:22:21 PM com.jme.app.BaseGame start | |
INFO: Application ending. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.noir.clientv2.handlers; | |
import com.jme.input.InputHandler; | |
import com.jme.input.KeyBindingManager; | |
import com.jme.input.KeyInput; | |
import com.jme.input.action.InputAction; | |
import com.jme.input.action.InputActionEvent; | |
import com.jmex.game.state.GameState; | |
import com.noir.clientv2.NoirClientV2; | |
public class LoginHandler extends InputHandler { | |
public LoginHandler(GameState myGameState) { | |
setKeyBindings(); | |
} | |
private void setKeyBindings() { | |
KeyBindingManager.getKeyBindingManager().set("exit", KeyInput.KEY_ESCAPE); | |
addAction(new ExitAction(), "exit", false ); | |
KeyBindingManager.getKeyBindingManager().set("enter", KeyInput.KEY_RETURN); | |
addAction(new ExitAction(), "enter", false); | |
} | |
private static class ExitAction extends InputAction { | |
public void performAction( InputActionEvent evt ) { | |
System.out.println("KEY STROKE RECEIVED!"); | |
// NoirClientV2.exit(); | |
} | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.noir.clientv2.gamestates; | |
import com.jme.image.Texture; | |
import com.jme.input.AbsoluteMouse; | |
import com.jme.input.InputHandler; | |
import com.jme.input.InputHandlerDevice; | |
import com.jme.input.Mouse; | |
import com.jme.math.Vector3f; | |
import com.jme.renderer.Renderer; | |
import com.jme.scene.Node; | |
import com.jme.scene.Text; | |
import com.jme.scene.state.AlphaState; | |
import com.jme.scene.state.LightState; | |
import com.jme.scene.state.TextureState; | |
import com.jme.system.DisplaySystem; | |
import com.jme.util.TextureManager; | |
import com.jmex.game.state.CameraGameState; | |
import com.noir.clientv2.handlers.LoginHandler; | |
public class LoginState extends CameraGameState { | |
/** This holds the mouse cursor */ | |
private Node cursor; | |
/** Our display system. */ | |
private DisplaySystem display; | |
private Text headerText; | |
private InputHandler input; | |
private Mouse mouse; | |
public LoginState() { | |
super("login"); | |
display = DisplaySystem.getDisplaySystem(); | |
initInput(); | |
initCursor(); | |
initText(); | |
rootNode.setLightCombineMode(LightState.OFF); | |
rootNode.setRenderQueueMode(Renderer.QUEUE_ORTHO); | |
rootNode.updateRenderState(); | |
rootNode.updateGeometricState(0, true); | |
} | |
public void onActivate() { | |
display.setTitle("NoirClientV2 - Login"); | |
super.onActivate(); | |
} | |
protected void initInput() { | |
input = new LoginHandler(this); | |
DisplaySystem display = DisplaySystem.getDisplaySystem(); | |
mouse = new AbsoluteMouse("Mouse Input", display.getWidth(), | |
display.getHeight()); | |
mouse.registerWithInputHandler(input); | |
for ( InputHandlerDevice device : LoginHandler.getDevices() ) { | |
System.out.println(" FOUND DEVICE: " + device.toString() ); | |
} | |
} | |
protected void initCursor() { | |
Texture texture = | |
TextureManager.loadTexture( | |
LoginState.class.getClassLoader().getResource( | |
"com/noir/clientv2/data/cursors/default.png"), | |
Texture.MM_LINEAR_LINEAR, | |
Texture.FM_LINEAR); | |
TextureState ts = display.getRenderer().createTextureState(); | |
ts.setEnabled(true); | |
ts.setTexture(texture); | |
AlphaState alpha = display.getRenderer().createAlphaState(); | |
alpha.setBlendEnabled(true); | |
alpha.setSrcFunction(AlphaState.SB_SRC_ALPHA); | |
alpha.setDstFunction(AlphaState.DB_ONE); | |
alpha.setTestEnabled(true); | |
alpha.setTestFunction(AlphaState.TF_GREATER); | |
alpha.setEnabled(true); | |
mouse.setRenderState(ts); | |
mouse.setRenderState(alpha); | |
mouse.setLocalScale(new Vector3f(1, 1, 1)); | |
cursor = new Node("Cursor"); | |
cursor.attachChild(mouse); | |
rootNode.attachChild(cursor); | |
} | |
protected void initText() { | |
DisplaySystem display = DisplaySystem.getDisplaySystem(); | |
headerText = Text.createDefaultTextLabel("title"); | |
headerText.print( "Please login" ); | |
headerText.getLocalTranslation().set( | |
(display.getWidth() / 2) - (headerText.getWidth() / 2), | |
display.getHeight() - 100, 0 ); | |
rootNode.attachChild(headerText); | |
} | |
/** Update input and button */ | |
protected void statusUpdate(float tpf) { | |
input.update(tpf); | |
rootNode.updateGeometricState(tpf, true); | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.noir.clientv2; | |
import java.util.logging.Level; | |
import java.util.logging.Logger; | |
import com.jme.app.AbstractGame; | |
import com.jme.app.BaseGame; | |
import com.jme.input.KeyInput; | |
import com.jme.input.MouseInput; | |
import com.jme.input.joystick.JoystickInput; | |
import com.jme.system.DisplaySystem; | |
import com.jme.system.JmeException; | |
import com.jme.util.Timer; | |
import com.jmex.game.state.GameState; | |
import com.jmex.game.state.GameStateManager; | |
import com.noir.clientv2.gamestates.LoginState; | |
public class NoirClientV2 extends BaseGame { | |
private static final Logger logger = Logger.getLogger(NoirClientV2.class | |
.getName()); | |
/** Only used in the static exit method. */ | |
private static AbstractGame instance; | |
/** High resolution timer for jME. */ | |
private Timer timer; | |
/** Simply an easy way to get at timer.getTimePerFrame(). */ | |
private float tpf; | |
/** | |
* @param args | |
*/ | |
public static void main(String[] args) { | |
NoirClientV2 nc = new NoirClientV2(); | |
nc.setDialogBehaviour(AbstractGame.ALWAYS_SHOW_PROPS_DIALOG); | |
nc.start(); | |
} | |
public static void exit() { | |
instance.finish(); | |
} | |
@Override | |
protected void cleanup() { | |
logger.info("Cleaning up resources."); | |
// Performs cleanup on all loaded game states. | |
GameStateManager.getInstance().cleanup(); | |
KeyInput.destroyIfInitalized(); | |
MouseInput.destroyIfInitalized(); | |
JoystickInput.destroyIfInitalized(); | |
} | |
@Override | |
/** Called after BaseGame.start() after initSystem() */ | |
protected void initGame() { | |
instance = this; | |
display.setTitle("NoirClient V2"); | |
// Creates the GameStateManager. Only needs to be called once. | |
GameStateManager.create(); | |
// Adds a new GameState to the GameStateManager. In order for it to get | |
// processed (rendered and updated) it needs to get activated. | |
GameState login = new LoginState(); | |
login.setActive(true); | |
GameStateManager.getInstance().attachChild(login); | |
} | |
@Override | |
/** Called after BaseGame.start(); */ | |
protected void initSystem() { | |
try { | |
/** Get a DisplaySystem according to the renderer selected in the startup box. */ | |
display = DisplaySystem.getDisplaySystem(properties.getRenderer()); | |
/** Create a window with the startup box's information. */ | |
display.createWindow( | |
properties.getWidth(), | |
properties.getHeight(), | |
properties.getDepth(), | |
properties.getFreq(), | |
properties.getFullscreen()); | |
/** Create a camera specific to the DisplaySystem that works with | |
* the display's width and height*/ | |
} | |
catch (JmeException e) { | |
/** If the displaysystem can't be initialized correctly, exit instantly. */ | |
logger.log(Level.SEVERE, "Could not create displaySystem", e); | |
System.exit(1); | |
} | |
/** Get a high resolution timer for FPS updates. */ | |
timer = Timer.getTimer(); | |
} | |
@Override | |
protected void reinit() { | |
// TODO Auto-generated method stub | |
} | |
@Override | |
/** This is called every frame after update() */ | |
protected void render(float interpolation) { | |
// Clears the previously rendered information. | |
display.getRenderer().clearBuffers(); | |
// Render the current game state. | |
GameStateManager.getInstance().render(tpf); | |
} | |
@Override | |
/** This is called every frame */ | |
protected void update(float interpolation) { | |
timer.update(); | |
tpf = timer.getTimePerFrame(); | |
GameStateManager.getInstance().update(tpf); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment