mirror of
https://github.com/jokerx3/HeatUp
synced 2026-07-27 10:19:46 +02:00
Merge branch 'master' of github.com:jokerx3/prp
This commit is contained in:
@@ -16,13 +16,13 @@ public class Config {
|
|||||||
public static int singleTilePixels = gamePanelWidth/mapMaxTilesWidth;
|
public static int singleTilePixels = gamePanelWidth/mapMaxTilesWidth;
|
||||||
public static void setGamePanelWidth(int width) {
|
public static void setGamePanelWidth(int width) {
|
||||||
// Wir wollen hier keine Reste!
|
// Wir wollen hier keine Reste!
|
||||||
while (width % mapMaxTilesHeight != 0) {
|
while (width % mapMaxTilesWidth != 0) {
|
||||||
width--;
|
width--;
|
||||||
}
|
}
|
||||||
gamePanelWidth = width;
|
gamePanelWidth = width;
|
||||||
updateSingleTilePixels();
|
updateSingleTilePixels();
|
||||||
}
|
}
|
||||||
private static void updateSingleTilePixels() {
|
private static void updateSingleTilePixels() {
|
||||||
singleTilePixels = gamePanelWidth/mapMaxTilesHeight;
|
singleTilePixels = gamePanelWidth/mapMaxTilesWidth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,12 +30,15 @@ public class StaticObject extends JComponent {
|
|||||||
private int staticObjectHeight;
|
private int staticObjectHeight;
|
||||||
|
|
||||||
public StaticObject(char staticObjectType, Point location, int staticObjectWidth, int staticObjectHeight) {
|
public StaticObject(char staticObjectType, Point location, int staticObjectWidth, int staticObjectHeight) {
|
||||||
|
System.out.println("Object Type: " + staticObjectType + "\t" +staticObjectHeight + " h:w " + staticObjectWidth);
|
||||||
this.staticObjectType = staticObjectType;
|
this.staticObjectType = staticObjectType;
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.staticObjectWidth = staticObjectWidth;
|
this.staticObjectWidth = staticObjectWidth;
|
||||||
this.staticObjectHeight = staticObjectHeight;
|
this.staticObjectHeight = staticObjectHeight;
|
||||||
loadBufferedImage();
|
loadBufferedImage();
|
||||||
setAutoBounds(location.x, location.y);
|
setAutoBounds(location.x, location.y);
|
||||||
|
autoRescale();
|
||||||
|
//System.out.println(getDebugInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
public StaticObject(char staticObjectType, Point location) {
|
public StaticObject(char staticObjectType, Point location) {
|
||||||
@@ -51,7 +54,9 @@ public class StaticObject extends JComponent {
|
|||||||
}
|
}
|
||||||
//g2d.rotate(0.2, 10, 10);
|
//g2d.rotate(0.2, 10, 10);
|
||||||
|
|
||||||
|
// TODO: Check if we can store a rescaled image in bf1???
|
||||||
if ( doRescale ) {
|
if ( doRescale ) {
|
||||||
|
//System.out.println("hit");
|
||||||
g2d.scale(rescaleFactorX, rescaleFactorY);
|
g2d.scale(rescaleFactorX, rescaleFactorY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,24 +72,40 @@ public class StaticObject extends JComponent {
|
|||||||
this.bf1 = image;
|
this.bf1 = image;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRescale(double rescaleFactorX, double rescaleFactorY) {
|
private void autoRescale() {
|
||||||
this.rescaleFactorX = rescaleFactorX;
|
// TODO: get original width and hight of bf1
|
||||||
this.rescaleFactorY = rescaleFactorY;
|
// Calculate factor new/original
|
||||||
this.doRescale = true;
|
// Rescale image using factor
|
||||||
|
// Save new bf in bf1 ???
|
||||||
|
this.rescaleFactorX = this.staticObjectWidth / this.bf1.getWidth();
|
||||||
|
this.rescaleFactorY = this.staticObjectHeight / this.bf1.getHeight();
|
||||||
|
|
||||||
|
System.out.println("Object: " + this.staticObjectType + "\tBuffered Image: Height: " + this.bf1.getHeight() + "\t Width: " + this.bf1.getWidth() + "\tStatic Object: Height: " + this.staticObjectHeight + "\t Width: " + this.staticObjectWidth);
|
||||||
|
|
||||||
|
if (this.rescaleFactorX != 1 && this.rescaleFactorY != 1 ) {
|
||||||
|
this.doRescale = true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unsetRescale() {
|
// public void setRescale(double rescaleFactorX, double rescaleFactorY) {
|
||||||
this.rescaleFactorX = 0.0;
|
// this.rescaleFactorX = rescaleFactorX;
|
||||||
this.rescaleFactorY = 0.0;
|
// this.rescaleFactorY = rescaleFactorY;
|
||||||
this.doRescale = false;
|
// this.doRescale = true;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
// public void unsetRescale() {
|
||||||
|
// this.rescaleFactorX = 0.0;
|
||||||
|
// this.rescaleFactorY = 0.0;
|
||||||
|
// this.doRescale = false;
|
||||||
|
// }
|
||||||
|
|
||||||
public void setAutoBounds(int x, int y) {
|
public void setAutoBounds(int x, int y) {
|
||||||
this.setBounds(x, y, this.bf1.getWidth(), this.bf1.getHeight());
|
this.setBounds(x, y, this.bf1.getWidth(), this.bf1.getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDebugInfo() {
|
public String getDebugInfo() {
|
||||||
String info = "Debug: " + "Rescale enabled:" + this.doRescale + "Rescale X:" + this.rescaleFactorX + "Rescale Y:" + this.rescaleFactorY + " Heigth:" + this.staticObjectHeight + " Width:" + this.staticObjectWidth + " StaticObjectType:" + this.staticObjectType + " X Position:" + this.location.x + " Y Position:" + this.location.y;
|
String info = "Debug: " + "Rescale? " + this.doRescale + "\tScale X:" + this.rescaleFactorX + "\tScale Y: " + this.rescaleFactorY + "\tH: " + this.staticObjectHeight + "\tW: " + this.staticObjectWidth + "\tStaticObjectType: " + this.staticObjectType + "\tX : " + this.location.x + "\tY :" + this.location.y;
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package de.heatup.testing;
|
|||||||
|
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
|
|
||||||
|
import de.heatup.cfg.Config;
|
||||||
import de.heatup.mapengine.MapEngine;
|
import de.heatup.mapengine.MapEngine;
|
||||||
import de.heatup.objects.DynamicObject;
|
import de.heatup.objects.DynamicObject;
|
||||||
import de.heatup.objects.StaticObject;
|
import de.heatup.objects.StaticObject;
|
||||||
@@ -25,7 +26,7 @@ public class GameLoop {
|
|||||||
|
|
||||||
//dynO3.setRescale(1.5,3.5);
|
//dynO3.setRescale(1.5,3.5);
|
||||||
|
|
||||||
|
Config.setGamePanelWidth(850);
|
||||||
MapEngine me = new MapEngine(1);
|
MapEngine me = new MapEngine(1);
|
||||||
for (StaticObject currentStaticObject : me.getAllMapObjects()) {
|
for (StaticObject currentStaticObject : me.getAllMapObjects()) {
|
||||||
GameInterface.getGamePanel().add(currentStaticObject);
|
GameInterface.getGamePanel().add(currentStaticObject);
|
||||||
|
|||||||
@@ -51,11 +51,11 @@ public class GameInterface extends JFrame {
|
|||||||
final JFrame frame = new JFrame();
|
final JFrame frame = new JFrame();
|
||||||
|
|
||||||
// Fullscreen testing: Remember not to use pack() when using fullscreen mode
|
// Fullscreen testing: Remember not to use pack() when using fullscreen mode
|
||||||
frame.setUndecorated(true);
|
// frame.setUndecorated(true);
|
||||||
frame.setResizable(false);
|
// frame.setResizable(false);
|
||||||
frame.setExtendedState(Frame.MAXIMIZED_BOTH);
|
// frame.setExtendedState(Frame.MAXIMIZED_BOTH);
|
||||||
frame.validate();
|
// frame.validate();
|
||||||
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(frame);
|
// GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(frame);
|
||||||
|
|
||||||
frame.setTitle("HeatUP!");
|
frame.setTitle("HeatUP!");
|
||||||
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
|
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||||
@@ -94,7 +94,7 @@ public class GameInterface extends JFrame {
|
|||||||
|
|
||||||
frame.add(outerPanel);
|
frame.add(outerPanel);
|
||||||
// Comment out for fullscreen
|
// Comment out for fullscreen
|
||||||
//frame.pack();
|
frame.pack();
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
frame.repaint();
|
frame.repaint();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user