🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

c# clearing images

Started by
53 comments, last by phil67rpg 5 years, 2 months ago

thanks for all the input,  do  you have any more input that is applicable to my collision problem? I am not  giving up on my problem, there has to be an answer to it.

Advertisement

well I finally solved my problem. YEAH!!!!!!!! here is the code I am using.


        int count = 102;
        bool collision = false;
        public void Form1_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.Clear(Color.Black);
            e.Graphics.DrawImage(ship, 350 + x, 530);
            if(collision)
            {
                return;
            }
            e.Graphics.DrawImage(bullet, 375 + x, 520 + y);
            e.Graphics.DrawImage(bug_one, 350, 0);
            if (y <= -510 && x >= -15 && x <= 15 && count > 0)
            {
                e.Graphics.DrawImage(coll, 350, 0);
                count = 0;
                collision = true;
            }
        }
        public void timer1_Tick(object sender, EventArgs e)
        {
            y -= 5;
            Invalidate();
        }
        public void timer2_Tick(object sender, EventArgs e)
        {
            count--;
            Invalidate();
        }

 

 

Are you in the mood to talk about it? :) This is good. We have options now...Let's check a few things. How many times do I want to see the coll image? If this event happens late, does it happen at all? What I suggest is walk though your logic for a few frames and see if all the values of your variables are what you think they should be. More importantly are they what you think they should be when they need to be first used. I would keep my head in this and practice with the debugger. 

well everything is working like I want it to do. now I have to draw several bugs. you can close this thread since I solved my problem.

9 hours ago, phil67rpg said:

do  you have any more input that is applicable to my collision problem?

I made something for you. Could you solve this follow problem? Imagine that you have a point and a rectangle. Is the point inside of the rectangle?

My flowchart should help you: https://drakonhub.com/ide/doc/8observer8/14

20190412234905.png.b1183362b60265df584e74c6ad71fd3d.png

could someone please close this thread I have solved my problem.

Are you sure? ⚠️

yes if run into another problem I will post a new thread.

This topic is closed to new replies.

Advertisement