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:
@@ -27,16 +27,16 @@ public class ImageLoader {
|
||||
imageFileName="src/de/heatup/resources/images/25x25_wall_orange_2.png";
|
||||
break;
|
||||
case 'u':
|
||||
imageFileName="src/de/heatup/resources/images/little_green_guy_up.png";
|
||||
imageFileName="src/de/heatup/resources/images/little_green_guy_verysmall.png";
|
||||
break;
|
||||
case 'd':
|
||||
imageFileName="src/de/heatup/resources/images/little_green_guy.png";
|
||||
imageFileName="src/de/heatup/resources/images/little_green_guy_verysmall.png";
|
||||
break;
|
||||
case 'l':
|
||||
imageFileName="src/de/heatup/resources/images/little_green_guy_left.png";
|
||||
imageFileName="src/de/heatup/resources/images/little_green_guy_verysmall.png";
|
||||
break;
|
||||
case 'r':
|
||||
imageFileName="src/de/heatup/resources/images/little_green_guy_right.png";
|
||||
imageFileName="src/de/heatup/resources/images/little_green_guy_verysmall.png";
|
||||
break;
|
||||
default:
|
||||
imageFileName="src/de/heatup/resources/images/dummy_image.png";
|
||||
|
||||
@@ -10,6 +10,8 @@ import java.io.IOException;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.JComponent;
|
||||
|
||||
import de.heatup.cfg.Config;
|
||||
|
||||
/*
|
||||
* Draft for static objects
|
||||
*/
|
||||
@@ -30,16 +32,19 @@ 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) {
|
||||
this(staticObjectType, location, 25, 25);
|
||||
this(staticObjectType, location, Config.singleTilePixels, Config.singleTilePixels);
|
||||
}
|
||||
|
||||
public void paintComponent(Graphics g) {
|
||||
@@ -51,9 +56,11 @@ public class StaticObject extends JComponent {
|
||||
}
|
||||
//g2d.rotate(0.2, 10, 10);
|
||||
|
||||
if ( doRescale ) {
|
||||
g2d.scale(rescaleFactorX, rescaleFactorY);
|
||||
}
|
||||
// TODO: Check if we can store a rescaled image in bf1???
|
||||
// if ( doRescale ) {
|
||||
// System.out.println("Hit: " + rescaleFactorX + " " + rescaleFactorY);
|
||||
// g2d.scale(rescaleFactorX, rescaleFactorY);
|
||||
// }
|
||||
|
||||
g2d.drawImage(bf1, 0, 0, this);
|
||||
g2d.finalize();
|
||||
@@ -67,24 +74,30 @@ public class StaticObject extends JComponent {
|
||||
this.bf1 = image;
|
||||
}
|
||||
|
||||
public void setRescale(double rescaleFactorX, double rescaleFactorY) {
|
||||
this.rescaleFactorX = rescaleFactorX;
|
||||
this.rescaleFactorY = rescaleFactorY;
|
||||
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 = (double)this.staticObjectWidth / (double)this.bf1.getWidth();
|
||||
this.rescaleFactorY = (double)this.staticObjectHeight / (double)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;
|
||||
}
|
||||
|
||||
// TODO: getter für höhe breite position
|
||||
|
||||
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 + "\tsH: " + this.staticObjectHeight + "\tsW: " + this.staticObjectWidth + "\tStaticObjectType: " + this.staticObjectType + "\tbW : " + this.bf1.getWidth() + "\tbH :" + this.bf1.getHeight();
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ public class logic {
|
||||
//System.out.println("x: " + dynObj.getX() + " y: " + dynObj.getY());
|
||||
//System.out.println("h: " + dynObj.getHeight() + " w: " + dynObj.getWidth());
|
||||
try {
|
||||
Thread.sleep(10);
|
||||
Thread.sleep(40);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
@@ -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(900);
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package de.heatup.ui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JProgressBar;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.border.LineBorder;
|
||||
|
||||
import de.heatup.ui.statusPanel.Score;
|
||||
import de.heatup.ui.statusPanel.Temperature;
|
||||
import de.heatup.ui.statusPanel.Timer;
|
||||
|
||||
|
||||
public class StatusPanelAdder{
|
||||
Temperature temp;
|
||||
Score score;
|
||||
Timer timer;
|
||||
|
||||
public int getTemp(){
|
||||
return temp.getTemp();
|
||||
}
|
||||
public int getScore(){
|
||||
return score.getScore();
|
||||
}
|
||||
public double getTime(){
|
||||
return timer.getTime();
|
||||
}
|
||||
|
||||
public static void createPanel(){
|
||||
JProgressBar tempbar= new JProgressBar(30,90);
|
||||
tempbar.setValue(45);
|
||||
//tempbar.setSize(new Dimension(200,50));
|
||||
|
||||
JLabel scoreLabel= new JLabel("new Score Label");
|
||||
scoreLabel.setBorder(new LineBorder(Color.BLACK, 2));
|
||||
//scoreLabel.setSize(new Dimension(100,50));
|
||||
|
||||
JLabel powerUpLabel = new JLabel(/*new ImageIcon("path_to_image.png")*/"powerUpLabel");
|
||||
powerUpLabel.setBorder(new LineBorder(Color.BLACK, 1));
|
||||
//powerUpLabel.setSize(new Dimension(200,50));
|
||||
|
||||
JLabel timeLabel = new JLabel();
|
||||
timeLabel.setBorder(new LineBorder(Color.BLACK, 2));
|
||||
timeLabel.setText("0");
|
||||
//timeLabel.setSize(new Dimension(300,24)); //Groesse,
|
||||
timeLabel.setHorizontalAlignment(SwingConstants.CENTER );
|
||||
|
||||
|
||||
|
||||
GameInterface.getStatusPanel().add(timeLabel);
|
||||
GameInterface.getStatusPanel().add(tempbar);
|
||||
GameInterface.getStatusPanel().add(scoreLabel);
|
||||
GameInterface.getStatusPanel().add(powerUpLabel);
|
||||
}
|
||||
private static void getStatusPanel(){
|
||||
GameInterface.getStatusPanel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package de.heatup.ui.statusPanel;
|
||||
|
||||
|
||||
public class Score {
|
||||
private int score;
|
||||
public Score(){
|
||||
score=0;
|
||||
}
|
||||
//returns score
|
||||
public int getScore(){
|
||||
return score;
|
||||
}
|
||||
//resets score
|
||||
public void resetScore(){
|
||||
score=0;
|
||||
}
|
||||
//raises score
|
||||
public void raiseScore(int additional){
|
||||
score+=additional;
|
||||
}
|
||||
//reduces score; when score<0, score=0;
|
||||
public void reduceScore(int reduce){
|
||||
score-=reduce;
|
||||
//when score less than 0
|
||||
if (score<0){
|
||||
score=0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package de.heatup.ui.statusPanel;
|
||||
|
||||
|
||||
public class Temperature {
|
||||
private int min;
|
||||
private int max;
|
||||
private int valtemp;
|
||||
|
||||
//ggf. f�r Schwierigkeitsgerade min und max zu ver�ndern und startwert!?
|
||||
public Temperature(int gmin, int gmax, int gtemp){
|
||||
this.min=gmin;
|
||||
this.max=gmax;
|
||||
this.valtemp=gtemp;
|
||||
}
|
||||
|
||||
//returns temp
|
||||
public int getTemp(){
|
||||
return valtemp;
|
||||
}
|
||||
/*
|
||||
* raiseTemp
|
||||
* return true, gameplay goes on
|
||||
* return false, heatup done
|
||||
*/
|
||||
public boolean raiseTemp(int additional){
|
||||
valtemp+=additional;
|
||||
if(valtemp>max){
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* reduceTemp
|
||||
* return true; gameplay goes on
|
||||
* return false; game over, temperature too low
|
||||
*/
|
||||
public boolean reduceTemp(int reduce){
|
||||
valtemp-=reduce;
|
||||
if (valtemp<min){
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package de.heatup.ui.statusPanel;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
public class Timer {
|
||||
|
||||
static double elapsedTime = 0L;
|
||||
public static void main(String[] args){
|
||||
double startTime = System.currentTimeMillis();
|
||||
|
||||
//1s = 1000ms
|
||||
while (elapsedTime <10000) {
|
||||
|
||||
elapsedTime = (new Date()).getTime() - startTime;
|
||||
System.out.println(elapsedTime);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public double getTime(){
|
||||
return elapsedTime;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user