Logging erweiterungen

This commit is contained in:
andreas
2014-11-07 10:43:15 +01:00
parent c0794efa20
commit 4796cd4a0f
4 changed files with 15 additions and 7 deletions
@@ -1,5 +1,6 @@
package de.heatup.mapengine; package de.heatup.mapengine;
import de.heatup.logging.Logger;
import de.heatup.testing.Player; import de.heatup.testing.Player;
public class CollisionHandler { public class CollisionHandler {
@@ -13,22 +14,22 @@ public class CollisionHandler {
switch (d) { switch (d) {
case 'l': case 'l':
if (MapGrid.getGridCell(movingObject.getGridLocation().x-1, movingObject.getGridLocation().y).isPath() && MapGrid.getGridCell(movingObject.getGridLocation().x-1, movingObject.getGridLocation().y).isTrigger()) { 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(); return MapGrid.getGridCell(movingObject.getGridLocation().x-1, movingObject.getGridLocation().y).isPath();
case 'r': case 'r':
if (MapGrid.getGridCell(movingObject.getGridLocation().x+1, movingObject.getGridLocation().y).isPath() && MapGrid.getGridCell(movingObject.getGridLocation().x+1, movingObject.getGridLocation().y).isTrigger()) { 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(); return MapGrid.getGridCell(movingObject.getGridLocation().x+1, movingObject.getGridLocation().y).isPath();
case 'd': case 'd':
if (MapGrid.getGridCell(movingObject.getGridLocation().x, movingObject.getGridLocation().y+1).isPath() && MapGrid.getGridCell(movingObject.getGridLocation().x, movingObject.getGridLocation().y+1).isTrigger()) { 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(); return MapGrid.getGridCell(movingObject.getGridLocation().x, movingObject.getGridLocation().y+1).isPath();
case 'u': case 'u':
if (MapGrid.getGridCell(movingObject.getGridLocation().x, movingObject.getGridLocation().y-1).isPath() && MapGrid.getGridCell(movingObject.getGridLocation().x, movingObject.getGridLocation().y-1).isTrigger()) { 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(); return MapGrid.getGridCell(movingObject.getGridLocation().x, movingObject.getGridLocation().y-1).isPath();
default: default:
+6 -1
View File
@@ -4,9 +4,11 @@ import java.awt.BorderLayout;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.GridLayout; import java.awt.GridLayout;
import java.awt.Point; import java.awt.Point;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JPanel; import javax.swing.JPanel;
import de.heatup.logging.Logger;
import de.heatup.mapengine.MapEngine; import de.heatup.mapengine.MapEngine;
import de.heatup.mapengine.SpawnAssistant; import de.heatup.mapengine.SpawnAssistant;
import de.heatup.objects.StaticObject; import de.heatup.objects.StaticObject;
@@ -37,6 +39,9 @@ public class GameLoopD extends JFrame implements Runnable {
public static void main(String[] args) { public static void main(String[] args) {
// Logging ausgabe auf Console aktivieren bzw. deaktivieren.
Logger.enableLogging();
/* /*
* hier drin bauen wir unser ui zusammen. * hier drin bauen wir unser ui zusammen.
*/ */
@@ -188,7 +193,7 @@ public class GameLoopD extends JFrame implements Runnable {
if (System.currentTimeMillis() - timer > 1000) { if (System.currentTimeMillis() - timer > 1000) {
timer += 1000; timer += 1000;
System.out.println(updates +" Ticks, fps " + frames); Logger.write(updates +" Ticks, fps " + frames);
updates = 0; updates = 0;
frames = 0; frames = 0;
} }
+2 -1
View File
@@ -7,6 +7,7 @@ import java.util.Random;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import de.heatup.cfg.Config; import de.heatup.cfg.Config;
import de.heatup.logging.Logger;
import de.heatup.mapengine.MapGrid; import de.heatup.mapengine.MapGrid;
public class Opponent extends Player { 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 // Blockade auflösen, gehe doch in die Richtung aus man gekommen ist
if ( this.blocked ) { if ( this.blocked ) {
System.out.println("Warning: Block detected!"); Logger.write("Warning: Block detected!");
this.i *= -1; this.i *= -1;
this.blocked = false; this.blocked = false;
this.blockedCounter = 0; this.blockedCounter = 0;
+2 -1
View File
@@ -13,6 +13,7 @@ import javax.imageio.ImageIO;
import javax.swing.JComponent; import javax.swing.JComponent;
import de.heatup.cfg.Config; import de.heatup.cfg.Config;
import de.heatup.logging.Logger;
public class Player extends JComponent { public class Player extends JComponent {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -116,7 +117,7 @@ public class Player extends JComponent {
if (stepCounter <= 0) { if (stepCounter <= 0) {
stepCounter = 25; stepCounter = 25;
//debug //debug
System.out.println("on grid - x: "+getGridLocation().x + " y: "+getGridLocation().y); Logger.write("on grid - x: "+getGridLocation().x + " y: "+getGridLocation().y);
} }
} }
startMove = false; startMove = false;