Jump to content
  • Advertisement
phil67rpg

c# drawing sprites

Recommended Posts

        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)
            {
                e.Graphics.DrawImage(black, 350, 0);
            }
        }
        int count = 0;
        private void timer2_Tick(object sender, EventArgs e)
        {
            if(count %2==0)
            {
                draw_flag = false;
            }
            else
            {
                draw_flag = true;
            }
            count++;
        }

well I have got my code to blink on and  off, it almost does what I want. I have worked on my timer function.

Share this post


Link to post
Share on other sites
Advertisement

 well I  watched the video and I think I know how to use the timer, I have almost solved my problem I just am unsure of how to get the bug not to blink, according to my code  it looks like it should draw my bug before I draw my collision sprite and   the bug should not blink, I need a fresh pair of eyes to look at my code and see what is wrong.

Share this post


Link to post
Share on other sites
Posted (edited)
1 hour ago, GoliathForge said:

then don't blink it.

Look at the Brian button link above and check out his collection of instruction.

how do I get it not to blink? is there any video that might be very helpful?

Edited by phil67rpg

Share this post


Link to post
Share on other sites
Posted (edited)

yes, forever. (I think) we toggle on...we toggle off.

Is something like this what you're looking for?

bool draw_flag = false;
private void Form1_Paint(object sender, PaintEventArgs e)
{
    e.Graphics.Clear(Color.Teal);
    e.Graphics.DrawImage(ship, 350 + x, 530);
    e.Graphics.DrawImage(bullet, 375 + x, 520 + y);
    
    if (draw_flag == false && y <= -510)
    {
        draw_flag = true;
    } else {
        e.Graphics.DrawImage(bug_one, 350, 0);
    }

    if(draw_flag == true)
    {
        e.Graphics.DrawImage(coll, 350, 0);
    }
}

int count = 0;
private void timer2_Tick(object sender, EventArgs e)
{   // is my timer ticking? and when do we enter?
    int someStopValue = 4;
    if(count > someStopValue)
    {
        draw_flag = false;
        count = 0;
        // y = 0; reset somewhere
    }
    
    count++;
}

 

Edited by GoliathForge

Share this post


Link to post
Share on other sites
Posted (edited)

so how do I toggle the values, is there a way that is very proficient? I also googled toggling but did come up anything good

Edited by phil67rpg

Share this post


Link to post
Share on other sites
Posted (edited)

make your own logic. make it how you want. Also I think the google keyword you're after would be animation. 

For instance, check this guy out. It's a little advanced I suspect but the direction you might be interested in.

 

Edited by GoliathForge

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!