Untitled
raw download clone
CSHARP
views 22
,
size 1004 b
namespace test
{
    class ball
    {
        public int radius, position_x, position_y, speed_x, speed_y;
        public Color color;

    
        public ball(int radius, int position_x, int position_y, int speed_x, int speed_y, Color color)
        {
            this.radius = radius;
            this.position_x = position_x;
            this.position_y = position_y;
            this.speed_x = speed_x;
            this.speed_y = speed_y;
            this.color = color;
        }

        public void MoveBall(Form1 form)
        {
            if (this.position_x < this.radius || this.position_x > (form.Width - this.radius))
                this.speed_x = this.speed_x * -1;
            if (this.position_y < this.radius || this.position_y > (form.Height - this.radius))
                this.speed_y = this.speed_y * -1;

            this.position_x = this.position_x + this.speed_x;
            this.position_y = this.position_y + this.speed_y;
        }

    }
}
close fullscreen
Login or Register to edit or fork this paste. It's free.