-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBlue.java
88 lines (76 loc) · 1.8 KB
/
Blue.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
package Aqua;
import java.util.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.URL;
import javax.sound.sampled.*;
public class Blue
{
int x, y, s;
Color c, d;
public Blue()
{
x = 900;
y = 405;
c = new Color(250,200,50);
d = new Color(250,230,100);
s = 5;
}
public void draw(Graphics2D g){
g.setColor(c);
g.fillRect(x,y,50,75);
g.setColor(d);
g.fillRect(x,y+20,50,35);
g.setColor(Color.black);
g.drawString("FISH",x+12,y+35);
g.drawString("FOOD",x+10,y+48);
}
public void right(){
if(x<950){
x+=s;
}
}
public void left(){
if(x>0){
x-=s;
}
}
public void up(){
if(y>0){
y-=s;
}
}
public void down(){
if(y<400){
y+=s;
}
}
public int getX(){
return x;
}
public int getY(){
return y;
}
public void change(int v){
if(v == 0){
c = new Color(250,200,50);
d = new Color(250,230,100);
}
if(v == 1){
c = new Color(200,50,250);
d = new Color(230,100,80);
}
if(v == 2){
c = new Color(50,250,200);
d = new Color(80,230,100);
}
}
public Rectangle getRectangle(){
return new Rectangle(x,y,50,75);
}
public Color getColor(){
return c;
}
}