|
|
@ -1,9 +1,9 @@ |
|
|
|
package Snake; |
|
|
|
|
|
|
|
import java.awt.Graphics; |
|
|
|
import java.awt.Point; |
|
|
|
import java.awt.*; |
|
|
|
|
|
|
|
public class AppleView implements Drawable{ |
|
|
|
public class AppleView implements Drawable |
|
|
|
{ |
|
|
|
|
|
|
|
private final Point position; |
|
|
|
private final int size; |
|
|
@ -16,8 +16,15 @@ public class AppleView implements Drawable{ |
|
|
|
this.size = size; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void draw(Graphics g) { |
|
|
|
public void setPosition(Point newPosition) |
|
|
|
{ |
|
|
|
position.setLocation(newPosition); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void draw(Graphics g) |
|
|
|
{ |
|
|
|
g.setColor(Color.RED); |
|
|
|
g.fillOval((int)position.getX()*size,(int)position.getY()*size, size, size); |
|
|
|
} |
|
|
|
} |