add inputProcesser

This commit is contained in:
Sem van der Hoeven
2020-05-25 19:36:19 +02:00
parent f1f053e070
commit 8668bc2017
2 changed files with 15 additions and 1 deletions

View File

@@ -17,7 +17,7 @@ import netwerkprog.game.client.game.map.MapRenderer;
import netwerkprog.game.client.map.GameInputProcessor;
import netwerkprog.game.util.graphics.FrameRate;
public class MainGame extends ApplicationAdapter {
public class MainGame extends ApplicationAdapter{
SpriteBatch batch;
float screenWidth;
float screenHeight;
@@ -148,4 +148,6 @@ public class MainGame extends ApplicationAdapter {
public int getHorizontalTileAmount() {
return map.getWidth();
}
}

View File

@@ -0,0 +1,12 @@
package netwerkprog.game.util.application;
public class InputTransform {
public static float getCursorToModelX(int screenwidth, int screenX, int cursorX) {
return (((float) cursorX) * screenwidth) / ((float) screenX);
}
public static float getCursorToModelY(int screenHeight, int screenY, int cursorY) {
return ((float) (screenY - cursorY)) * screenHeight / ((float) screenY);
}
}