Skip to content

Commit

Permalink
configure movement speeds
Browse files Browse the repository at this point in the history
  • Loading branch information
benckx committed Jul 18, 2020
1 parent 2759875 commit ac088e3
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@

A basic camera system for a management game for jMonkeyEngine.

*Ouistiti* is French for marmoset.

![https://www.youtube.com/watch?v=s6HhQtTJuFI](images/demo.png)

https://www.youtube.com/watch?v=s6HhQtTJuFI
https://www.youtube.com/watch?v=ltBLNQPvsjU

# Features

Expand Down Expand Up @@ -40,7 +42,7 @@ https://www.youtube.com/watch?v=s6HhQtTJuFI

@Override
public void simpleUpdate(float tpf) {
cameraManager.simpleUpdate();
cameraManager.simpleUpdate(tpf);
}
}
```
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def jmeVersion = "3.3.2-stable"

apply plugin: 'kotlin'
apply plugin: 'idea'
apply plugin: 'maven'

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package be.encelade.ouistiti

import be.encelade.ouistiti.CameraManager.ViewMode.*
import be.encelade.ouistiti.ViewMode.*
import com.jme3.input.controls.ActionListener

class CameraActionListener(val cameraManager: CameraManager) : ActionListener {
Expand Down
9 changes: 5 additions & 4 deletions src/main/kotlin/be/encelade/ouistiti/CameraManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ open class CameraManager(val rootNode: Node, val camera: Camera, val inputManage

fun rotate() {
if (clockWise) {
for (i in 1..3) incrementNbrRotations()
repeat(3) { incrementNbrRotations() }
} else {
incrementNbrRotations()
}
Expand Down Expand Up @@ -153,13 +153,13 @@ open class CameraManager(val rootNode: Node, val camera: Camera, val inputManage
}

private fun baseLocationFor(viewMode: ViewMode): Vector3f {
val result = when (viewMode) {
val location = when (viewMode) {
TOP_VIEW -> Vector3f(0f, 0f, 20f)
SIDE_VIEW -> Vector3f(0f, -18f, 20f)
ISO_VIEW -> Vector3f(-13f, -13f, 18f)
}

return rotateForCurrentAngle(result)
return rotateForCurrentAngle(location)
}

private fun baseRotationFor(viewMode: ViewMode): Vector3f {
Expand All @@ -176,7 +176,8 @@ open class CameraManager(val rootNode: Node, val camera: Camera, val inputManage

private fun rotateForCurrentAngle(input: Vector3f): Vector3f {
var result = Vector3f(input)
for (i in 1..nbrRotations) {

repeat(nbrRotations) {
result = Vector3f(result.y, -result.x, result.z)
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/TestCameraManagerJava.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import be.encelade.ouistiti.CameraManager;
import be.encelade.ouistiti.ViewMode;
import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;

import static be.encelade.ouistiti.CameraManager.ViewMode.ISO_VIEW;
import static com.jme3.material.Materials.UNSHADED;

public class TestCameraManagerJava {
Expand All @@ -22,7 +22,7 @@ public static class MyJavaApp extends SimpleApplication {

@Override
public void simpleInitApp() {
cameraManager = new CameraManager(this, ISO_VIEW);
cameraManager = new CameraManager(this, ViewMode.ISO_VIEW);
cameraManager.loadDefaultKeyMappings();

inputManager.setCursorVisible(true);
Expand Down

0 comments on commit ac088e3

Please sign in to comment.