yes, look at the code above @kseh gave you.
c# bug invaders
hint: when the interval ticks, toggle a global bool draw flag;
I really, really don't want to mess up your vision. The journey is not the destination but the steps taken to get there. Let's see what you can come up with.
Dev careful. Pixel on board.
I am doing goliaths hint.
22 hours ago, GoliathForge said:hint: when the interval ticks, toggle a global bool draw flag;
I really, really don't want to mess up your vision. The journey is not the destination but the steps taken to get there. Let's see what you can come up with.
bool draw_flag = false;
private void timer2_Tick(object sender, EventArgs e)
{
draw_flag = true;
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.Clear(this.BackColor);
e.Graphics.DrawImage(ship, 350 + x, 530);
e.Graphics.DrawImage(bullet, 375 + x, 520 + y);
e.Graphics.DrawImage(bug_one, 350, 0);
if (y <= -500)
{
e.Graphics.DrawImage(coll, 350, 0);
// e.Graphics.DrawImage(black, 350, 0);
}
}
almost. good go with the switch. The way you're set up, it will only turn on after the interval. If that's the behavior you're after, perfect. Now use the flag when you paint. Again, first work this out in your head. What do you want to see happen and can you make it happen logically with just one bool. maybe it's time to remove that condition that tests the variable y being less than or equal to negative 500 and replace it with good logic using your new found tool to splat that bug. The timed toggle.
We toogle on...We toggle off...straight up good fun-phil.
Please take a moment at some point, have a tea...and have another go at what @Daniel Ricci advises above.
Dev careful. Pixel on board.
I have almost solved my problem, I am taking goliath's advice and have implemented his toggle.
bool draw_flag = true;
private void timer2_Tick(object sender, EventArgs e)
{
draw_flag = false;
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
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 if (draw_flag == true && y <= -510)
{
e.Graphics.DrawImage(black, 350, 0);
}
}