Click here to Skip to main content
15,921,179 members
Home / Discussions / C#
   

C#

 
AnswerRe: The classic bouncing ball logic!! Pin
Eddy Vluggen12-Jul-10 23:13
professionalEddy Vluggen12-Jul-10 23:13 
GeneralRe: The classic bouncing ball logic!! Pin
Muammar©12-Jul-10 23:36
Muammar©12-Jul-10 23:36 
AnswerRe: The classic bouncing ball logic!! Pin
Peace ON12-Jul-10 23:51
Peace ON12-Jul-10 23:51 
GeneralRe: The classic bouncing ball logic!! Pin
Eddy Vluggen13-Jul-10 0:24
professionalEddy Vluggen13-Jul-10 0:24 
GeneralRe: The classic bouncing ball logic!! Pin
Muammar©13-Jul-10 0:42
Muammar©13-Jul-10 0:42 
GeneralRe: The classic bouncing ball logic!! Pin
Eddy Vluggen13-Jul-10 1:20
professionalEddy Vluggen13-Jul-10 1:20 
AnswerRe: The classic bouncing ball logic!! Pin
harold aptroot13-Jul-10 0:10
harold aptroot13-Jul-10 0:10 
AnswerRe: The classic bouncing ball logic!! [modified] Pin
Luc Pattyn13-Jul-10 1:04
sitebuilderLuc Pattyn13-Jul-10 1:04 
That is all wrong. You have a position p (with x and y components), a speed v (with x and y components), and an acceleration/gravity a (possibly with x and y components).

For small time steps, you could evolve like this (apply to each component individually):
p+=v;
v+=a;

where a probably is just a gravitational constant (which happens to be positive since the y-axis is pointing downward in GDI+).

And collisions would invert the relevant speed component, so floor/ceiling would do v.y=-v.y; and left/right walls would cause v.x=-v.x;

ADDED
optionally you could also reduce the speed by some factor (say v*=0.9) on each collision to mimic non-elasticity.
/ADDED

Smile | :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.


modified on Tuesday, July 13, 2010 7:42 AM

GeneralRe: The classic bouncing ball logic!! Pin
David Skelly13-Jul-10 2:06
David Skelly13-Jul-10 2:06 
GeneralRe: The classic bouncing ball logic!! Pin
Luc Pattyn13-Jul-10 2:18
sitebuilderLuc Pattyn13-Jul-10 2:18 
GeneralRe: The classic bouncing ball logic!! Pin
David Skelly13-Jul-10 6:51
David Skelly13-Jul-10 6:51 
GeneralRe: The classic bouncing ball logic!! Pin
Pete O'Hanlon13-Jul-10 8:59
mvePete O'Hanlon13-Jul-10 8:59 
Question.exe update Pin
padmanabhan N12-Jul-10 21:59
padmanabhan N12-Jul-10 21:59 
AnswerRe: .exe update Pin
Peace ON12-Jul-10 22:19
Peace ON12-Jul-10 22:19 
QuestionWrite application version and installation path to registry Pin
sumit703412-Jul-10 21:11
sumit703412-Jul-10 21:11 
AnswerRe: Write application version and installation path to registry Pin
Peace ON12-Jul-10 21:46
Peace ON12-Jul-10 21:46 
GeneralRe: Write application version and installation path to registry Pin
sumit703412-Jul-10 22:32
sumit703412-Jul-10 22:32 
AnswerRe: Write application version and installation path to registry Pin
Peace ON12-Jul-10 22:39
Peace ON12-Jul-10 22:39 
Questionproblem in occurs in win 7 Pin
prasadbuddhika12-Jul-10 20:22
prasadbuddhika12-Jul-10 20:22 
AnswerRe: problem in occurs in win 7 Pin
Corinna John12-Jul-10 21:13
Corinna John12-Jul-10 21:13 
QuestionHow to resize the drwan rectangle when zoomin the image in the picture box? [modified] Pin
Nivas8212-Jul-10 18:21
Nivas8212-Jul-10 18:21 
AnswerRe: How to resize the drwan rectangle when zoomin the image in the picture box? Pin
R. Giskard Reventlov12-Jul-10 21:27
R. Giskard Reventlov12-Jul-10 21:27 
GeneralRe: How to resize the drwan rectangle when zoomin the image in the picture box? Pin
Nivas8212-Jul-10 22:12
Nivas8212-Jul-10 22:12 
GeneralRe: How to resize the drwan rectangle when zoomin the image in the picture box? Pin
PaulPrice12-Jul-10 22:21
PaulPrice12-Jul-10 22:21 
GeneralRe: How to resize the drwan rectangle when zoomin the image in the picture box? [modified] Pin
Nivas8212-Jul-10 22:26
Nivas8212-Jul-10 22:26 

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.