-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWindow.java
More file actions
72 lines (61 loc) · 1.58 KB
/
Copy pathWindow.java
File metadata and controls
72 lines (61 loc) · 1.58 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import javax.swing.*;
import java.awt.*;
import java.io.*;
import java.awt.event.*;
import javax.imageio.ImageIO;
import java.util.Scanner;
public class Window extends JFrame
{
State state = new State();
Controller control = new Controller();
JPanel panel;
Timer timer = new Timer(30, new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
panel.setSize(state.width, state.height);
panel.repaint();
state.update();
}
});
public void init(int p_width, int p_height, int p_density) throws IOException
{
setTitle("Zuna RTS");
setSize(p_width, p_height);
state.width = p_width;
state.height = p_height;
state.density = p_density;
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setPreferredSize(new java.awt.Dimension(p_width, p_height));
//setMinimumSize(new java.awt.Dimension(1600, 1200));
setMaximumSize(new java.awt.Dimension(p_width, p_height));
setVisible(true);
addKeyListener(control);
//
// load images
//
state.line = ImageIO.read(new File("Line.png"));
state.bg = ImageIO.read(new File("Background.jpg"));
int x_count = p_width/p_density;
int y_count = p_height/p_density;
state.x_count = x_count;
state.y_count = y_count;
CostField field = new CostField();
field.density = p_density;
state.cost = field;
panel = new DrawPanel(x_count, y_count, p_density);
add(panel);
state.started = true;
//state.update();
panel.setSize(state.width, state.height);
panel.repaint();
try{
Thread.sleep(1000);
}
catch(Exception e)
{
}
timer.start();
}
}