Skip to content

Commit 0912249

Browse files
committed
Added a sky box and the beginnings of what will be player movement.
1 parent 668694e commit 0912249

File tree

15 files changed

+757
-3
lines changed

15 files changed

+757
-3
lines changed
72.6 KB
Loading
74.7 KB
Loading
72.1 KB
Loading
74.6 KB
Loading
73.9 KB
Loading
73.4 KB
Loading

sim-eth-basic/src/main/java/example/GameConstants.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,7 @@ public class GameConstants {
4848
public static final int PROTOCOL_VERSION = 42;
4949

5050
public static final int DEFAULT_PORT = 4269;
51+
52+
53+
public static final int GRID_CELL_SIZE = 32;
5154
}

sim-eth-basic/src/main/java/example/GameSessionState.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646

4747
import example.net.GameSessionListener;
4848
import example.net.client.GameSessionClientService;
49+
import example.view.PlayerMovementState;
50+
import example.view.SkyState;
51+
import example.view.SpaceGridState;
4952

5053
/**
5154
* The core state that manages the game session. This has several
@@ -59,7 +62,12 @@ public class GameSessionState extends CompositeAppState {
5962

6063
public GameSessionState() {
6164
// add normal states on the super-constructor
62-
super(new MessageState());
65+
super(new MessageState(),
66+
new SkyState(),
67+
new PlayerMovementState(),
68+
new SpaceGridState(GameConstants.GRID_CELL_SIZE, 10, new ColorRGBA(0.8f, 1f, 1f, 0.5f))
69+
//new SpaceGridState(2, 10, ColorRGBA.White)
70+
);
6371

6472
// Add states that need to support enable/disable independent of
6573
// the outer state using addChild().
@@ -84,7 +92,8 @@ protected void initialize( Application app ) {
8492
getState(ConnectionState.class).getService(GameSessionClientService.class).addGameSessionListener(gameSessionObserver);
8593

8694
InputMapper inputMapper = GuiGlobals.getInstance().getInputMapper();
87-
inputMapper.activateGroup(MainGameFunctions.IN_GAME);
95+
inputMapper.activateGroup(MainGameFunctions.IN_GAME);
96+
8897
}
8998

9099
@Override
@@ -101,6 +110,18 @@ protected void cleanup( Application app ) {
101110

102111
super.cleanup(app);
103112
}
113+
114+
@Override
115+
protected void onEnable() {
116+
super.onEnable();
117+
GuiGlobals.getInstance().setCursorEventsEnabled(false);
118+
}
119+
120+
@Override
121+
protected void onDisable() {
122+
super.onEnable();
123+
GuiGlobals.getInstance().setCursorEventsEnabled(true);
124+
}
104125

105126
/**
106127
* Notified by the server about game-session related events.

sim-eth-basic/src/main/java/example/InGameMenuState.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
import com.simsilica.lemur.input.InputMapper;
5151
import com.simsilica.lemur.style.ElementId;
5252

53+
import example.view.PlayerMovementState;
54+
5355
/**
5456
*
5557
*
@@ -64,7 +66,9 @@ public class InGameMenuState extends BaseAppState {
6466

6567
private List<Action> sessionActions = new ArrayList<>();
6668
private Container sessionButtons;
67-
69+
70+
private boolean movementState = false;
71+
6872
public InGameMenuState( boolean enabled ) {
6973
setEnabled(enabled);
7074
sessionActions.add(new CallMethodAction("Disconnect", this, "disconnect"));
@@ -147,10 +151,21 @@ protected void cleanup( Application app ) {
147151
protected void onEnable() {
148152
Node gui = ((Main)getApplication()).getGuiNode();
149153
gui.attachChild(mainWindow);
154+
155+
if( getState(PlayerMovementState.class) != null ) {
156+
// Save the enabled state of the PlayerMovementState so that we
157+
// can restore it if the menu is closed.
158+
this.movementState = getState(PlayerMovementState.class).isEnabled();
159+
getState(PlayerMovementState.class).setEnabled(false);
160+
}
150161
}
151162

152163
@Override
153164
protected void onDisable() {
154165
mainWindow.removeFromParent();
166+
167+
if( getState(PlayerMovementState.class) != null ) {
168+
getState(PlayerMovementState.class).setEnabled(movementState);
169+
}
155170
}
156171
}

sim-eth-basic/src/main/java/example/Main.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
import com.simsilica.state.DebugHudState;
5555
import com.simsilica.util.LogAdapter;
5656

57+
import example.view.PlayerMovementFunctions;
58+
5759
/**
5860
* The main bootstrap class for the SimEthereal networking example
5961
* game.
@@ -81,6 +83,7 @@ public Main() {
8183
new DebugHudState(), // SiO2 utility class
8284
new SiliconDioxideState(),
8385
new MainMenuState(),
86+
//new FlyCamAppState(), // temporary
8487
new ScreenshotAppState("", System.currentTimeMillis()));
8588
}
8689

@@ -97,6 +100,7 @@ public void simpleInitApp() {
97100
globals.getStyles().setDefaultStyle("glass");
98101

99102
MainGameFunctions.initializeDefaultMappings(globals.getInputMapper());
103+
PlayerMovementFunctions.initializeDefaultMappings(globals.getInputMapper());
100104

101105
// Since we've added the background spinning widget here, we'll
102106
// also register events to enable/disable it.

0 commit comments

Comments
 (0)