1080p
This commit is contained in:
67
MetoderUppgift/Form1.Designer.cs
generated
67
MetoderUppgift/Form1.Designer.cs
generated
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace MetoderUppgift
|
||||
{
|
||||
partial class Form1
|
||||
partial class BilSimulation
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@@ -48,45 +48,50 @@ namespace MetoderUppgift
|
||||
//
|
||||
// Throttle
|
||||
//
|
||||
Throttle.Location = new Point(12, 438);
|
||||
Throttle.Location = new Point(6, 205);
|
||||
Throttle.Margin = new Padding(2, 1, 2, 1);
|
||||
Throttle.Maximum = 4;
|
||||
Throttle.Name = "Throttle";
|
||||
Throttle.Size = new Size(208, 90);
|
||||
Throttle.Size = new Size(112, 45);
|
||||
Throttle.TabIndex = 0;
|
||||
Throttle.Value = 2;
|
||||
//
|
||||
// lblThr
|
||||
//
|
||||
lblThr.AutoSize = true;
|
||||
lblThr.Location = new Point(50, 514);
|
||||
lblThr.Location = new Point(27, 241);
|
||||
lblThr.Margin = new Padding(2, 0, 2, 0);
|
||||
lblThr.Name = "lblThr";
|
||||
lblThr.Size = new Size(126, 32);
|
||||
lblThr.Size = new Size(63, 15);
|
||||
lblThr.TabIndex = 1;
|
||||
lblThr.Text = "Gaspådrag";
|
||||
//
|
||||
// lblVel
|
||||
//
|
||||
lblVel.AutoSize = true;
|
||||
lblVel.Location = new Point(26, 327);
|
||||
lblVel.Location = new Point(14, 153);
|
||||
lblVel.Margin = new Padding(2, 0, 2, 0);
|
||||
lblVel.Name = "lblVel";
|
||||
lblVel.Size = new Size(116, 32);
|
||||
lblVel.Size = new Size(58, 15);
|
||||
lblVel.TabIndex = 2;
|
||||
lblVel.Text = "Hastighet";
|
||||
//
|
||||
// lblAcc
|
||||
//
|
||||
lblAcc.AutoSize = true;
|
||||
lblAcc.Location = new Point(26, 378);
|
||||
lblAcc.Location = new Point(14, 177);
|
||||
lblAcc.Margin = new Padding(2, 0, 2, 0);
|
||||
lblAcc.Name = "lblAcc";
|
||||
lblAcc.Size = new Size(145, 32);
|
||||
lblAcc.Size = new Size(73, 15);
|
||||
lblAcc.TabIndex = 3;
|
||||
lblAcc.Text = "Acceleration";
|
||||
//
|
||||
// btnStart
|
||||
//
|
||||
btnStart.Location = new Point(26, 260);
|
||||
btnStart.Location = new Point(14, 122);
|
||||
btnStart.Margin = new Padding(2, 1, 2, 1);
|
||||
btnStart.Name = "btnStart";
|
||||
btnStart.Size = new Size(150, 46);
|
||||
btnStart.Size = new Size(81, 22);
|
||||
btnStart.TabIndex = 4;
|
||||
btnStart.Text = "Starta";
|
||||
btnStart.UseVisualStyleBackColor = true;
|
||||
@@ -102,50 +107,55 @@ namespace MetoderUppgift
|
||||
Car.BackColor = Color.Transparent;
|
||||
Car.BackgroundImageLayout = ImageLayout.None;
|
||||
Car.Image = Properties.Resources.Car;
|
||||
Car.Location = new Point(552, 277);
|
||||
Car.Location = new Point(331, 106);
|
||||
Car.Margin = new Padding(2, 1, 2, 1);
|
||||
Car.Name = "Car";
|
||||
Car.Size = new Size(148, 159);
|
||||
Car.Size = new Size(153, 150);
|
||||
Car.SizeMode = PictureBoxSizeMode.Zoom;
|
||||
Car.TabIndex = 7;
|
||||
Car.TabStop = false;
|
||||
//
|
||||
// tbxAcceleration
|
||||
//
|
||||
tbxAcceleration.Location = new Point(26, 153);
|
||||
tbxAcceleration.Location = new Point(14, 72);
|
||||
tbxAcceleration.Margin = new Padding(2, 1, 2, 1);
|
||||
tbxAcceleration.Name = "tbxAcceleration";
|
||||
tbxAcceleration.Size = new Size(288, 39);
|
||||
tbxAcceleration.Size = new Size(268, 23);
|
||||
tbxAcceleration.TabIndex = 8;
|
||||
//
|
||||
// tbxVelocity
|
||||
//
|
||||
tbxVelocity.Location = new Point(26, 64);
|
||||
tbxVelocity.Location = new Point(14, 30);
|
||||
tbxVelocity.Margin = new Padding(2, 1, 2, 1);
|
||||
tbxVelocity.Name = "tbxVelocity";
|
||||
tbxVelocity.Size = new Size(288, 39);
|
||||
tbxVelocity.Size = new Size(268, 23);
|
||||
tbxVelocity.TabIndex = 9;
|
||||
//
|
||||
// lblMaxAcceleration
|
||||
//
|
||||
lblMaxAcceleration.AutoSize = true;
|
||||
lblMaxAcceleration.Location = new Point(26, 118);
|
||||
lblMaxAcceleration.Location = new Point(14, 55);
|
||||
lblMaxAcceleration.Margin = new Padding(2, 0, 2, 0);
|
||||
lblMaxAcceleration.Name = "lblMaxAcceleration";
|
||||
lblMaxAcceleration.Size = new Size(280, 32);
|
||||
lblMaxAcceleration.Size = new Size(248, 15);
|
||||
lblMaxAcceleration.TabIndex = 10;
|
||||
lblMaxAcceleration.Text = "MaxAcceleration [m/s^2]";
|
||||
lblMaxAcceleration.Text = "MaxAcceleration [m/s^2] (Recommended 10)";
|
||||
//
|
||||
// lblMaxHastighet
|
||||
//
|
||||
lblMaxHastighet.AutoSize = true;
|
||||
lblMaxHastighet.Location = new Point(26, 29);
|
||||
lblMaxHastighet.Location = new Point(14, 14);
|
||||
lblMaxHastighet.Margin = new Padding(2, 0, 2, 0);
|
||||
lblMaxHastighet.Name = "lblMaxHastighet";
|
||||
lblMaxHastighet.Size = new Size(226, 32);
|
||||
lblMaxHastighet.Size = new Size(223, 15);
|
||||
lblMaxHastighet.TabIndex = 11;
|
||||
lblMaxHastighet.Text = "Max hastighet [m/s]";
|
||||
lblMaxHastighet.Text = "Max hastighet [m/s] (Recommended: 30)";
|
||||
//
|
||||
// Form1
|
||||
// BilSimulation
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(13F, 32F);
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1083, 622);
|
||||
ClientSize = new Size(583, 292);
|
||||
Controls.Add(lblMaxHastighet);
|
||||
Controls.Add(lblMaxAcceleration);
|
||||
Controls.Add(tbxVelocity);
|
||||
@@ -156,9 +166,10 @@ namespace MetoderUppgift
|
||||
Controls.Add(lblVel);
|
||||
Controls.Add(lblThr);
|
||||
Controls.Add(Throttle);
|
||||
Margin = new Padding(2, 1, 2, 1);
|
||||
MaximizeBox = false;
|
||||
Name = "Form1";
|
||||
Text = "Form1";
|
||||
Name = "BilSimulation";
|
||||
Text = "Bil Simulation";
|
||||
Load += Form1_Load;
|
||||
((System.ComponentModel.ISupportInitialize)Throttle).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)Car).EndInit();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Drawing;
|
||||
namespace MetoderUppgift
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
public partial class BilSimulation : Form
|
||||
{
|
||||
float velocity = 0; // [m/s]
|
||||
float vMax; // [m/s]
|
||||
@@ -10,11 +10,10 @@ namespace MetoderUppgift
|
||||
float dt = 0.1f; // [s]
|
||||
float stripeOffset = 0; // horizontal offset for stripes
|
||||
|
||||
public Form1()
|
||||
public BilSimulation()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
void UpdateUI(float acceleration)
|
||||
{
|
||||
lblAcc.Text = "Acceleration: " + acceleration.ToString("0.00") + " [m/s<>]";
|
||||
@@ -81,21 +80,23 @@ namespace MetoderUppgift
|
||||
Application.Exit();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e) // Paint funktion f<>r grafik
|
||||
{
|
||||
base.OnPaint(e);
|
||||
Graphics g = e.Graphics;
|
||||
|
||||
int roadX = 800;
|
||||
int roadWidth = 150;
|
||||
int roadX = 400;
|
||||
int roadWidth = 100;
|
||||
g.FillRectangle(Brushes.DimGray, roadX, 0, roadWidth, ClientSize.Height);
|
||||
Car.Location = new Point(800, ClientSize.Height / 2);
|
||||
|
||||
Car.Location = new Point(roadX + roadWidth/2, ClientSize.Height / 2);
|
||||
Car.Size = new Size(roadWidth/2, roadWidth/2);
|
||||
|
||||
|
||||
// Streck
|
||||
int stripeWidth = 10;
|
||||
int stripeHeight = 30;
|
||||
int gap = 200;
|
||||
int stripeWidth = 5;
|
||||
int stripeHeight = 15;
|
||||
int gap = 80;
|
||||
int stripesCount = 5;
|
||||
int stripeX = roadX + roadWidth / 2 - stripeWidth / 2;
|
||||
int stripeY = 0;
|
||||
@@ -104,7 +105,7 @@ namespace MetoderUppgift
|
||||
{
|
||||
g.FillRectangle(Brushes.White, stripeX, stripeY + stripeOffset, stripeWidth, stripeHeight); // Offset uppdateras varje tick. F<>r<EFBFBD>ndringshastighet av hastighet.
|
||||
stripeY += gap;
|
||||
if ((stripeOffset) > 200)
|
||||
if ((stripeOffset) > 80)
|
||||
{
|
||||
stripeOffset = 0; // Flytta tillbaka strecken om de hamnar utanf<6E>r rutan.
|
||||
}
|
||||
@@ -120,6 +121,5 @@ namespace MetoderUppgift
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,4 +27,16 @@
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Resources\Car.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Resources\Screenshot 2026-01-18 192012.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Resources\Screenshot 2026-01-18 192524.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -11,7 +11,7 @@ namespace MetoderUppgift
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
Application.Run(new BilSimulation());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user