-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlatform.java
85 lines (77 loc) · 1.81 KB
/
Platform.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
import java.awt.*;
import javax.swing.*;
import java.util.*;
import java.awt.event.*;
import java.awt.geom.Rectangle2D;
class Platform implements MouseMotionListener,MouseListener
{
private double x, y, width, height, max_width;
Board p;
private Cursor inv;
Thread t;
public Platform(double x,double y,double width,double height,double max_width,Board p)
{
this.x=x;
this.y=y ;
this.width=width;
this.height=height;
this.max_width= max_width;
this.p= p;
Toolkit tk=Toolkit.getDefaultToolkit();
Image img=tk.getImage("emptyImage.gif");
inv=tk.createCustomCursor(img,new Point(10,10),"invisi");
}
public Double getx()
{
return(x);
}
public Double gety()
{
return(y);
}
public Double getw()
{
return(width);
}
public Double geth()
{
return(height);
}
public void drawPlatform(Graphics g)
{
Graphics2D g2= (Graphics2D)g;
g2.setColor(new Color(209,211,209));
Rectangle2D r=new Rectangle2D.Double(x,y,width,height);
g2.fill(r);
}
public void mouseMoved(MouseEvent e)
{
p.setCursor(inv);
x=e.getPoint().getX()-(width/2);
p.repaint(0,(int)y,(int)max_width,(int)y);
}
public void mouseDragged(MouseEvent e)
{
x=e.getPoint().getX()-(width/2);
if(p.B.get(0).y<y-20)
p.B.push(new Bullet(e.getX(),(int)this.y,p.lev.Neut));
p.repaint(0,(int)y,(int)max_width,(int)y);
}
public void mousePressed(MouseEvent e)
{
p.B.push(new Bullet(e.getX(),(int)this.y,p.lev.Neut));
}
public void mouseClicked(MouseEvent e)
{
p.B.push(new Bullet(e.getX(),(int)this.y,p.lev.Neut));
}
public void mouseExited(MouseEvent e)
{
}
public void mouseEntered(MouseEvent e)
{
}
public void mouseReleased(MouseEvent e)
{
}
}