Click here to Skip to main content
15,916,180 members
Home / Discussions / C#
   

C#

 
AnswerRe: How do i to create a bouncing ball in C# Pin
OriginalGriff5-Apr-18 5:21
mveOriginalGriff5-Apr-18 5:21 
GeneralRe: How do i to create a bouncing ball in C# Pin
Member 137644515-Apr-18 7:29
Member 137644515-Apr-18 7:29 
GeneralRe: How do i to create a bouncing ball in C# Pin
OriginalGriff5-Apr-18 8:10
mveOriginalGriff5-Apr-18 8:10 
All that means is: when the ball hits an edge, it bounces off at the appropriate angle.
So if it hits the wall like this:
      |
      |
      |
      |
----->|
      |
      |
      |
      |
It rebounds exactly as you'd expect:
      |
      |
      |
      |
<-----|
      |
      |
      |
      |
It if hits at an angle, then it rebounds at an angle:
    |
\   |
 \  |
  \ |
   \|
    |
    |
    |
    |
Becomes
    |
    |
    |
    |
   /|
  / |
 /  |
/   |
    |
Now, presumably, you have a "move this number X" and "move this number Y" values which you add to your ball coordinates each time the timer ticks? So just try inverting the "move number" for the appropriate direction: left and right walls modify dX = -dX, top and bottom modify dY = -dY

Make sense?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!

PraiseRe: How do i to create a bouncing ball in C# Pin
Member 137644515-Apr-18 8:16
Member 137644515-Apr-18 8:16 
GeneralRe: How do i to create a bouncing ball in C# Pin
OriginalGriff5-Apr-18 8:21
mveOriginalGriff5-Apr-18 8:21 
AnswerRe: How do i to create a bouncing ball in C# Pin
Eddy Vluggen5-Apr-18 6:53
professionalEddy Vluggen5-Apr-18 6:53 
Questioncopy paste file remotly Pin
Member 79659463-Apr-18 19:41
Member 79659463-Apr-18 19:41 
AnswerRe: copy paste file remotly Pin
OriginalGriff3-Apr-18 20:07
mveOriginalGriff3-Apr-18 20:07 
GeneralRe: copy paste file remotly Pin
Member 79659464-Apr-18 21:34
Member 79659464-Apr-18 21:34 
GeneralRe: copy paste file remotly Pin
OriginalGriff4-Apr-18 21:43
mveOriginalGriff4-Apr-18 21:43 
SuggestionRe: copy paste file remotly Pin
Richard Deeming4-Apr-18 1:40
mveRichard Deeming4-Apr-18 1:40 
GeneralRe: copy paste file remotly Pin
Member 79659464-Apr-18 21:03
Member 79659464-Apr-18 21:03 
GeneralRe: copy paste file remotly Pin
Eddy Vluggen4-Apr-18 23:48
professionalEddy Vluggen4-Apr-18 23:48 
GeneralRe: copy paste file remotly Pin
Member 79659467-Apr-18 19:39
Member 79659467-Apr-18 19:39 
AnswerRe: copy paste file remotly Pin
Member 79659467-Apr-18 19:40
Member 79659467-Apr-18 19:40 
GeneralRe: copy paste file remotly Pin
Eddy Vluggen8-Apr-18 0:19
professionalEddy Vluggen8-Apr-18 0:19 
QuestionOCR project Pin
Member 130706852-Apr-18 7:40
Member 130706852-Apr-18 7:40 
AnswerRe: OCR project Pin
Pete O'Hanlon2-Apr-18 7:45
mvePete O'Hanlon2-Apr-18 7:45 
QuestionWorking on OCR as my final year project. Pin
Member 130706852-Apr-18 7:17
Member 130706852-Apr-18 7:17 
AnswerRe: Working on OCR as my final year project. Pin
Dave Kreskowiak2-Apr-18 8:41
mveDave Kreskowiak2-Apr-18 8:41 
AnswerRe: Working on OCR as my final year project. Pin
User 41802543-Apr-18 14:22
User 41802543-Apr-18 14:22 
QuestionOCR project Pin
Member 130706852-Apr-18 7:13
Member 130706852-Apr-18 7:13 
AnswerRe: OCR project Pin
Dave Kreskowiak2-Apr-18 8:39
mveDave Kreskowiak2-Apr-18 8:39 
QuestionGenerate unique number from C# string Pin
MiteshUmta2-Apr-18 2:37
MiteshUmta2-Apr-18 2:37 
AnswerRe: Generate unique number from C# string Pin
Dave Kreskowiak2-Apr-18 2:53
mveDave Kreskowiak2-Apr-18 2:53 

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.