Click here to Skip to main content
15,885,244 members
Home / Discussions / C#
   

C#

 
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 
GeneralRe: Having trouble working with balls on Pong game in Windows forms in C# Pin
Wagner18-Dec-17 7:28
Wagner18-Dec-17 7:28 
GeneralRe: Having trouble working with balls on Pong game in Windows forms in C# Pin
Gerry Schmitz18-Dec-17 7:45
mveGerry Schmitz18-Dec-17 7:45 
QuestionConfigure container in Bootstrapper with Unity Pin
Kenneth Haugland17-Dec-17 3:17
mvaKenneth Haugland17-Dec-17 3:17 
AnswerRe: Configure container in Bootstrapper with Unity Pin
Chris Quinn17-Dec-17 21:36
Chris Quinn17-Dec-17 21:36 
GeneralRe: Configure container in Bootstrapper with Unity Pin
Kenneth Haugland18-Dec-17 1:57
mvaKenneth Haugland18-Dec-17 1:57 
AnswerRe: Configure container in Bootstrapper with Unity Pin
Kenneth Haugland18-Dec-17 8:24
mvaKenneth Haugland18-Dec-17 8:24 
QuestionRegarding article post of mvc pagelist. Pin
Member 1320094417-Dec-17 3:15
Member 1320094417-Dec-17 3:15 
AnswerRe: Regarding article post of mvc pagelist. Pin
Afzaal Ahmad Zeeshan17-Dec-17 4:32
professionalAfzaal Ahmad Zeeshan17-Dec-17 4:32 
QuestionExceptions Thrown Back to Caller with No Details Pin
User9874317-Dec-17 1:30
professionalUser9874317-Dec-17 1:30 
AnswerRe: Exceptions Thrown Back to Caller with No Details Pin
Richard Andrew x6417-Dec-17 1:48
professionalRichard Andrew x6417-Dec-17 1:48 
GeneralRe: Exceptions Thrown Back to Caller with No Details Pin
User9874317-Dec-17 11:25
professionalUser9874317-Dec-17 11:25 
AnswerRe: Exceptions Thrown Back to Caller with No Details Pin
Richard Andrew x6417-Dec-17 11:56
professionalRichard Andrew x6417-Dec-17 11:56 
GeneralRe: Exceptions Thrown Back to Caller with No Details Pin
User9874317-Dec-17 13:39
professionalUser9874317-Dec-17 13:39 
GeneralRe: Exceptions Thrown Back to Caller with No Details Pin
User9874317-Dec-17 14:38
professionalUser9874317-Dec-17 14:38 
QuestionI have a collum that is called "MountCT" Time type but for some reason when processing , times do not add up . Pin
Member 1256531216-Dec-17 22:32
Member 1256531216-Dec-17 22:32 

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.