On 3/19/2019 at 5:04 PM, phil67rpg said:
I have tried tweaking it but just cant come up with a viable solution. I am so close, I have got it to blink off and on.
private void Form1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.Clear(Color.Black);
e.Graphics.DrawImage(ship, 350 + x, 530);
e.Graphics.DrawImage(bullet, 375 + x, 520 + y);
e.Graphics.DrawImage(bug_one, 350, 0);
if (draw_flag == false && y <= -510)
{
e.Graphics.DrawImage(coll, 350, 0);
}
else
{
e.Graphics.DrawImage(bug_one, 350, 0);
}
if (draw_flag==true)
{
e.Graphics.DrawImage(black, 350, 0);
}
}
int count = 0;
private void timer2_Tick(object sender, EventArgs e)
{
draw_flag = false;
int stop = 4;
if (count > stop)
{
draw_flag = true;
count = 0;
}
count++;
}
}
Dude just look at your logic... You draw when draw_flag is true... and it's only true every fourth tick... That is, right now, it will be off, off, off, on, off, off, off, on, etc. You are forcing it to blink. I'm not sure if you're having trouble with understanding how basic animation works or if you don't understand basic coding, but this thread is painful to read... Maybe Google how to make a flip book... If you only draw on every fourth page, it's going to look like it's blinking...
But, look man... Just remove the code that you put that makes it blink... replace the entire timer code with "draw_flag = true;" -- and then it will just be true every frame (i.e. If you don't want it to blink, draw it on every page of your flip book, stop skipping pages!).
Also you're totally murdering c# casing conventions. In simplified terms, you should be using TitleCase for class level variables, and camelCase for method level variables... (It's not going to make your code work any different, it's just a matter of established conventions... You don't have to change it, it's just annoying to see.)