done
This commit is contained in:
parent
8cf1211532
commit
891232e03c
@ -56,7 +56,7 @@ namespace PIbd_22_Kalyshev_Y_V_MotorBoat_Base
|
||||
/// <param name="height">Высота картинки</param>
|
||||
public void SetPosition(int x, int y, int width, int height)
|
||||
{
|
||||
if (x <= width || y <= height || _boatWidth <= width || _boatHeight <= height)
|
||||
if (x + _boatWidth <= width && y + _boatHeight <= height && x > 0 && y > 0)
|
||||
{
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
@ -120,7 +120,6 @@ namespace PIbd_22_Kalyshev_Y_V_MotorBoat_Base
|
||||
Pen pen = new(Color.Black, 3);
|
||||
Brush br = new SolidBrush(Boat?.BodyColor ?? Color.Black);
|
||||
Brush brBrown = new SolidBrush(Color.Brown);
|
||||
|
||||
// Внешняя часть лодки
|
||||
g.DrawLine(pen, _startPosX, _startPosY, _startPosX + 120, _startPosY + 0);
|
||||
g.DrawLine(pen, _startPosX + 120, _startPosY, _startPosX + 170, _startPosY + 30);
|
||||
|
@ -15,7 +15,7 @@ namespace PIbd_22_Kalyshev_Y_V_MotorBoat_Base
|
||||
public void Init(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
Random rnd = new();
|
||||
Speed = speed <= 0 ? rnd.Next(10, 80) : speed;
|
||||
Speed = speed <= 0 ? rnd.Next(5, 30) : speed;
|
||||
Weight = weight <= 0 ? rnd.Next(30, 100) : weight;
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
|
@ -49,9 +49,9 @@
|
||||
this.toolStripStatusLabelSpeed,
|
||||
this.toolStripStatusLabelWeight,
|
||||
this.toolStripStatusLabelBodyColor});
|
||||
this.statusStrip1.Location = new System.Drawing.Point(0, 424);
|
||||
this.statusStrip1.Location = new System.Drawing.Point(0, 427);
|
||||
this.statusStrip1.Name = "statusStrip1";
|
||||
this.statusStrip1.Size = new System.Drawing.Size(800, 26);
|
||||
this.statusStrip1.Size = new System.Drawing.Size(882, 26);
|
||||
this.statusStrip1.TabIndex = 0;
|
||||
this.statusStrip1.Text = "statusStrip1";
|
||||
//
|
||||
@ -79,15 +79,17 @@
|
||||
this.pictureBoxBoat.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBoxBoat.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBoxBoat.Name = "pictureBoxBoat";
|
||||
this.pictureBoxBoat.Size = new System.Drawing.Size(800, 424);
|
||||
this.pictureBoxBoat.Size = new System.Drawing.Size(882, 427);
|
||||
this.pictureBoxBoat.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||
this.pictureBoxBoat.TabIndex = 1;
|
||||
this.pictureBoxBoat.TabStop = false;
|
||||
this.pictureBoxBoat.SizeChanged += new System.EventHandler(this.PictureBoxBoat_Resize);
|
||||
this.pictureBoxBoat.Resize += new System.EventHandler(this.PictureBoxBoat_Resize);
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.buttonCreate.Location = new System.Drawing.Point(12, 382);
|
||||
this.buttonCreate.Location = new System.Drawing.Point(12, 385);
|
||||
this.buttonCreate.Name = "buttonCreate";
|
||||
this.buttonCreate.Size = new System.Drawing.Size(94, 29);
|
||||
this.buttonCreate.TabIndex = 2;
|
||||
@ -100,7 +102,7 @@
|
||||
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonRight.BackgroundImage = global::PIbd_22_Kalyshev_Y_V_MotorBoat_Base.Properties.Resources.right;
|
||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonRight.Location = new System.Drawing.Point(738, 371);
|
||||
this.buttonRight.Location = new System.Drawing.Point(820, 374);
|
||||
this.buttonRight.Name = "buttonRight";
|
||||
this.buttonRight.Size = new System.Drawing.Size(40, 40);
|
||||
this.buttonRight.TabIndex = 3;
|
||||
@ -112,7 +114,7 @@
|
||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonLeft.BackgroundImage = global::PIbd_22_Kalyshev_Y_V_MotorBoat_Base.Properties.Resources.left;
|
||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonLeft.Location = new System.Drawing.Point(646, 371);
|
||||
this.buttonLeft.Location = new System.Drawing.Point(728, 374);
|
||||
this.buttonLeft.Name = "buttonLeft";
|
||||
this.buttonLeft.Size = new System.Drawing.Size(40, 40);
|
||||
this.buttonLeft.TabIndex = 4;
|
||||
@ -124,7 +126,7 @@
|
||||
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonUp.BackgroundImage = global::PIbd_22_Kalyshev_Y_V_MotorBoat_Base.Properties.Resources.up;
|
||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonUp.Location = new System.Drawing.Point(692, 325);
|
||||
this.buttonUp.Location = new System.Drawing.Point(774, 328);
|
||||
this.buttonUp.Name = "buttonUp";
|
||||
this.buttonUp.Size = new System.Drawing.Size(40, 40);
|
||||
this.buttonUp.TabIndex = 5;
|
||||
@ -136,7 +138,7 @@
|
||||
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonDown.BackgroundImage = global::PIbd_22_Kalyshev_Y_V_MotorBoat_Base.Properties.Resources.down;
|
||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonDown.Location = new System.Drawing.Point(692, 371);
|
||||
this.buttonDown.Location = new System.Drawing.Point(774, 374);
|
||||
this.buttonDown.Name = "buttonDown";
|
||||
this.buttonDown.Size = new System.Drawing.Size(40, 40);
|
||||
this.buttonDown.TabIndex = 6;
|
||||
@ -147,7 +149,7 @@
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.ClientSize = new System.Drawing.Size(882, 453);
|
||||
this.Controls.Add(this.buttonDown);
|
||||
this.Controls.Add(this.buttonUp);
|
||||
this.Controls.Add(this.buttonLeft);
|
||||
|
@ -25,9 +25,9 @@ namespace PIbd_22_Kalyshev_Y_V_MotorBoat_Base.git
|
||||
/// <param name="e"></param>
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new();
|
||||
Random rnd = new();
|
||||
_boat = new DrawningBoat();
|
||||
_boat.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||
_boat.Init(rnd.Next(5, 30), rnd.Next(30, 100), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||
_boat.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxBoat.Width, pictureBoxBoat.Height);
|
||||
toolStripStatusLabelSpeed.Text = $"Ñêîðîñòü: {_boat.Boat.Speed}";
|
||||
toolStripStatusLabelWeight.Text = $"Âåñ: {_boat.Boat.Weight}";
|
||||
@ -65,7 +65,7 @@ namespace PIbd_22_Kalyshev_Y_V_MotorBoat_Base.git
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void PictureBoxCar_Resize(object sender, EventArgs e)
|
||||
private void PictureBoxBoat_Resize(object sender, EventArgs e)
|
||||
{
|
||||
_boat?.ChangeBorders(pictureBoxBoat.Width, pictureBoxBoat.Height);
|
||||
Draw();
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 7.8 KiB |
Binary file not shown.
Before Width: | Height: | Size: 6.8 KiB |
Binary file not shown.
Before Width: | Height: | Size: 23 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 7.8 KiB |
Loading…
Reference in New Issue
Block a user