74 lines
2.3 KiB
Java
74 lines
2.3 KiB
Java
package MonorailHard;
|
|
|
|
import javax.swing.*;
|
|
import java.awt.*;
|
|
|
|
public class DrawningWheels {
|
|
private int WheelSz;
|
|
JPanel MonorailPanel;
|
|
private NumberType WheelsNumb;
|
|
private Color WheelColor, TireColor;
|
|
private int Width, Height;
|
|
public int CurX, CurY;
|
|
public int WheelSz(){
|
|
return WheelSz;
|
|
}
|
|
|
|
boolean Init(int width, int height, int curX, int curY, Color wheelColor, Color tireColor, JPanel monorailPanel){
|
|
Width = width;
|
|
Height = height;
|
|
CurX = curX;
|
|
CurY = curY;
|
|
WheelColor = wheelColor;
|
|
TireColor = tireColor;
|
|
WheelSz = Height - Height * 7 / 10;
|
|
MonorailPanel = monorailPanel;
|
|
return true;
|
|
}
|
|
|
|
public void ChangeWheelsNumb(int x){
|
|
if(x <= 2)
|
|
WheelsNumb = NumberType.Two;
|
|
if(x == 3)
|
|
WheelsNumb = NumberType.Three;
|
|
if(x >= 4)
|
|
WheelsNumb = NumberType.Four;
|
|
}
|
|
|
|
public NumberType WheelsNumb(){
|
|
return WheelsNumb;
|
|
}
|
|
|
|
public void DrawWheels(){
|
|
Graphics2D g2d = (Graphics2D)MonorailPanel.getGraphics();
|
|
g2d.setColor(WheelColor);
|
|
g2d.fillOval( CurX + Width / 10, CurY + Height / 10 * 7, WheelSz, WheelSz);
|
|
g2d.setColor(TireColor);
|
|
g2d.drawOval(CurX + Width / 10, CurY + Height / 10 * 7, WheelSz, WheelSz);
|
|
g2d.setColor(WheelColor);
|
|
g2d.fillOval(CurX + Width / 10 * 8, CurY + Height / 10 * 7, WheelSz, WheelSz);
|
|
g2d.setColor(TireColor);
|
|
g2d.drawOval(CurX + Width / 10 * 8, CurY + Height / 10 * 7, WheelSz, WheelSz);
|
|
|
|
//3 колеса
|
|
if (WheelsNumb == NumberType.Three || WheelsNumb == NumberType.Four)
|
|
{
|
|
g2d.setColor(WheelColor);
|
|
g2d.fillOval(CurX + Width / 10 * 6, CurY + Height / 10 * 7, WheelSz, WheelSz);
|
|
g2d.setColor(TireColor);
|
|
g2d.drawOval(CurX + Width / 10 * 6, CurY + Height / 10 * 7, WheelSz, WheelSz);
|
|
}
|
|
|
|
//4 колеса
|
|
if (WheelsNumb == NumberType.Four)
|
|
{
|
|
g2d.setColor(WheelColor);
|
|
g2d.fillOval(CurX + Width / 10 * 3, CurY + Height / 10 * 7, WheelSz, WheelSz);
|
|
g2d.setColor(TireColor);
|
|
g2d.drawOval(CurX + Width / 10 * 3, CurY + Height / 10 * 7, WheelSz, WheelSz);
|
|
}
|
|
}
|
|
|
|
|
|
}
|