package bomberman;
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import java.util.Random;public class Gamev1 extends JPanel implements Runnable
{
Random randomGenerator = new Random();
Thread mainthrd;
public JFrame myframe;
boolean running=true;
int width=400,height=400;
public static int ROW=20,COL=20;
/** relative path for files */
public static String RP = "./";
BomberMap map;
Gamev1(JFrame jf)
{
myframe=jf;
map=new BomberMap(this,ROW,COL,3,3);
mainthrd=new Thread(this);
try
{
mainthrd.start();
}catch(Exception e){ System.out.println(e);System.exit(0);}
setFocusable(true);
}
public void paintComponent(Graphics g)
{
super.paintComponent(g);
Graphics2D g2d=(Graphics2D)g;
g2d.setBackground(Color.yellow);
g2d.clearRect(0,0,width,height);
g2d.setColor(Color.green);
map.draw(g2d);
}
public void run()
{
while(true)
{
repaint();
try
{
Thread.sleep(100);
}
catch(Exception e){}
}
}public static void main(String []args)
{
JFrame window=new JFrame();
window.setTitle("Bomber Game v1");
window.setBackground(Color.BLUE);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.getContentPane().add(new Gamev1(window));
window.setSize(800,600);
window.setLocationRelativeTo(null);
window.setFocusable(true);
window.setVisible(true);
}}