From 4796cd4a0f2ad586f4da3373e2540cc72e5579c8 Mon Sep 17 00:00:00 2001 From: andreas Date: Fri, 7 Nov 2014 10:43:15 +0100 Subject: [PATCH] Logging erweiterungen --- HeatUp/src/de/heatup/mapengine/CollisionHandler.java | 9 +++++---- HeatUp/src/de/heatup/testing/GameLoopD.java | 7 ++++++- HeatUp/src/de/heatup/testing/Opponent.java | 3 ++- HeatUp/src/de/heatup/testing/Player.java | 3 ++- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/HeatUp/src/de/heatup/mapengine/CollisionHandler.java b/HeatUp/src/de/heatup/mapengine/CollisionHandler.java index 13ffe3b..32a4e98 100644 --- a/HeatUp/src/de/heatup/mapengine/CollisionHandler.java +++ b/HeatUp/src/de/heatup/mapengine/CollisionHandler.java @@ -1,5 +1,6 @@ package de.heatup.mapengine; +import de.heatup.logging.Logger; import de.heatup.testing.Player; public class CollisionHandler { @@ -13,22 +14,22 @@ public class CollisionHandler { switch (d) { case 'l': if (MapGrid.getGridCell(movingObject.getGridLocation().x-1, movingObject.getGridLocation().y).isPath() && MapGrid.getGridCell(movingObject.getGridLocation().x-1, movingObject.getGridLocation().y).isTrigger()) { - System.out.println("Collision with trigger of hardware ID: " + MapGrid.getGridCell(movingObject.getGridLocation().x-1, movingObject.getGridLocation().y).getCorrespondingHardwareToTrigger()); + Logger.write("Collision with trigger of hardware ID: " + MapGrid.getGridCell(movingObject.getGridLocation().x-1, movingObject.getGridLocation().y).getCorrespondingHardwareToTrigger()); } return MapGrid.getGridCell(movingObject.getGridLocation().x-1, movingObject.getGridLocation().y).isPath(); case 'r': if (MapGrid.getGridCell(movingObject.getGridLocation().x+1, movingObject.getGridLocation().y).isPath() && MapGrid.getGridCell(movingObject.getGridLocation().x+1, movingObject.getGridLocation().y).isTrigger()) { - System.out.println("Collision with trigger of hardware ID: " + MapGrid.getGridCell(movingObject.getGridLocation().x+1, movingObject.getGridLocation().y).getCorrespondingHardwareToTrigger()); + Logger.write("Collision with trigger of hardware ID: " + MapGrid.getGridCell(movingObject.getGridLocation().x+1, movingObject.getGridLocation().y).getCorrespondingHardwareToTrigger()); } return MapGrid.getGridCell(movingObject.getGridLocation().x+1, movingObject.getGridLocation().y).isPath(); case 'd': if (MapGrid.getGridCell(movingObject.getGridLocation().x, movingObject.getGridLocation().y+1).isPath() && MapGrid.getGridCell(movingObject.getGridLocation().x, movingObject.getGridLocation().y+1).isTrigger()) { - System.out.println("Collision with trigger of hardware ID: " + MapGrid.getGridCell(movingObject.getGridLocation().x, movingObject.getGridLocation().y+1).getCorrespondingHardwareToTrigger()); + Logger.write("Collision with trigger of hardware ID: " + MapGrid.getGridCell(movingObject.getGridLocation().x, movingObject.getGridLocation().y+1).getCorrespondingHardwareToTrigger()); } return MapGrid.getGridCell(movingObject.getGridLocation().x, movingObject.getGridLocation().y+1).isPath(); case 'u': if (MapGrid.getGridCell(movingObject.getGridLocation().x, movingObject.getGridLocation().y-1).isPath() && MapGrid.getGridCell(movingObject.getGridLocation().x, movingObject.getGridLocation().y-1).isTrigger()) { - System.out.println("Collision with trigger of hardware ID: " + MapGrid.getGridCell(movingObject.getGridLocation().x, movingObject.getGridLocation().y-1).getCorrespondingHardwareToTrigger()); + Logger.write("Collision with trigger of hardware ID: " + MapGrid.getGridCell(movingObject.getGridLocation().x, movingObject.getGridLocation().y-1).getCorrespondingHardwareToTrigger()); } return MapGrid.getGridCell(movingObject.getGridLocation().x, movingObject.getGridLocation().y-1).isPath(); default: diff --git a/HeatUp/src/de/heatup/testing/GameLoopD.java b/HeatUp/src/de/heatup/testing/GameLoopD.java index f5f0c42..6e9c9c4 100644 --- a/HeatUp/src/de/heatup/testing/GameLoopD.java +++ b/HeatUp/src/de/heatup/testing/GameLoopD.java @@ -4,9 +4,11 @@ import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.GridLayout; import java.awt.Point; + import javax.swing.JFrame; import javax.swing.JPanel; +import de.heatup.logging.Logger; import de.heatup.mapengine.MapEngine; import de.heatup.mapengine.SpawnAssistant; import de.heatup.objects.StaticObject; @@ -37,6 +39,9 @@ public class GameLoopD extends JFrame implements Runnable { public static void main(String[] args) { + // Logging ausgabe auf Console aktivieren bzw. deaktivieren. + Logger.enableLogging(); + /* * hier drin bauen wir unser ui zusammen. */ @@ -188,7 +193,7 @@ public class GameLoopD extends JFrame implements Runnable { if (System.currentTimeMillis() - timer > 1000) { timer += 1000; - System.out.println(updates +" Ticks, fps " + frames); + Logger.write(updates +" Ticks, fps " + frames); updates = 0; frames = 0; } diff --git a/HeatUp/src/de/heatup/testing/Opponent.java b/HeatUp/src/de/heatup/testing/Opponent.java index 807c20c..4e5498b 100644 --- a/HeatUp/src/de/heatup/testing/Opponent.java +++ b/HeatUp/src/de/heatup/testing/Opponent.java @@ -7,6 +7,7 @@ import java.util.Random; import javax.imageio.ImageIO; import de.heatup.cfg.Config; +import de.heatup.logging.Logger; import de.heatup.mapengine.MapGrid; public class Opponent extends Player { @@ -61,7 +62,7 @@ public class Opponent extends Player { // Blockade auflösen, gehe doch in die Richtung aus man gekommen ist if ( this.blocked ) { - System.out.println("Warning: Block detected!"); + Logger.write("Warning: Block detected!"); this.i *= -1; this.blocked = false; this.blockedCounter = 0; diff --git a/HeatUp/src/de/heatup/testing/Player.java b/HeatUp/src/de/heatup/testing/Player.java index 7bd94d7..27667bf 100644 --- a/HeatUp/src/de/heatup/testing/Player.java +++ b/HeatUp/src/de/heatup/testing/Player.java @@ -13,6 +13,7 @@ import javax.imageio.ImageIO; import javax.swing.JComponent; import de.heatup.cfg.Config; +import de.heatup.logging.Logger; public class Player extends JComponent { private static final long serialVersionUID = 1L; @@ -116,7 +117,7 @@ public class Player extends JComponent { if (stepCounter <= 0) { stepCounter = 25; //debug - System.out.println("on grid - x: "+getGridLocation().x + " y: "+getGridLocation().y); + Logger.write("on grid - x: "+getGridLocation().x + " y: "+getGridLocation().y); } } startMove = false;