Commit ed3617c8 authored by Arnaud Guerquin's avatar Arnaud Guerquin

Merge branch 'master' of gitlab.crans.org:genie_logiciel_2015/the_dungeon_project

parents 7b72c26d 8414b73e
...@@ -2,26 +2,64 @@ package artificial_intelligence; ...@@ -2,26 +2,64 @@ package artificial_intelligence;
import java.util.ArrayList; import java.util.ArrayList;
import artificial_intelligence.AIEntities.AbstractEntity; import artificial_intelligence.AIEntities.*;
import artificial_intelligence.AIEntities.BasicEntity;
import core.gamestate.GameContent; import core.gamestate.GameContent;
import core.relayer.Relayer; import core.relayer.Relayer;
/** /**
* This class is used to stop all AI thread when the game finishes. * @author Guerquin Arnaud && Ramusat Yann
* @author Guerquin Arnaud
* *
* TODO replace this class by AI_Controler (more general). Thanks avoiding using this class. * This class allows to create a new entity of indicated type.
* This class provides a way to start or stop all the current working entities (for example when initializing and quitting a map).
* *
*/ */
public class AIControler { public class AIControler {
private static ArrayList<AbstractEntity> list=new ArrayList<>(); private static ArrayList<AbstractEntity> list=new ArrayList<>();
public static void add(GameContent gameContent,Relayer dmr){ /**
AbstractEntity ai=new BasicEntity(gameContent,dmr); * Create a new AI of indicated type given as context a gameContent and a relayer to contact.
* @param gameContent
* @param dmr
* @param type the behaviour of the AI to create
*/
public static void add(GameContent gameContent, Relayer dmr, EnumBehaviourType type) {
AbstractEntity ai = null;
switch(type) {
case Agressive:
ai = new AgressiveEntity(gameContent,dmr);
break;
case Basic:
ai = new BasicEntity(gameContent,dmr);
break;
case Defender:
ai = new DefenderEntity(gameContent,dmr);
break;
default:
System.out.println("Trying to instanciate unrecognized type of AI.");
break;
}
list.add(ai); list.add(ai);
} }
/**
* Return all the AIs active or created but not active.
* @return the list of AIs
*/
public static ArrayList<AbstractEntity> getList() {
return list;
}
/**
* In order to know how many AIs are created.
* @return the size of the list
*/
public static int getNumber() {
return list.size();
}
/**
* To use for example at the end of a map.
*/
public static void killAll(){ public static void killAll(){
for(AbstractEntity ai :list){ for(AbstractEntity ai :list){
ai.setEndThread(false); ai.setEndThread(false);
...@@ -29,6 +67,9 @@ public class AIControler { ...@@ -29,6 +67,9 @@ public class AIControler {
list.clear(); list.clear();
} }
/**
* To start all the AIs at the begining of the map and after init complete inialization.
*/
public static void startAll() { public static void startAll() {
for(AbstractEntity ai :list){ for(AbstractEntity ai :list){
ai.start(); ai.start();
......
package artificial_intelligence;
import artificial_intelligence.AIEntities.*;
import core.gamestate.GameContent;
import core.relayer.Relayer;
import java.util.ArrayList;
/**
* Created by Yann RAMUSAT on 30/12/15.
*
* This class allows to create a new entity of indicated type.
* This class provides a way to start or stop all the current working entities (for example when initializing and quitting a map).
*
* Note: A part of this code (killAll and startAll) is inspired by the previous class AIControler implemented by Arnaud Guerquin.
*/
public class AI_Controler {
/*** SINGLETON PART ***/
private static AI_Controler ourInstance = new AI_Controler();
public static AI_Controler getInstance() {
return ourInstance;
}
private AI_Controler() {
}
/** CONTROLER PART ***/
private ArrayList<AbstractEntity> list=new ArrayList<>();
public ArrayList<AbstractEntity> getList() {
return list;
}
public void killAll(){
for(AbstractEntity ai :list){
ai.setEndThread(false);
}
list.clear();
}
public void startAll() {
for(AbstractEntity ai :list){
ai.start();
}
}
/*** FACTORY PART ***/
public void add(GameContent gameContent, Relayer dmr, EnumBehaviourType type) {
AbstractEntity ai = null;
switch(type) {
case Agressive:
ai = new AgressiveEntity(gameContent,dmr);
break;
case Basic:
ai = new BasicEntity(gameContent,dmr);
break;
case Defender:
ai = new DefenderEntity(gameContent,dmr);
break;
default:
System.out.println("Trying to instanciate unrecognized type of AI.");
break;
}
list.add(ai);
}
public int getNumber() {
return list.size();
}
}
...@@ -4,15 +4,7 @@ import artificial_intelligence.AIEntities.AbstractEntity; ...@@ -4,15 +4,7 @@ import artificial_intelligence.AIEntities.AbstractEntity;
import artificial_intelligence.AIEntities.AgressiveEntity; import artificial_intelligence.AIEntities.AgressiveEntity;
import artificial_intelligence.AIEntities.BasicEntity; import artificial_intelligence.AIEntities.BasicEntity;
import artificial_intelligence.AIEntities.EnumBehaviourType; import artificial_intelligence.AIEntities.EnumBehaviourType;
import artificial_intelligence.AI_Controler; import artificial_intelligence.AIControler;
import core.gamestate.Character;
import core.gamestate.Entity;
import core.gamestate.GameState;
import core.relayer.Relayer;
import map_generation.map.SurfacesMapGeneration;
import map_generation.map.Map;
import map_generation.map.MapPoint;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -22,23 +14,23 @@ import static org.junit.Assert.*; ...@@ -22,23 +14,23 @@ import static org.junit.Assert.*;
/** /**
* Created by Yann RAMUSAT on 30/12/15. * Created by Yann RAMUSAT on 30/12/15.
* *
* This is the unit test class for the AI_Controler class. * This is the unit test class for the AIControler class.
*/ */
public class AI_ControlerTest { public class AIControlerTest {
@Test @Test
public void testadd() throws Exception { public void testadd() throws Exception {
AI_Controler.getInstance().add(null, null, EnumBehaviourType.Basic); AIControler.add(null, null, EnumBehaviourType.Basic);
assertEquals(1, AI_Controler.getInstance().getNumber()); assertEquals(1, AIControler.getNumber());
AI_Controler.getInstance().add(null, null, EnumBehaviourType.Agressive); AIControler.add(null, null, EnumBehaviourType.Agressive);
boolean obt = AI_Controler.getInstance().getList().get(1) instanceof AgressiveEntity; boolean obt = AIControler.getList().get(1) instanceof AgressiveEntity;
assertEquals(true, obt); assertEquals(true, obt);
} }
@Test @Test
public void testkillAll() throws Exception { public void testkillAll() throws Exception {
AI_Controler.getInstance().killAll(); AIControler.killAll();
assertEquals(0, AI_Controler.getInstance().getNumber()); assertEquals(0, AIControler.getNumber());
} }
} }
\ No newline at end of file
...@@ -14,7 +14,7 @@ import org.junit.runners.Suite; ...@@ -14,7 +14,7 @@ import org.junit.runners.Suite;
@RunWith(Suite.class) @RunWith(Suite.class)
@Suite.SuiteClasses({ @Suite.SuiteClasses({
AI_ControlerTest.class, AIControlerTest.class,
AITileComparatorTest.class AITileComparatorTest.class
}) })
public class AITests{} public class AITests{}
package graphics.graphical_utility; package graphics.graphical_utility;
import core.zone.Point;
import graphics.guiSkeleton.mapManagement.GraphicsMapPoint;
/** /**
* Created by etouss on 20/12/2015. * Created by etouss on 20/12/2015.
*/ */
...@@ -12,4 +15,29 @@ public final class GraphicalBridgeConfiguration { ...@@ -12,4 +15,29 @@ public final class GraphicalBridgeConfiguration {
public static final int TILE_SCALE=32; public static final int TILE_SCALE=32;
public static final int TILE_SIZE=16; public static final int TILE_SIZE=16;
/**
* Converts a distance expressed in the Core coordinate system to the same distance, expressed in the Graphics coordinate system
* @param distanceInCoreSystem
* @return
*/
public static final int core2Graphics(int distanceInCoreSystem) {
return ( (int) ((float) distanceInCoreSystem * (float) TILE_SCALE / (float) (Point.TileScale)));
}
//For checking the core2Graphics method
public static void main(String[] args){
System.out.println("DistanceConverterCheck: Input="+50+", Output="+ core2Graphics(50));
}
/**
* Convert the coordinates of a Point instance (defined in the core) to an instance of GraphicsMapPoint (with coordinates in the Swing system)
* @param x: the x coordinate of an instance of Point (IN THE CORE COORDINATE SYSTEM !)
* @param y: the y coordinate of the same instance of Point (IN THE CORE COORDINATE SYSTEM !)
* @return
*/
public static GraphicsMapPoint makeMapPointFromCoreCoordinates(int x, int y)
{
return new GraphicsMapPoint(core2Graphics(y), core2Graphics(x));
}
} }
package graphics.guiSkeleton.entityDisplayer; package graphics.guiSkeleton.entityDisplayer;
import core.gamestate.Being; import core.gamestate.Being;
import graphics.graphical_utility.GraphicalBridgeConfiguration;
import graphics.guiSkeleton.mapManagement.GraphicsMap; import graphics.guiSkeleton.mapManagement.GraphicsMap;
import graphics.guiSkeleton.mapManagement.GraphicsMapPoint; import graphics.guiSkeleton.mapManagement.GraphicsMapPoint;
import graphics.guiSkeleton.mapManagement.PositionedSprite; import graphics.guiSkeleton.mapManagement.PositionedSprite;
...@@ -37,7 +38,7 @@ public class HealthBarDisplayer { ...@@ -37,7 +38,7 @@ public class HealthBarDisplayer {
int hp = being.getHP(); int hp = being.getHP();
int maxHP = being.getMaxHP(); int maxHP = being.getMaxHP();
float healthRatio = ((float)hp)/maxHP; float healthRatio = ((float)hp)/maxHP;
GraphicsMapPoint beingPosition = graphicsMap.makeMapPointFromCoreCoordinates(being.getX(), being.getY()); GraphicsMapPoint beingPosition = GraphicalBridgeConfiguration.makeMapPointFromCoreCoordinates(being.getX(), being.getY());
//applying translation //applying translation
GraphicsMapPoint healthBarContainerTopLeft = beingPosition.translate(- assumedSpriteWidth/2, assumedSpriteHeight + yOffsetForHealthBarContainer); GraphicsMapPoint healthBarContainerTopLeft = beingPosition.translate(- assumedSpriteWidth/2, assumedSpriteHeight + yOffsetForHealthBarContainer);
......
...@@ -2,6 +2,7 @@ package graphics.guiSkeleton.entityDisplayer.entityDisplayerBank; ...@@ -2,6 +2,7 @@ package graphics.guiSkeleton.entityDisplayer.entityDisplayerBank;
import core.gamestate.Action; import core.gamestate.Action;
import core.gamestate.Entity; import core.gamestate.Entity;
import graphics.graphical_utility.GraphicalBridgeConfiguration;
import graphics.guiSkeleton.mapManagement.GraphicsMap; import graphics.guiSkeleton.mapManagement.GraphicsMap;
import graphics.guiSkeleton.entityDisplayer.EntityDisplayer; import graphics.guiSkeleton.entityDisplayer.EntityDisplayer;
import graphics.guiSkeleton.mapManagement.GraphicsMapPoint; import graphics.guiSkeleton.mapManagement.GraphicsMapPoint;
...@@ -44,7 +45,7 @@ public class ChatRoseEntityDisplayer extends EntityDisplayer { ...@@ -44,7 +45,7 @@ public class ChatRoseEntityDisplayer extends EntityDisplayer {
Sprite sprite = SpriteStorage.getInstance().getChatRose(); Sprite sprite = SpriteStorage.getInstance().getChatRose();
Entity entity = getAssociatedEntity(); Entity entity = getAssociatedEntity();
GraphicsMapPoint entityPositionGraphicsMapPoint = graphicsMap.makeMapPointFromCoreCoordinates(entity.getX(), entity.getY()); GraphicsMapPoint entityPositionGraphicsMapPoint = GraphicalBridgeConfiguration.makeMapPointFromCoreCoordinates(entity.getX(), entity.getY());
//applying translation //applying translation
GraphicsMapPoint spriteTopLeftGraphicsMapPoint = entityPositionGraphicsMapPoint.translate(- sprite_width/2, - sprite_height/2); GraphicsMapPoint spriteTopLeftGraphicsMapPoint = entityPositionGraphicsMapPoint.translate(- sprite_width/2, - sprite_height/2);
int direction = entity.getDirection().ordinal(); int direction = entity.getDirection().ordinal();
......
package graphics.guiSkeleton.entityDisplayer.entityDisplayerBank; package graphics.guiSkeleton.entityDisplayer.entityDisplayerBank;
import core.gamestate.Entity; import core.gamestate.Entity;
import graphics.graphical_utility.GraphicalBridgeConfiguration;
import graphics.guiSkeleton.mapManagement.GraphicsMap; import graphics.guiSkeleton.mapManagement.GraphicsMap;
import graphics.guiSkeleton.entityDisplayer.EntityDisplayer; import graphics.guiSkeleton.entityDisplayer.EntityDisplayer;
import graphics.guiSkeleton.mapManagement.GraphicsMapPoint; import graphics.guiSkeleton.mapManagement.GraphicsMapPoint;
...@@ -26,7 +27,7 @@ public class InvisibleEntityDisplayer extends EntityDisplayer { ...@@ -26,7 +27,7 @@ public class InvisibleEntityDisplayer extends EntityDisplayer {
public PositionedSprite getPositionedSprite(GraphicsMap graphicsMap) { public PositionedSprite getPositionedSprite(GraphicsMap graphicsMap) {
Sprite sprite = SpriteStorage.getInstance().getInvisible(); Sprite sprite = SpriteStorage.getInstance().getInvisible();
Entity entity = getAssociatedEntity(); Entity entity = getAssociatedEntity();
GraphicsMapPoint entityPositionGraphicsMapPoint = graphicsMap.makeMapPointFromCoreCoordinates(entity.getX(), entity.getY()); GraphicsMapPoint entityPositionGraphicsMapPoint = GraphicalBridgeConfiguration.makeMapPointFromCoreCoordinates(entity.getX(), entity.getY());
return PositionedSprite.PositionSprite(sprite, entityPositionGraphicsMapPoint); return PositionedSprite.PositionSprite(sprite, entityPositionGraphicsMapPoint);
} }
} }
...@@ -2,6 +2,7 @@ package graphics.guiSkeleton.entityDisplayer.entityDisplayerBank; ...@@ -2,6 +2,7 @@ package graphics.guiSkeleton.entityDisplayer.entityDisplayerBank;
import core.gamestate.Entity; import core.gamestate.Entity;
import core.gamestate.Action; import core.gamestate.Action;
import graphics.graphical_utility.GraphicalBridgeConfiguration;
import graphics.guiSkeleton.mapManagement.GraphicsMap; import graphics.guiSkeleton.mapManagement.GraphicsMap;
import graphics.guiSkeleton.entityDisplayer.EntityDisplayer; import graphics.guiSkeleton.entityDisplayer.EntityDisplayer;
import graphics.guiSkeleton.mapManagement.GraphicsMapPoint; import graphics.guiSkeleton.mapManagement.GraphicsMapPoint;
...@@ -41,7 +42,7 @@ public class RonflexEntityDisplayer extends EntityDisplayer { ...@@ -41,7 +42,7 @@ public class RonflexEntityDisplayer extends EntityDisplayer {
Sprite sprite = SpriteStorage.getInstance().getRonflex(); Sprite sprite = SpriteStorage.getInstance().getRonflex();
Entity entity = getAssociatedEntity(); Entity entity = getAssociatedEntity();
GraphicsMapPoint entityPositionGraphicsMapPoint = graphicsMap.makeMapPointFromCoreCoordinates(entity.getX(), entity.getY()); GraphicsMapPoint entityPositionGraphicsMapPoint = GraphicalBridgeConfiguration.makeMapPointFromCoreCoordinates(entity.getX(), entity.getY());
//applying translation //applying translation
GraphicsMapPoint spriteTopLeftGraphicsMapPoint = entityPositionGraphicsMapPoint.translate(- sprite_width/2, - sprite_height/2); GraphicsMapPoint spriteTopLeftGraphicsMapPoint = entityPositionGraphicsMapPoint.translate(- sprite_width/2, - sprite_height/2);
int direction = entity.getDirection().ordinal(); int direction = entity.getDirection().ordinal();
......
...@@ -12,6 +12,7 @@ import gameloop.DummyLocalGameLoop; ...@@ -12,6 +12,7 @@ import gameloop.DummyLocalGameLoop;
import gameloop.GameStarter; import gameloop.GameStarter;
import graphics.graphical_abstraction.panel.GamePanelAbstraction; import graphics.graphical_abstraction.panel.GamePanelAbstraction;
import graphics.graphical_abstraction.panel.GamePanelAbstractionController; import graphics.graphical_abstraction.panel.GamePanelAbstractionController;
import graphics.graphical_utility.GraphicalBridgeConfiguration;
import graphics.graphical_utility.coreProcesses.GameContentMapChangeListener; import graphics.graphical_utility.coreProcesses.GameContentMapChangeListener;
import graphics.guiSkeleton.*; import graphics.guiSkeleton.*;
import graphics.guiSkeleton.entityDisplayer.HealthBarDisplayer; import graphics.guiSkeleton.entityDisplayer.HealthBarDisplayer;
...@@ -85,7 +86,7 @@ public class GamePanel extends GUIPanel implements GameContentMapChangeListener, ...@@ -85,7 +86,7 @@ public class GamePanel extends GUIPanel implements GameContentMapChangeListener,
//Getting the map, creating a bufferedImage out of it and storing it //Getting the map, creating a bufferedImage out of it and storing it
GraphicsMap graphicsMap = MapDrawer.drawMap(gameContent.getMap()); GraphicsMap graphicsMap = MapDrawer.drawMap(gameContent.getMap());
GraphicsMapPoint initialTopLeftGraphicsMapPoint = graphicsMap.makeMapPointFromCoreCoordinates(followedRelayer.getCharacter().getX(), followedRelayer.getCharacter().getY()); GraphicsMapPoint initialTopLeftGraphicsMapPoint = GraphicalBridgeConfiguration.makeMapPointFromCoreCoordinates(followedRelayer.getCharacter().getX(), followedRelayer.getCharacter().getY());
visionBox = new VisionBox(initialTopLeftGraphicsMapPoint, getSize().width, getSize().height, graphicsMap); visionBox = new VisionBox(initialTopLeftGraphicsMapPoint, getSize().width, getSize().height, graphicsMap);
topLeftLabel = new JLabel("Press ESC to go back to main menu"); topLeftLabel = new JLabel("Press ESC to go back to main menu");
...@@ -162,7 +163,7 @@ public class GamePanel extends GUIPanel implements GameContentMapChangeListener, ...@@ -162,7 +163,7 @@ public class GamePanel extends GUIPanel implements GameContentMapChangeListener,
// System.out.println("coreEntityTopLeft "+processedEntity.getTopLeft().getPosX()+","+processedEntity.getTopLeft().getPosY()); // System.out.println("coreEntityTopLeft "+processedEntity.getTopLeft().getPosX()+","+processedEntity.getTopLeft().getPosY());
//Debug //Debug
// System.out.println("coreColBoxTopLeft "+collisionBox.getTopLeft().getPosX()+","+collisionBox.getTopLeft().getPosY()); // System.out.println("coreColBoxTopLeft "+collisionBox.getTopLeft().getPosX()+","+collisionBox.getTopLeft().getPosY());
GraphicsMapPoint graphicsTopLeft = visionBox.getGraphicsMap().makeMapPointFromCoreCoordinates(coreTopLeft.getPosX(), coreTopLeft.getPosY()); GraphicsMapPoint graphicsTopLeft = GraphicalBridgeConfiguration.makeMapPointFromCoreCoordinates(coreTopLeft.getPosX(), coreTopLeft.getPosY());
//Debug //Debug
// GraphicsMapPoint graphicsEntityTopLeft = visionBox.getGraphicsMap().makeMapPointFromCoreCoordinates(processedEntity.getTopLeft().getPosX(), processedEntity.getTopLeft().getPosY()); // GraphicsMapPoint graphicsEntityTopLeft = visionBox.getGraphicsMap().makeMapPointFromCoreCoordinates(processedEntity.getTopLeft().getPosX(), processedEntity.getTopLeft().getPosY());
//Debug //Debug
...@@ -175,11 +176,11 @@ public class GamePanel extends GUIPanel implements GameContentMapChangeListener, ...@@ -175,11 +176,11 @@ public class GamePanel extends GUIPanel implements GameContentMapChangeListener,
if(zone instanceof Rectangle){ if(zone instanceof Rectangle){
Rectangle rectColBox = (Rectangle) zone; Rectangle rectColBox = (Rectangle) zone;
//getWidth and getHeight may have to be swapped (these are method from the core, and I'm unsure about what their return mean in swing coordinate system) //getWidth and getHeight may have to be swapped (these are method from the core, and I'm unsure about what their return mean in swing coordinate system)
g.drawRect(gpmp.getX(), gpmp.getY(), DistanceConverter.core2Graphics(rectColBox.getWidth()), DistanceConverter.core2Graphics(rectColBox.getHeight())); g.drawRect(gpmp.getX(), gpmp.getY(), GraphicalBridgeConfiguration.core2Graphics(rectColBox.getWidth()), GraphicalBridgeConfiguration.core2Graphics(rectColBox.getHeight()));
} }
if(zone instanceof Circle){ if(zone instanceof Circle){
Circle circleColBox = (Circle) zone; Circle circleColBox = (Circle) zone;
g.drawOval(gpmp.getX(), gpmp.getY(), DistanceConverter.core2Graphics(2 * circleColBox.getRadius()), DistanceConverter.core2Graphics(2 * circleColBox.getRadius())); g.drawOval(gpmp.getX(), gpmp.getY(), GraphicalBridgeConfiguration.core2Graphics(2 * circleColBox.getRadius()), GraphicalBridgeConfiguration.core2Graphics(2 * circleColBox.getRadius()));
} }
} }
...@@ -193,7 +194,7 @@ public class GamePanel extends GUIPanel implements GameContentMapChangeListener, ...@@ -193,7 +194,7 @@ public class GamePanel extends GUIPanel implements GameContentMapChangeListener,
} }
/** Get the GraphicsMapPoint of the position of the entity followed by the gamePanel **/ /** Get the GraphicsMapPoint of the position of the entity followed by the gamePanel **/
GraphicsMapPoint followedEntityPositionGraphicsMapPoint = visionBox.getGraphicsMap().makeMapPointFromCoreCoordinates(followedRelayer.getCharacter().getX(), followedRelayer.getCharacter().getY()); GraphicsMapPoint followedEntityPositionGraphicsMapPoint = GraphicalBridgeConfiguration.makeMapPointFromCoreCoordinates(followedRelayer.getCharacter().getX(), followedRelayer.getCharacter().getY());
if (debugMapPoint) { if (debugMapPoint) {
System.out.println("followedEntityPositionGraphicsMapPoint:"); System.out.println("followedEntityPositionGraphicsMapPoint:");
followedEntityPositionGraphicsMapPoint.print(); followedEntityPositionGraphicsMapPoint.print();
...@@ -282,7 +283,7 @@ public class GamePanel extends GUIPanel implements GameContentMapChangeListener, ...@@ -282,7 +283,7 @@ public class GamePanel extends GUIPanel implements GameContentMapChangeListener,
@Override @Override
public void mapChange() { public void mapChange() {
GraphicsMap graphicsMap = MapDrawer.drawMap(DummyLocalGameLoop.getInstance().getContent().getMap()); GraphicsMap graphicsMap = MapDrawer.drawMap(DummyLocalGameLoop.getInstance().getContent().getMap());
GraphicsMapPoint initialTopLeftMapPoint = graphicsMap.makeMapPointFromCoreCoordinates(followedRelayer.getCharacter().getX(), followedRelayer.getCharacter().getY()); GraphicsMapPoint initialTopLeftMapPoint = GraphicalBridgeConfiguration.makeMapPointFromCoreCoordinates(followedRelayer.getCharacter().getX(), followedRelayer.getCharacter().getY());
visionBox = new VisionBox(initialTopLeftMapPoint, getSize().width, getSize().height, graphicsMap); visionBox = new VisionBox(initialTopLeftMapPoint, getSize().width, getSize().height, graphicsMap);
repaint(); repaint();
} }
......
...@@ -10,6 +10,7 @@ import gameloop.DummyLocalGameLoop; ...@@ -10,6 +10,7 @@ import gameloop.DummyLocalGameLoop;
import gameloop.GameStarter; import gameloop.GameStarter;
import graphics.graphical_abstraction.panel.GamePanelAbstraction; import graphics.graphical_abstraction.panel.GamePanelAbstraction;
import graphics.graphical_abstraction.panel.GamePanelAbstractionController; import graphics.graphical_abstraction.panel.GamePanelAbstractionController;
import graphics.graphical_utility.GraphicalBridgeConfiguration;
import graphics.graphical_utility.coreProcesses.GameContentMapChangeListener; import graphics.graphical_utility.coreProcesses.GameContentMapChangeListener;
import graphics.guiSkeleton.*; import graphics.guiSkeleton.*;
import graphics.guiSkeleton.entityDisplayer.HealthBarDisplayer; import graphics.guiSkeleton.entityDisplayer.HealthBarDisplayer;
...@@ -84,7 +85,7 @@ public class GamePanel2 extends GUIPanel implements GameContentMapChangeListener ...@@ -84,7 +85,7 @@ public class GamePanel2 extends GUIPanel implements GameContentMapChangeListener
//Getting the map, creating a bufferedImage out of it and storing it //Getting the map, creating a bufferedImage out of it and storing it
GraphicsMap graphicsMap = MapDrawer.drawMap(gameContent.getMap()); GraphicsMap graphicsMap = MapDrawer.drawMap(gameContent.getMap());
GraphicsMapPoint initialTopLeftGraphicsMapPoint = graphicsMap.makeMapPointFromCoreCoordinates(followedRelayer.getCharacter().getX(), followedRelayer.getCharacter().getY()); GraphicsMapPoint initialTopLeftGraphicsMapPoint = GraphicalBridgeConfiguration.makeMapPointFromCoreCoordinates(followedRelayer.getCharacter().getX(), followedRelayer.getCharacter().getY());
visionBox = new VisionBox(initialTopLeftGraphicsMapPoint, getSize().width, getSize().height, graphicsMap); visionBox = new VisionBox(initialTopLeftGraphicsMapPoint, getSize().width, getSize().height, graphicsMap);
topLeftLabel = new JLabel("Press ESC to go back to main menu"); topLeftLabel = new JLabel("Press ESC to go back to main menu");
...@@ -161,7 +162,7 @@ public class GamePanel2 extends GUIPanel implements GameContentMapChangeListener ...@@ -161,7 +162,7 @@ public class GamePanel2 extends GUIPanel implements GameContentMapChangeListener
// System.out.println("coreEntityTopLeft "+processedEntity.getTopLeft().getPosX()+","+processedEntity.getTopLeft().getPosY()); // System.out.println("coreEntityTopLeft "+processedEntity.getTopLeft().getPosX()+","+processedEntity.getTopLeft().getPosY());
//Debug //Debug
// System.out.println("coreColBoxTopLeft "+collisionBox.getTopLeft().getPosX()+","+collisionBox.getTopLeft().getPosY()); // System.out.println("coreColBoxTopLeft "+collisionBox.getTopLeft().getPosX()+","+collisionBox.getTopLeft().getPosY());
GraphicsMapPoint graphicsTopLeft = visionBox.getGraphicsMap().makeMapPointFromCoreCoordinates(coreTopLeft.getPosX(), coreTopLeft.getPosY()); GraphicsMapPoint graphicsTopLeft = GraphicalBridgeConfiguration.makeMapPointFromCoreCoordinates(coreTopLeft.getPosX(), coreTopLeft.getPosY());
//Debug //Debug
// GraphicsMapPoint graphicsEntityTopLeft = visionBox.getGraphicsMap().makeMapPointFromCoreCoordinates(processedEntity.getTopLeft().getPosX(), processedEntity.getTopLeft().getPosY()); // GraphicsMapPoint graphicsEntityTopLeft = visionBox.getGraphicsMap().makeMapPointFromCoreCoordinates(processedEntity.getTopLeft().getPosX(), processedEntity.getTopLeft().getPosY());
//Debug //Debug
...@@ -174,11 +175,11 @@ public class GamePanel2 extends GUIPanel implements GameContentMapChangeListener ...@@ -174,11 +175,11 @@ public class GamePanel2 extends GUIPanel implements GameContentMapChangeListener
if(zone instanceof Rectangle){ if(zone instanceof Rectangle){
Rectangle rectColBox = (Rectangle) zone; Rectangle rectColBox = (Rectangle) zone;
//getWidth and getHeight may have to be swapped (these are method from the core, and I'm unsure about what their return mean in swing coordinate system) //getWidth and getHeight may have to be swapped (these are method from the core, and I'm unsure about what their return mean in swing coordinate system)
g.drawRect(gpmp.getX(), gpmp.getY(), DistanceConverter.core2Graphics(rectColBox.getWidth()), DistanceConverter.core2Graphics(rectColBox.getHeight())); g.drawRect(gpmp.getX(), gpmp.getY(), GraphicalBridgeConfiguration.core2Graphics(rectColBox.getWidth()), GraphicalBridgeConfiguration.core2Graphics(rectColBox.getHeight()));
} }
if(zone instanceof Circle){ if(zone instanceof Circle){
Circle circleColBox = (Circle) zone; Circle circleColBox = (Circle) zone;
g.drawOval(gpmp.getX(), gpmp.getY(), DistanceConverter.core2Graphics(2 * circleColBox.getRadius()), DistanceConverter.core2Graphics(2 * circleColBox.getRadius())); g.drawOval(gpmp.getX(), gpmp.getY(), GraphicalBridgeConfiguration.core2Graphics(2 * circleColBox.getRadius()), GraphicalBridgeConfiguration.core2Graphics(2 * circleColBox.getRadius()));
} }
} }
...@@ -192,7 +193,7 @@ public class GamePanel2 extends GUIPanel implements GameContentMapChangeListener ...@@ -192,7 +193,7 @@ public class GamePanel2 extends GUIPanel implements GameContentMapChangeListener
} }
/** Get the GraphicsMapPoint of the position of the entity followed by the gamePanel **/ /** Get the GraphicsMapPoint of the position of the entity followed by the gamePanel **/
GraphicsMapPoint followedEntityPositionGraphicsMapPoint = visionBox.getGraphicsMap().makeMapPointFromCoreCoordinates(followedRelayer.getCharacter().getX(), followedRelayer.getCharacter().getY()); GraphicsMapPoint followedEntityPositionGraphicsMapPoint = GraphicalBridgeConfiguration.makeMapPointFromCoreCoordinates(followedRelayer.getCharacter().getX(), followedRelayer.getCharacter().getY());
if (debugMapPoint) { if (debugMapPoint) {
System.out.println("followedEntityPositionGraphicsMapPoint:"); System.out.println("followedEntityPositionGraphicsMapPoint:");
followedEntityPositionGraphicsMapPoint.print(); followedEntityPositionGraphicsMapPoint.print();
...@@ -274,7 +275,7 @@ public class GamePanel2 extends GUIPanel implements GameContentMapChangeListener ...@@ -274,7 +275,7 @@ public class GamePanel2 extends GUIPanel implements GameContentMapChangeListener
@Override @Override
public void mapChange() { public void mapChange() {
GraphicsMap graphicsMap = MapDrawer.drawMap(DummyLocalGameLoop.getInstance().getContent().getMap()); GraphicsMap graphicsMap = MapDrawer.drawMap(DummyLocalGameLoop.getInstance().getContent().getMap());
GraphicsMapPoint initialTopLeftMapPoint = graphicsMap.makeMapPointFromCoreCoordinates(followedRelayer.getCharacter().getX(), followedRelayer.getCharacter().getY()); GraphicsMapPoint initialTopLeftMapPoint = GraphicalBridgeConfiguration.makeMapPointFromCoreCoordinates(followedRelayer.getCharacter().getX(), followedRelayer.getCharacter().getY());
visionBox = new VisionBox(initialTopLeftMapPoint, getSize().width, getSize().height, graphicsMap); visionBox = new VisionBox(initialTopLeftMapPoint, getSize().width, getSize().height, graphicsMap);
repaint(); repaint();
} }
......
...@@ -45,14 +45,5 @@ public class GraphicsMap { ...@@ -45,14 +45,5 @@ public class GraphicsMap {
return Width * TileSprite.TileSpriteWidth(); return Width * TileSprite.TileSpriteWidth();
} }
/**
* Convert the coordinates of a Point instance (defined in the core) to an instance of GraphicsMapPoint (with coordinates in the Swing system)
* @param x: the x coordinate of an instance of Point (IN THE CORE COORDINATE SYSTEM !)
* @param y: the y coordinate of the same instance of Point (IN THE CORE COORDINATE SYSTEM !)
* @return
*/
public GraphicsMapPoint makeMapPointFromCoreCoordinates(int x, int y)
{
return new GraphicsMapPoint(y,x);
}
}