using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Game2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
timer1.Start();
}
private void Move_Ship(int X_Coord ,int Y_Coord, string Positioning)
{
if(Positioning == "Rechts")
{
X_Coord += 5;
this.pictureBox1.Location = new Point(X_Coord, Y_Coord);
};
if (Positioning == "Links")
{
X_Coord -= 5;
this.pictureBox1.Location = new Point(X_Coord, Y_Coord);
};
if (Positioning == "Up")
{
Y_Coord -= 5;
this.pictureBox1.Location = new Point(X_Coord, Y_Coord);
};
if (Positioning == "Down")
{
Y_Coord += 5;
this.pictureBox1.Location = new Point(X_Coord, Y_Coord);
};
}
private void timer1_Tick(object sender, EventArgs e)
{
if (Control.ModifierKeys == Keys.Up)
{
Move_Ship(pictureBox1.Location.X, pictureBox1.Location.Y, "Up");
};
if (Control.ModifierKeys == Keys.Down)
{
Move_Ship(pictureBox1.Location.X, pictureBox1.Location.Y, "Down");
};
if (Control.ModifierKeys == Keys.Left)
{
Move_Ship(pictureBox1.Location.X, pictureBox1.Location.Y, "Links");
};
if (Control.ModifierKeys == Keys.Right)
{
Move_Ship(pictureBox1.Location.X, pictureBox1.Location.Y, "Rechts");
};
}
}
}
If I did this right my piture should be moving the but it doesn't do anything at all. Did I do something wrong and if so please tell me?