Skip to content

Commit

Permalink
Tutorial fixes (25.11.17)
Browse files Browse the repository at this point in the history
Fixed GUIButton, renamed changePage to changeScene, added Controllers
compatibility to PlayerChracterNoclip
  • Loading branch information
Slaynash committed Nov 25, 2017
1 parent 0407f8b commit 6fb3036
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/slaynash/sgengine/gui/button/GUIButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void render(){
if(event == null) event = new GUIButtonEvent();
listener.mouseEntered(event);
}
text.setColour(textColorHover.r, textColorHover.g, textColorHover.b);
if(text != null) text.setColour(textColorHover.r, textColorHover.g, textColorHover.b);
}
if(mouseIn && isFocused()){
if(UserInputUtil.mouseLeftClicked()) for(GUIButtonListener listener : getGUIButtonListener()){
Expand All @@ -98,7 +98,7 @@ public void render(){
if(event == null) event = new GUIButtonEvent();
listener.mouseExited(event);
}
text.setColour(textColor.r, textColor.g, textColor.b);
if(text != null) text.setColour(textColor.r, textColor.g, textColor.b);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.lwjgl.input.Mouse;

import slaynash.sgengine.Configuration;
import slaynash.sgengine.inputs.ControllersControlManager;
import slaynash.sgengine.inputs.KeyboardControlManager;
import slaynash.sgengine.utils.DisplayManager;

Expand Down Expand Up @@ -40,8 +41,8 @@ public void update() {
}

private void updateAimDir() {
yaw -= (Mouse.getDX())*0.01f*Configuration.getMouseSensibility();
pitch += (Mouse.getDY())*0.01f*Configuration.getMouseSensibility();
yaw -= (Mouse.getDX())*0.01f*Configuration.getMouseSensibility() + ControllersControlManager.getValue(0, "cameraX")*.005f*DisplayManager.getFrameTime();
pitch += (Mouse.getDY())*0.01f*Configuration.getMouseSensibility() + ControllersControlManager.getValue(0, "cameraY")*.005f*DisplayManager.getFrameTime();

if (yaw >= PI*2f){
yaw -= PI*2f;
Expand Down Expand Up @@ -100,5 +101,11 @@ else if(KeyboardControlManager.isPressed("crouch"))
up = -WALK_SPEED;
else up = 0;
}

forward += -ControllersControlManager.getValue(0, "forward")*WALK_SPEED;
left += ControllersControlManager.getValue(0, "right")*WALK_SPEED;

up += ControllersControlManager.isPressed(0, "jump")?WALK_SPEED:0;
up -= ControllersControlManager.isPressed(0, "crouch")?WALK_SPEED:0;
}
}
6 changes: 3 additions & 3 deletions src/slaynash/sgengine/utils/SceneManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ else if(nextScene != null){
start();
}
else{
changePage();
changeScene();
}
}
try { Thread.sleep(1); } catch (InterruptedException e) { e.printStackTrace(LogSystem.getErrStream()); }
Expand Down Expand Up @@ -243,11 +243,11 @@ private static void start() {
* End current render loop, clear the current GamePage and start a new GamePage instance with his render
* @param page is the GamePage to start
*/
public static void changePage(Class<? extends Scene> page){
public static void changeScene(Class<? extends Scene> page){
nextScene = page;
}

private static void changePage(){
private static void changeScene(){
LogSystem.out_println("[SceneManager] Changing page from "+currentScene.getClass()+" to "+nextScene);
stop();
start();
Expand Down

0 comments on commit 6fb3036

Please sign in to comment.