1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
import java.awt.*;
import javax.swing.*;
import java.util.*;
import java.io.File;
/***********************
* Class implementation *
******************************************************************************/
public class MapDrawer extends JPanel {
private int width = 0;
private int height = 0;
private Image mapImage = null;
private String timeValue = "Time: 00:00";
private int[] pointsX1 = {0,0,0,0};
private int[] pointsY1 = {0,0,0,0};
private int[] pointsX2 = {0,0,0,0};
private int[] pointsY2 = {0,0,0,0};
private Hashtable<Object,Object> drawableObjects = null;
//== CONSTRUCTORS & DESTRUCTORS =========================================//
public MapDrawer(String mapFile) {
LoadImage(mapFile);
drawableObjects = new Hashtable<Object,Object>();
this.repaint();
}
public void updateEnemy(String owner, int x, int y, String name) {
try
{
DrawableEnemy tmpObject = (DrawableEnemy) drawableObjects.get(owner);
JOptionPane.showMessageDialog(null, "coucou1");
DrawableEnemy enemy = new DrawableEnemy(this, x, y, name);
JOptionPane.showMessageDialog(null, "coucou2");
if (tmpObject == null)
{
drawableObjects.put(owner, enemy);
}
else
tmpObject.updateObject(x, y, name);
}catch(Exception ex){JOptionPane.showMessageDialog(null, ex.toString());}
}
} |