|
@@ -6,20 +6,23 @@ import model.Inventory;
|
|
|
import view.tile.TileManager;
|
|
import view.tile.TileManager;
|
|
|
import util.GAMESTATE;
|
|
import util.GAMESTATE;
|
|
|
import controller.KeyHandler;
|
|
import controller.KeyHandler;
|
|
|
|
|
+import view.util.screenCoordinatesToWorld;
|
|
|
|
|
|
|
|
import javax.swing.*;
|
|
import javax.swing.*;
|
|
|
import java.awt.*;
|
|
import java.awt.*;
|
|
|
|
|
|
|
|
-public class GamePanel extends JPanel implements Runnable{
|
|
|
|
|
|
|
+public class GamePanel extends JPanel implements Runnable, screenCoordinatesToWorld {
|
|
|
|
|
|
|
|
//Screen Settings
|
|
//Screen Settings
|
|
|
- final int originalTileSize = 16;
|
|
|
|
|
- final int scale = 4;
|
|
|
|
|
|
|
+ final static int originalTileSize = 16;
|
|
|
|
|
+ final static int scale = 4;
|
|
|
|
|
|
|
|
int fps = 60;
|
|
int fps = 60;
|
|
|
|
|
|
|
|
public Inventory inventory;
|
|
public Inventory inventory;
|
|
|
|
|
|
|
|
|
|
+ public static int static_TileSize = originalTileSize * scale;
|
|
|
|
|
+
|
|
|
public int tileSize = originalTileSize * scale;
|
|
public int tileSize = originalTileSize * scale;
|
|
|
public int maxScreenCol = 16;
|
|
public int maxScreenCol = 16;
|
|
|
public int maxScreenRow = 12;
|
|
public int maxScreenRow = 12;
|
|
@@ -62,6 +65,9 @@ public class GamePanel extends JPanel implements Runnable{
|
|
|
this.setFocusable(true);
|
|
this.setFocusable(true);
|
|
|
|
|
|
|
|
gameState = GAMESTATE.PLAY;
|
|
gameState = GAMESTATE.PLAY;
|
|
|
|
|
+
|
|
|
|
|
+ System.out.println("Screen Width: " + screenWidth);
|
|
|
|
|
+ System.out.println("Screen Height: " + screenHeight);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void zoomInOut(int i){
|
|
public void zoomInOut(int i){
|
|
@@ -140,9 +146,15 @@ public class GamePanel extends JPanel implements Runnable{
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- public void screenCoordinatesToWorld(int screenX, int screenY){
|
|
|
|
|
- // Todo
|
|
|
|
|
|
|
+
|
|
|
|
|
+ public int x(int screenX){
|
|
|
|
|
+ return (int) (camera.worldX + screenX / (double) tileSize);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public int y(int screenY){
|
|
|
|
|
+ return (int) (camera.worldY + screenY / (double) tileSize);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
public void highlightTile(int screenX, int screenY) {
|
|
public void highlightTile(int screenX, int screenY) {
|
|
|
System.out.println("X: " + screenX/tileSize+" Y: "+screenY/tileSize);
|
|
System.out.println("X: " + screenX/tileSize+" Y: "+screenY/tileSize);
|
|
|
}
|
|
}
|