/* LABY - (c) 2001 Rémi Peyronnet */ import java.awt.*; import java.applet.*; import java.util.Random; /** * A good game.
*
* @version 0.01, 19/10/2001
* @author Rémi Peyronnet
*/
public class laby extends Applet {
// Exceptions
class Exception_NoMoreCase extends Exception {};
class Exception_NoFoundCase extends Exception {};
// These vars describe the size of the panel.
final static short xmaxdef = 50;
final static short ymaxdef = 30;
final static boolean updt = true;
final static boolean dbg = false;
int xmax, ymax;
// Physical size of the panel
Dimension d;
int dx, dy, xshift, yshift;
// Directions
final static short dir[]= {0,1,1,0,0,-1,-1,0};
// Attributes
final static short murX = 1;
final static short murY = 2;
final static short fait = 4;
final static short bord = 8;
// Laby Data
short laby[][];
Random random;
// This method is called when it is an applet
public void init()
{
System.out.print("Laby - 2001 RP.\n");
try { xmax=Integer.parseInt(getParameter("xmax")); } catch (Exception e) { xmax = xmaxdef; }
try { ymax=Integer.parseInt(getParameter("ymax")); } catch (Exception e) { ymax = ymaxdef; }
System.out.print(" * Xmax = "+xmax+"\n");
System.out.print(" * Ymax = "+ymax+"\n");
d = getSize();
dx = (int)Math.floor(d.width / (xmax+1));
dy = (int)Math.floor(d.height / (ymax+1));
xshift = (d.width - xmax*dx)/2;
yshift = (d.height - ymax*dy)/2;
init_laby();
repaint();
}
public void start()
{
gen_laby();
repaint();
}
public void init_laby()
{
laby = new short[ymax+2][xmax+2];
// Fill the laby with walls
for (int i=0;i