I am using c# and windows forms to make an isometric game, my question how do I move an image without the screen flickering. here is my code so far.
namespace WindowsFormsApp15
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
int x = 240, y = 220;
private void Form1_Paint(object sender, PaintEventArgs e)
{
Image myImage = Image.FromFile("iso3.png");
for(int j=0; j<420; j+=20)
{
for(int i=0; i<520; i+=40)
{
e.Graphics.DrawImage(myImage, i, j);
}
}
Image myImage_two = Image.FromFile("castle3.png");
e.Graphics.DrawImage(myImage_two, 240, 160);
Image myImage_three = Image.FromFile("player2.png");
e.Graphics.DrawImage(myImage_three, x, y);
}
private void button1_Click(object sender, EventArgs e)
{
y -= 5;
Invalidate();
}
private void button2_Click(object sender, EventArgs e)
{
y += 5;
Invalidate();
}
private void button3_Click(object sender, EventArgs e)
{
x -= 5;
Invalidate();
}
private void button4_Click(object sender, EventArgs e)
{
x += 5;
Invalidate();
}
}
}