-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexpend.java
165 lines (142 loc) · 2.98 KB
/
expend.java
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
package test;
import java.awt.*;
import javax.swing.*;
public class expend extends JFrame
{
/**
*
*/
private static final long serialVersionUID = 1L;
int fps = 50;
int speed = 120;
int unit = 40;
int []sizes;
boolean []stats;
enum block_status_class {_static, _up, _down, _left, _right};
block_status_class [][]block_status;
int [][]status_number;
public static void main(String args[])
{
System.out.println("Expend: test");
System.out.println("Created by virtualize at "+System.currentTimeMillis());
System.out.println("");
new expend();
}
clock_class clock = new clock_class(this);
expend()
{
int tmp;
sizes = new int[speed];
stats = new boolean[speed];
for(int i = 0; i < speed; i++)
{
tmp = (int)(Math.cos((double)(i*Math.PI*2/speed))*unit);
if(tmp>0)
stats[i] = true;
else
stats[i] = false;
sizes[i] = (int)Math.abs(tmp);
}
this.setSize(1000, 700);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setResizable(false);
this.setVisible(true);
clock.start();
}
boolean started = false;
String status1 = "started.", status2 = "", status3 = "";
void showStatus(String msg)
{
status3 = status2;
status2 = status1;
status1 = msg;
}
long tmp2 = 0;
/*
Image iBuffer;
Graphics gBuffer;
public void update(Graphics g)
{
paint(g);
}
void draw()
{
if(started)
{
}
}
*/
public void paint(Graphics g)
{
started = true;
g.clearRect(0, 0, this.getWidth(), this.getHeight());
//g.setColor(new Color(255,(int)(128+clock.c%128),0));
/*
int tmp = Math.abs((int)(200.0*Math.sin((double)clock.c/speed)));
g.fillRect(50-tmp, 30, 2*tmp, 50);
g.setColor(new Color(0,(int)(128+clock.c%128),tmp));
g.fillRect(100, 200-tmp, 600, 2*tmp);
*/
int tmp = (int) (clock.c%speed);
for(int i = 1; i < 10; i++)
{
for(int j = 1; j < 10; j++)
{
if(stats[tmp])
g.setColor(Color.red);
else
g.setColor(Color.black);
//g.fillRect(50*i-sizes[tmp], 50*j, 2*sizes[tmp], 50+unit/2);
g.fillRect(60*i+10-sizes[tmp]/2, 60*j+10, sizes[tmp], unit);
}
}
if(clock.c/speed!=tmp2)
{
tmp2 = clock.c%10;
this.showStatus("Running "+tmp2);
}
g.setFont(new Font("dialog", 10, 10));
g.setXORMode(Color.darkGray);
g.drawString(status1, 10, this.getHeight()-10);
g.setXORMode(Color.gray);
g.drawString(status2, 10, this.getHeight()-25);
g.setXORMode(Color.lightGray);
g.drawString(status3, 10, this.getHeight()-40);
g.setPaintMode();
//repaint();
}
class clock_class implements Runnable
{
/**clock:
* This is the handler of repainting.
*/
Thread t;
long c;
expend ex;
clock_class(expend e)
{
ex = e;
t = new Thread(this);
c = 0;
}
public void run()
{
while(true)
{
try {
Thread.sleep(1000/fps);
} catch (InterruptedException e) {
e.printStackTrace();
}
c++;
//System.out.println("clock: "+c);
if(ex.started)
ex.repaint();
}
}
public void start()
{
t.start();
}
}
}