-
Notifications
You must be signed in to change notification settings - Fork 0
/
app12.java
129 lines (104 loc) · 1.79 KB
/
app12.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
/*<applet code="app12" height="800" width="800">
</applet>
*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class app12 extends Applet implements MouseListener
{
int x1=100;
int flag1=0;
int t1=130;
int t2=130;
int t3=150;
int y=0;
String msg="SCORE";
int score=0;
boolean flag2=true;
public void init()
{
addMouseListener(this);
}
public void mouseClicked(MouseEvent me)
{
int xpos=me.getX();
int ypos=me.getY();
if(xpos>=0&&xpos<=100&&ypos>=350&&ypos<=450)
{
flag1=1;
}
}
public void mousePressed(MouseEvent me)
{
}
public void mouseEntered(MouseEvent me)
{
}
public void mouseExited(MouseEvent me)
{
}
public void mouseReleased(MouseEvent me)
{
}
public void paint(Graphics g)
{ g.setColor(Color.red);
g.fillRect(0,350,100,100);
g.setColor(Color.yellow);
g.fillRect(100,375,50,50);
g.setColor(Color.blue);
g.fillRect(x1,385,30,30);
int xpoints[] = {t1, t2, t3};
int ypoints[] = {385, 415, 400};
int npoints = 3;
g.fillPolygon(xpoints, ypoints, npoints);
g.drawString(msg+" = " + "" + score,10,10);
//BULLET FIRED
try {
//if(t3>=700&&t3<=780)
//{
// score=score+10;
//}
if(flag1==1&&x1==700)
{
flag1=0;
}
if(flag1==1)
{
x1++;
t1++;
t2++;
t3++;
}
if(flag1==0)
{
x1=100;
t1=130;
t2=130;
t3=150;
}
//MOVING BALL
g.fillOval(700,y,80,80);
if(flag2==false&&y!=0)
{
y--;
}
if(flag2==true&&y<720)
{
y++;
}
if(y==720)
{
flag2=false;
}
if (flag2==false&&y==0)
{
flag2=true;
}
Thread.sleep(5);
}
catch(Exception e)
{
}
repaint();
}
}