add a .xpm file as background / first TEST /
- add a special cat image in background - now ready for a pixel art phase ... - very quick&dirty implementation of xpm parser... - xpm generated with gimp using posterize. Thanks gimp !
This commit is contained in:
@@ -5,6 +5,7 @@ import org.artisanlogiciel.games.maze.solve.DirectionPosition;
|
||||
import org.artisanlogiciel.games.maze.solve.MazeResolutionListener;
|
||||
import org.artisanlogiciel.graphics.Drawing;
|
||||
import org.artisanlogiciel.graphics.DrawingLine;
|
||||
import org.artisanlogiciel.xpm.Xpm;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -36,6 +37,9 @@ public class MazeComponent
|
||||
int gX = -1;
|
||||
int gY = -1;
|
||||
|
||||
// use a background
|
||||
Xpm xpm = null;
|
||||
|
||||
Date lastDrag = null;
|
||||
// FIXME HARCDODED delay after which a draging to draw a continous line is ended, a new line will then start.
|
||||
long dragTimeout = 200;
|
||||
@@ -63,6 +67,11 @@ public class MazeComponent
|
||||
this.goal = goal;
|
||||
}
|
||||
}
|
||||
|
||||
public void setXpm(Xpm xpm)
|
||||
{
|
||||
this.xpm = xpm;
|
||||
}
|
||||
// for a given (x,y) pixel return cell position.
|
||||
// if rightmost position of view not (0,0) this is not working.
|
||||
Position getPosition(int x, int y) {
|
||||
@@ -319,18 +328,22 @@ public class MazeComponent
|
||||
int aX = pX;
|
||||
int aY = pY;
|
||||
|
||||
|
||||
|
||||
// draw background
|
||||
for (; pY < mY; pY++) {
|
||||
for (pX = 0; pX < mX; pX++) {
|
||||
walls = map.getWalls(pX, pY);
|
||||
g.setColor(colorMap.background);
|
||||
if ( xpm != null ) {
|
||||
int cX = ( pX < xpm.getWidth()) ? pX : xpm.getWidth() - 1;
|
||||
int cY = ( pY < xpm.getHeight()) ? pY : xpm.getHeight() - 1;
|
||||
g.setColor(xpm.getColor(cX,cY));
|
||||
}
|
||||
else {
|
||||
g.setColor(colorMap.background);
|
||||
}
|
||||
cp.drawBackground(g, pX, pY, walls);
|
||||
}
|
||||
}
|
||||
|
||||
pX = aX;
|
||||
pY = aY;
|
||||
|
||||
// draw all walls within clip bounds horiz first then lines
|
||||
|
||||
Reference in New Issue
Block a user