import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.util.Random;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.KeyStroke;
public class Main extends Applet implements Runnable
{
private static final long serialVersionUID = 1L;
public static JFrame mainFrame;
public static JPanel mainPanel;
public static Random random;
public static boolean isRunning = false;
public static String[] names = {"LootMine : Try Minecraft!", "LootMine : Try Terraria!", "LootMine : Try Team Fortress 2!", "LootMine : Try Garry's Mod!", "LootMine : How about that airline food?", "LootMine : Single player!", "LootMine : Indie games rock!", "LootMine : Celli are cool!"};
public static int mainFrameX = 1000;
public static int mainFrameY = 800;
public static int pixelSize = 5;
public static int pixelX = mainFrameX / pixelSize;
public static int pixelY = mainFrameY / pixelSize;
public static Image screen;
public static Level level;
public static Player player;
public static int sX = 0, sY = 0;
public Main()
{
setPreferredSize(new Dimension(mainFrameX, mainFrameY));
}
public static void main(String args[])
{
Main main = new Main();
JFrame mainFrame = new JFrame("MainFrame");
mainFrame.add(main);
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainFrame.setTitle(getRandom(names));
mainFrame.pack();
mainFrame.setVisible(true);
mainFrame.setSize(mainFrameX, mainFrameY);
mainFrame.setResizable(false);
mainFrame.setLocationRelativeTo(null);
//mainPanel = new JPanel();
//mainPanel.setPreferredSize(new Dimension(mainFrameX, mainFrameY));
//mainPanel.setBackground(new Color(0, 200, 200));
//mainPanel.setVisible(true);
//mainPanel.setIgnoreRepaint(true);
//mainFrame.getContentPane().add(mainPanel);
main.start();
}
public void start()
{
new Tile();
try
{
level = new Level();
} catch(Exception e)
{
System.out.println("Could not load level!");
}
isRunning = true;
new Thread(this).start();
}
public void stop()
{
isRunning = false;
}
public void render()
{
Graphics g = screen.getGraphics();
g.setColor(new Color(0, 200, 200));
g.fillRect(0, 0, pixelX, pixelY);
g = getGraphics();
g.drawImage(screen, 0, 0, mainFrameX, mainFrameY, 0, 0, pixelX, pixelY, null);
g.dispose();
level.render(g);
}
public static void tick()
{
}
public void run()
{
screen = createVolatileImage(pixelX, pixelY);
while(isRunning)
{
tick();
render();
try
{
Thread.sleep(5);
}catch(Exception e)
{
System.out.println("Tick error! Please restart.");
}
}
}
public static String getRandom(String[] par1StringArray)
{
random = new Random();
return names[random.nextInt(names.length)];
}
public static String getName(String name)
{
random = new Random();
return names[random.nextInt(1)];
}
}