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 void setGamePanelWidth(int width) {
|
||||
// Wir wollen hier keine Reste!
|
||||
while (width % mapMaxTilesHeight != 0) {
|
||||
while (width % mapMaxTilesWidth != 0) {
|
||||
width--;
|
||||
}
|
||||
gamePanelWidth = width;
|
||||
updateSingleTilePixels();
|
||||
}
|
||||
private static void updateSingleTilePixels() {
|
||||
singleTilePixels = gamePanelWidth/mapMaxTilesHeight;
|
||||
singleTilePixels = gamePanelWidth/mapMaxTilesWidth;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,12 +30,15 @@ public class StaticObject extends JComponent {
|
||||
private 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.location = location;
|
||||
this.staticObjectWidth = staticObjectWidth;
|
||||
this.staticObjectHeight = staticObjectHeight;
|
||||
loadBufferedImage();
|
||||
setAutoBounds(location.x, location.y);
|
||||
autoRescale();
|
||||
//System.out.println(getDebugInfo());
|
||||
}
|
||||
|
||||
public StaticObject(char staticObjectType, Point location) {
|
||||
@@ -51,7 +54,9 @@ public class StaticObject extends JComponent {
|
||||
}
|
||||
//g2d.rotate(0.2, 10, 10);
|
||||
|
||||
// TODO: Check if we can store a rescaled image in bf1???
|
||||
if ( doRescale ) {
|
||||
//System.out.println("hit");
|
||||
g2d.scale(rescaleFactorX, rescaleFactorY);
|
||||
}
|
||||
|
||||
@@ -67,24 +72,40 @@ public class StaticObject extends JComponent {
|
||||
this.bf1 = image;
|
||||
}
|
||||
|
||||
public void setRescale(double rescaleFactorX, double rescaleFactorY) {
|
||||
this.rescaleFactorX = rescaleFactorX;
|
||||
this.rescaleFactorY = rescaleFactorY;
|
||||
this.doRescale = true;
|
||||
private void autoRescale() {
|
||||
// TODO: get original width and hight of bf1
|
||||
// Calculate factor new/original
|
||||
// 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() {
|
||||
this.rescaleFactorX = 0.0;
|
||||
this.rescaleFactorY = 0.0;
|
||||
this.doRescale = false;
|
||||
}
|
||||
// public void setRescale(double rescaleFactorX, double rescaleFactorY) {
|
||||
// this.rescaleFactorX = rescaleFactorX;
|
||||
// this.rescaleFactorY = rescaleFactorY;
|
||||
// this.doRescale = true;
|
||||
// }
|
||||
|
||||
// public void unsetRescale() {
|
||||
// this.rescaleFactorX = 0.0;
|
||||
// this.rescaleFactorY = 0.0;
|
||||
// this.doRescale = false;
|
||||
// }
|
||||
|
||||
public void setAutoBounds(int x, int y) {
|
||||
this.setBounds(x, y, this.bf1.getWidth(), this.bf1.getHeight());
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package de.heatup.testing;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
|
||||
import de.heatup.cfg.Config;
|
||||
import de.heatup.mapengine.MapEngine;
|
||||
import de.heatup.objects.DynamicObject;
|
||||
import de.heatup.objects.StaticObject;
|
||||
@@ -25,7 +26,7 @@ public class GameLoop {
|
||||
|
||||
//dynO3.setRescale(1.5,3.5);
|
||||
|
||||
|
||||
Config.setGamePanelWidth(850);
|
||||
MapEngine me = new MapEngine(1);
|
||||
for (StaticObject currentStaticObject : me.getAllMapObjects()) {
|
||||
GameInterface.getGamePanel().add(currentStaticObject);
|
||||
|
||||
@@ -51,11 +51,11 @@ public class GameInterface extends JFrame {
|
||||
final JFrame frame = new JFrame();
|
||||
|
||||
// Fullscreen testing: Remember not to use pack() when using fullscreen mode
|
||||
frame.setUndecorated(true);
|
||||
frame.setResizable(false);
|
||||
frame.setExtendedState(Frame.MAXIMIZED_BOTH);
|
||||
frame.validate();
|
||||
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(frame);
|
||||
// frame.setUndecorated(true);
|
||||
// frame.setResizable(false);
|
||||
// frame.setExtendedState(Frame.MAXIMIZED_BOTH);
|
||||
// frame.validate();
|
||||
// GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(frame);
|
||||
|
||||
frame.setTitle("HeatUP!");
|
||||
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||
@@ -94,7 +94,7 @@ public class GameInterface extends JFrame {
|
||||
|
||||
frame.add(outerPanel);
|
||||
// Comment out for fullscreen
|
||||
//frame.pack();
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
frame.repaint();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user