-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFood.java
More file actions
56 lines (49 loc) · 1.3 KB
/
Food.java
File metadata and controls
56 lines (49 loc) · 1.3 KB
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
//Kaan Cinar && Bogachan Arslan && Onder Soydal && Sinan Karabocuoglu
//Food
//24.04.2018
import java.awt.*;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.geom.AffineTransform;
import java.awt.geom.PathIterator;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.io.File;
import java.io.IOException;
import java.util.*;
public class Food{
//attitudes
public int xpos;
public int ypos;
public Rectangle2D bor;
public boolean eaten;
public boolean powerUp;
//constructer
public Food(int x, int y){
xpos = x;
ypos = y;
eaten = false;
bor = new Rectangle2D.Double(xpos+23,ypos+23+34,10,10);
}
//methods
public int getX(){
return xpos;
}
public int getY(){
return ypos;
}
public Rectangle2D getBorderOfFood(){
return bor;
}
public void draw(Graphics g){
Graphics2D g2 = (Graphics2D) g;
if(!eaten) {
g2.setColor(Color.YELLOW);
g2.fillOval((int)bor.getBounds2D().getX(),(int)bor.getBounds2D().getY(),(int)bor.getBounds2D().getWidth(),(int)bor.getBounds2D().getHeight());
}
}
public void setPowerUp(){
powerUp = true;
bor = new Rectangle2D.Double(xpos+18,ypos+18+34,20,20);
}
}