Click here to Skip to main content
15,911,646 members
Home / Discussions / C#
   

C#

 
Questionc sharp windows form application in visual studio Pin
Member 1358596919-Dec-17 20:30
Member 1358596919-Dec-17 20:30 
AnswerRe: c sharp windows form application in visual studio Pin
OriginalGriff19-Dec-17 21:38
mveOriginalGriff19-Dec-17 21:38 
QuestionHow to speech russian text in C#? Pin
Ldta19-Dec-17 15:38
Ldta19-Dec-17 15:38 
AnswerRe: How to speech russian text in C#? Pin
Pete O'Hanlon19-Dec-17 19:35
mvePete O'Hanlon19-Dec-17 19:35 
GeneralRe: How to speech russian text in C#? Pin
Ldta20-Dec-17 1:43
Ldta20-Dec-17 1:43 
GeneralRe: How to speech russian text in C#? Pin
Pete O'Hanlon20-Dec-17 2:43
mvePete O'Hanlon20-Dec-17 2:43 
QuestionDrag and drop dynamically a video from a media player to another container Pin
Hervend19-Dec-17 0:19
Hervend19-Dec-17 0:19 
AnswerRe: Drag and drop dynamically a video from a media player to another container Pin
Richard MacCutchan19-Dec-17 2:48
mveRichard MacCutchan19-Dec-17 2:48 
GeneralRe: Drag and drop dynamically a video from a media player to another container Pin
Hervend19-Dec-17 20:37
Hervend19-Dec-17 20:37 
Questionsave appointment on the shared exchange calendar Pin
maxim^18-Dec-17 23:22
maxim^18-Dec-17 23:22 
AnswerRe: save appointment on the shared exchange calendar Pin
OriginalGriff18-Dec-17 23:26
mveOriginalGriff18-Dec-17 23:26 
AnswerRe: save appointment on the shared exchange calendar Pin
Pete O'Hanlon19-Dec-17 4:03
mvePete O'Hanlon19-Dec-17 4:03 
Questionlambda expression to retrieve sequence based on an array value where the array is stored in the sequence Pin
Krellon18-Dec-17 23:02
Krellon18-Dec-17 23:02 
AnswerRe: lambda expression to retrieve sequence based on an array value where the array is stored in the sequence Pin
OriginalGriff18-Dec-17 23:25
mveOriginalGriff18-Dec-17 23:25 
GeneralRe: lambda expression to retrieve sequence based on an array value where the array is stored in the sequence Pin
Krellon19-Dec-17 0:13
Krellon19-Dec-17 0:13 
GeneralRe: lambda expression to retrieve sequence based on an array value where the array is stored in the sequence Pin
Richard Deeming19-Dec-17 2:19
mveRichard Deeming19-Dec-17 2:19 
GeneralRe: lambda expression to retrieve sequence based on an array value where the array is stored in the sequence Pin
Krellon19-Dec-17 5:37
Krellon19-Dec-17 5:37 
SuggestionRe: lambda expression to retrieve sequence based on an array value where the array is stored in the sequence Pin
Richard Deeming19-Dec-17 2:17
mveRichard Deeming19-Dec-17 2:17 
GeneralRe: lambda expression to retrieve sequence based on an array value where the array is stored in the sequence Pin
OriginalGriff19-Dec-17 2:26
mveOriginalGriff19-Dec-17 2:26 
QuestionHaving trouble working with balls on Pong game in Windows forms in C# Pin
Wagner18-Dec-17 4:29
Wagner18-Dec-17 4:29 
AnswerRe: Having trouble working with balls on Pong game in Windows forms in C# Pin
Kenneth Haugland18-Dec-17 4:34
mvaKenneth Haugland18-Dec-17 4:34 
GeneralRe: Having trouble working with balls on Pong game in Windows forms in C# Pin
Wagner18-Dec-17 4:53
Wagner18-Dec-17 4:53 
AnswerRe: Having trouble working with balls on Pong game in Windows forms in C# Pin
Ron Nicholson18-Dec-17 5:25
professionalRon Nicholson18-Dec-17 5:25 
I'm assuming you know the Cartesian Coordinate system[^]. Every thing will be based on it.
C#
if (ball.Location.Y < 0)
            {
                pl1Score++;
                ball.Location = new Point(this.Width / 2, this.Height / 2);

            }
In plain English this means; If the location of the ball is less than 0 then take the following actions. Update player ones score and give the ball a new location in the middle of the screen.
Assuming your paddles are at the top and bottom of the screen this means that player one just score a point against player two.
C#
if (ball.Location.Y > this.Height)
            {
                pl2Score++;
                ball.Location = new Point(this.Width / 2, this.Height / 2);
            }
This means exactly the same except the ball has traveled off the screen at the bottom.
C#
if ( ball.Location.X > player1.Location.X 
  && ball.Location.X + ball.Width < player1.Location.X + player1.Width 
  && ball.Location.Y + ball.Height > player1.Location.Y)
            {

                bvelY *= -1;
            }

This one is very similar in that you are making sure that the location of the ball in both the X and Y coordinate has not hit the player one paddle.

So the ball X coordinate must be greater than the player one X coordinate
AND
the ball X coordinate plus the ball width is less than the player one X plus the player one width.
(in other words does the ball line up with the paddle in the X coordinate.
AND
the ball Y coordinate plus the ball height is greater than the player one Y coordinate.

That whole if statement tells you if the ball hit the paddle then change the direction of the ball. I know it says speed but sometimes speed and direction are equivalent.
Jack of all trades, master of none, though often times better than master of one.

GeneralRe: Having trouble working with balls on Pong game in Windows forms in C# Pin
Wagner18-Dec-17 6:46
Wagner18-Dec-17 6:46 
AnswerRe: Having trouble working with balls on Pong game in Windows forms in C# Pin
Gerry Schmitz18-Dec-17 6:35
mveGerry Schmitz18-Dec-17 6:35 

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.