Click here to Skip to main content
15,898,878 members
Home / Discussions / C#
   

C#

 
QuestionThe classic bouncing ball logic!! Pin
Muammar©12-Jul-10 23:08
Muammar©12-Jul-10 23:08 
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 
You're doing it the hard way, why not just store a speed vector? (and don't create a struct/class for it, just store two ints or floats somewhere)
Speed can be negative, depending on the direction.
It will also make it much easier if you decide to do "other funny physics things", like gravity or other accelerations; you could just add the acceleration vector to the speed vector every update. (or scaled by time, if your steps are not fixed)

To bounce that way, you can do something like
none
until no change
{
    if (ball outside of horizontal range)
        mirror speed horizontally and mirror ball around the edge it hits
    if (ball outside of vertical range)
        mirror speed vertically and mirror ball around the edge it hits
}


Muammar© wrote:
y -= step+7;

That is a little odd.
AnswerRe: The classic bouncing ball logic!! [modified] Pin
Luc Pattyn13-Jul-10 1:04
sitebuilderLuc Pattyn13-Jul-10 1:04 
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 

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.