|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace Übungen_LF6_WinFormanwendung
|
|
|
|
|
{
|
|
|
|
|
public partial class Autofahren : Form
|
|
|
|
|
{
|
|
|
|
|
Auto Schnecke1 = new Auto();
|
|
|
|
|
Auto Schnecke2 = new Auto();
|
|
|
|
|
Auto Schnecke3 = new Auto();
|
|
|
|
|
Auto Schnecke4 = new Auto();
|
|
|
|
|
|
|
|
|
|
bool winnerFound = false;
|
|
|
|
|
|
|
|
|
|
public Autofahren()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void button_start_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
int startPos_X = 50;
|
|
|
|
|
int startPos_Y = 50;
|
|
|
|
|
|
|
|
|
|
Schnecke1 = new Auto(80, startPos_X, startPos_Y, "Schnecke 1");
|
|
|
|
|
this.Controls.Add(Schnecke1);
|
|
|
|
|
|
|
|
|
|
Schnecke2 = new Auto(90, startPos_X, startPos_Y + 50, "Schnecke 2");
|
|
|
|
|
this.Controls.Add(Schnecke2);
|
|
|
|
|
|
|
|
|
|
Schnecke3 = new Auto(75, startPos_X, startPos_Y + 100, "Schnecke 3");
|
|
|
|
|
this.Controls.Add(Schnecke3);
|
|
|
|
|
|
|
|
|
|
Schnecke4 = new Auto(99, startPos_X, startPos_Y + 150, "Schnecke 4");
|
|
|
|
|
this.Controls.Add(Schnecke4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void button_go_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
while (!winnerFound)
|
|
|
|
|
{
|
|
|
|
|
Schnecke1.fahren(this.Size.Width - 100);
|
|
|
|
|
Schnecke2.fahren(this.Size.Width - 100);
|
|
|
|
|
Schnecke3.fahren(this.Size.Width - 100);
|
|
|
|
|
Schnecke4.fahren(this.Size.Width - 100);
|
|
|
|
|
|
|
|
|
|
if (Schnecke1.zielErreicht || Schnecke2.zielErreicht || Schnecke3.zielErreicht || Schnecke4.zielErreicht)
|
|
|
|
|
winnerFound = true;
|
|
|
|
|
|
|
|
|
|
Controls.Remove(Schnecke1);
|
|
|
|
|
Controls.Remove(Schnecke2);
|
|
|
|
|
Controls.Remove(Schnecke3);
|
|
|
|
|
Controls.Remove(Schnecke4);
|
|
|
|
|
|
|
|
|
|
Controls.Add(Schnecke1);
|
|
|
|
|
Controls.Add(Schnecke2);
|
|
|
|
|
Controls.Add(Schnecke3);
|
|
|
|
|
Controls.Add(Schnecke4);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void button_ende_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|