Click here to Skip to main content
15,889,436 members
Home / Discussions / C#
   

C#

 
Question" System.UriFormatException: Invalid URI : The format of the URI could not be determined " Pin
ChinnuKodali15088-Jul-13 7:06
professionalChinnuKodali15088-Jul-13 7:06 
AnswerRe: " System.UriFormatException: Invalid URI : The format of the URI could not be determined " Pin
Pete O'Hanlon8-Jul-13 7:10
mvePete O'Hanlon8-Jul-13 7:10 
GeneralMessage Closed Pin
8-Jul-13 10:24
professionalChinnuKodali15088-Jul-13 10:24 
GeneralRe: " System.UriFormatException: Invalid URI : The format of the URI could not be determined " Pin
Pete O'Hanlon8-Jul-13 10:29
mvePete O'Hanlon8-Jul-13 10:29 
GeneralRe: " System.UriFormatException: Invalid URI : The format of the URI could not be determined " Pin
ChinnuKodali15088-Jul-13 10:41
professionalChinnuKodali15088-Jul-13 10:41 
GeneralRe: " System.UriFormatException: Invalid URI : The format of the URI could not be determined " Pin
Pete O'Hanlon8-Jul-13 10:44
mvePete O'Hanlon8-Jul-13 10:44 
QuestionMaths for bouncing a ball around a window.. Pin
Kevin Bewley8-Jul-13 4:42
Kevin Bewley8-Jul-13 4:42 
AnswerRe: Maths for bouncing a ball around a window.. Pin
NickPace8-Jul-13 5:10
NickPace8-Jul-13 5:10 
I would use two integer properties for the ball object, called DeltaX and DeltaY. These would represent the number of pixels for the ball to move along the X and Y axis. A good starting point would probably be 3 as a value for both of these variables. When DeltaX is positive, the ball is moving to the right; and when negative, the ball is moving to the left. When DeltaY is positive, the ball is moving down; and when negative, the ball is moving up. When you encounter the edge of the form, simply multiply the appropriate variable by -1 to change its direction.

Something like this:
C#
private bool BallHitBoundary(Ball ball)
{
    /* Check if the game ball hit a form boundary. If so, change the direction of the ball accordingly and
     * return true. Otherwise return false. */
    if (ball.Top <= ClientRectangle.Top || ball.Bottom >= ClientRectangle.Bottom)
    {
        // Game ball hit the top or bottom. Change the Y direction the other way.
        ball.ReverseDeltaY();
        return true;
    }

    if (ball.Left <= ClientRectangle.Left || ball.Right >= ClientRectangle.Right)
    {
        // Game ball hit the left or right side. Change the X direction the other way.
        ball.ReverseDeltaX();
        return true;
    }
    else
    {
        return false;
    }
}

and the ReverseDeltaY() and ReverseDeltaX() are methods for the ball object that simply multiply DeltaY/DeltaX by -1:
XML
/// <summary>
/// Reverses DeltaX by multiplying by -1.
/// </summary>
internal void ReverseDeltaX()
{
    DeltaX *= -1;
}

/// <summary>
/// Reverses DeltaY by multiplying by -1.
/// </summary>
internal void ReverseDeltaY()
{
    DeltaY *= -1;
}


The above is actual code from a project I built to make a Breakout game just for the fun of it. The ball object inherits from a Panel object with a solid circle drawn inside of it. It works good for me.
-NP

Never underestimate the creativity of the end-user.

GeneralRe: Maths for bouncing a ball around a window.. Pin
Kevin Bewley8-Jul-13 5:19
Kevin Bewley8-Jul-13 5:19 
GeneralRe: Maths for bouncing a ball around a window.. Pin
NickPace8-Jul-13 5:25
NickPace8-Jul-13 5:25 
GeneralRe: Maths for bouncing a ball around a window.. Pin
Kevin Bewley8-Jul-13 5:46
Kevin Bewley8-Jul-13 5:46 
GeneralRe: Maths for bouncing a ball around a window.. Pin
harold aptroot8-Jul-13 6:00
harold aptroot8-Jul-13 6:00 
AnswerRe: Maths for bouncing a ball around a window.. Pin
Keld Ølykke8-Jul-13 20:11
Keld Ølykke8-Jul-13 20:11 
QuestionWebException timeout Problem. Pin
vishalmudrale8-Jul-13 4:04
vishalmudrale8-Jul-13 4:04 
QuestionRe: WebException timeout Problem. Pin
Eddy Vluggen8-Jul-13 4:59
professionalEddy Vluggen8-Jul-13 4:59 
AnswerRe: WebException timeout Problem. Pin
vishalmudrale8-Jul-13 20:20
vishalmudrale8-Jul-13 20:20 
QuestionRe: WebException timeout Problem. Pin
vishalmudrale8-Jul-13 20:21
vishalmudrale8-Jul-13 20:21 
AnswerRe: WebException timeout Problem. Pin
Eddy Vluggen9-Jul-13 0:22
professionalEddy Vluggen9-Jul-13 0:22 
GeneralRe: WebException timeout Problem. Pin
vishalmudrale9-Jul-13 0:40
vishalmudrale9-Jul-13 0:40 
GeneralRe: WebException timeout Problem. Pin
Eddy Vluggen9-Jul-13 3:03
professionalEddy Vluggen9-Jul-13 3:03 
QuestionDeveloping a Point of Sale System for Reataurant/Hotel Pin
MohdWaseem8-Jul-13 3:46
MohdWaseem8-Jul-13 3:46 
AnswerRe: Developing a Point of Sale System for Reataurant/Hotel Pin
Manfred Rudolf Bihy8-Jul-13 4:46
professionalManfred Rudolf Bihy8-Jul-13 4:46 
AnswerRe: Developing a Point of Sale System for Reataurant/Hotel Pin
Dave Kreskowiak8-Jul-13 5:18
mveDave Kreskowiak8-Jul-13 5:18 
AnswerRe: Developing a Point of Sale System for Reataurant/Hotel Pin
Walt Dexter8-Jul-13 7:21
Walt Dexter8-Jul-13 7:21 
AnswerRe: Developing a Point of Sale System for Reataurant/Hotel Pin
Bernhard Hiller8-Jul-13 23:12
Bernhard Hiller8-Jul-13 23:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.