/* * NWPiece - the northwest corner piece * * by Adam Doppelt * http://www.cs.brown.edu/people/amd/ */ import java.awt.*; public class NWPiece extends Piece { static PieceType type_; static public void SetupStatics(Component c, Image image) { type_ = new PieceType(c); for (int loop = 0; loop < SLICES; ++loop) { double percent = (double)loop / (double)DIV_SLICES; if (percent < FIRST_PERCENT) { percent = percent / FIRST_PERCENT * FIRST_LINE; type_.x1_[loop] = PercentPixel(NEG_EDGE); type_.y1_[loop] = PercentPixel(percent); type_.x2_[loop] = PercentPixel(POS_EDGE); type_.y2_[loop] = PercentPixel(percent); type_.visible_[loop] = Math.round(percent * SIZE) < GOOD_PIXELS_A || Math.round(percent * SIZE) > GOOD_PIXELS_B; } else if (percent < FIRST_PERCENT + CIRCLE_PERCENT) { double angle = (1.0 + ((percent - FIRST_PERCENT) / CIRCLE_PERCENT) * 1.5) * Math.PI; type_.x1_[loop] = PercentPixel( CENTER + PIPE_WIDTH * (1.0 + 1.5 * Math.cos(angle))); type_.y1_[loop] = PercentPixel( CENTER + PIPE_WIDTH * (1.0 - 1.5 * Math.sin(angle))); type_.x2_[loop] = PercentPixel( CENTER + PIPE_WIDTH * (1.0 + 0.5 * Math.cos(angle))); type_.y2_[loop] = PercentPixel( CENTER + PIPE_WIDTH * (1.0 - 0.5 * Math.sin(angle))); type_.visible_[loop] = true; } else { type_.x1_[loop] = type_.y1_[SLICES - loop]; type_.y1_[loop] = type_.x1_[SLICES - loop]; type_.x2_[loop] = type_.y2_[SLICES - loop]; type_.y2_[loop] = type_.x2_[SLICES - loop]; type_.visible_[loop] = true; } } type_.red_ = false; type_.green_ = true; type_.blue_ = false; type_.legalDirections_ = SOUTH + EAST; type_.flipDirections_ = EAST; if (image == null) type_.GenerateImage(); else type_.stamp_ = image; } public NWPiece() { super(type_); } public int Twist(int direction) { if (oldDirection_ == SOUTH) return WEST; else return NORTH; } }