Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Team3FinalProject/BodySeg.java
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
42 lines (39 sloc)
1.09 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.Graphics2D; | |
public class BodySeg extends Body | |
{ | |
private Body _nextSeg; | |
public BodySeg(int x, int y, GamePanel p){ | |
this(java.awt.Color.green, x, y, p); | |
} | |
public BodySeg(java.awt.Color c, int x, int y, GamePanel p){ | |
super(c, x, y, p); | |
} | |
public void grow(){ | |
super.move(); | |
} | |
public void move(){ | |
int oldXLoc, oldYLoc; | |
oldYLoc = (int) _bodySeg.getY(); | |
oldXLoc = (int) _bodySeg.getX(); | |
super.move(); | |
if(_nextSeg != null) _nextSeg.move(oldXLoc, oldYLoc); | |
} | |
public void move(int x, int y){ | |
int oldXLoc, oldYLoc; | |
oldYLoc = (int) _bodySeg.getY(); | |
oldXLoc = (int) _bodySeg.getX(); | |
_panel.checkShipHit(x, y); | |
setLocation(x, y); | |
if(_nextSeg != null) _nextSeg.move(oldXLoc, oldYLoc); | |
} | |
public void setNextSeg(Body aSegment){ | |
_nextSeg = aSegment; | |
} | |
public Body getNextSeg(){ | |
return _nextSeg; | |
} | |
public void fill(Graphics2D aBrush){ | |
super.fill(aBrush); | |
if(_nextSeg != null) _nextSeg.fill(aBrush); | |
} | |
} |