Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Page 2 of 2 FirstFirst 12
Results 26 to 39 of 39

Thread: Help Please

  1. #26
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Help Please

    why the out put is messed when the for loop is in place
    Can you describe what the messed part is now? After a few code changes, it could be acting differently than it was.

  2. #27
    Junior Member viper_07's Avatar
    Join Date
    Jul 2011
    Location
    manchester
    Posts
    23
    My Mood
    Cheerful
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Help Please

    it seems that the ball is containd on one side of the page the balls see as tho they are not flowing more like traped on one side

  3. #28
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Help Please

    like traped on one side
    Back to printing out the values of the balls positions. Only test with two balls to keep it simple. You might try changing the size of the window and the speed that the balls move for easier debugging.
    The thing to notice is when the ball reverses direction. What variables are used when a ball reverses direction?

  4. #29
    Junior Member viper_07's Avatar
    Join Date
    Jul 2011
    Location
    manchester
    Posts
    23
    My Mood
    Cheerful
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Help Please

    it must be something to do with the for loop because all varibles are the same with and without it and when i put a break; after the while the balls work perfectley hmmmm this is deffonatley a strange one

  5. #30
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Help Please

    You can make assumptions and/or you can add printlns and look at the output and see if there is a pattern when a ball looks like it is "trapped on one side".
    What are the values of the balls positions when that happens?

  6. #31
    Junior Member viper_07's Avatar
    Join Date
    Jul 2011
    Location
    manchester
    Posts
    23
    My Mood
    Cheerful
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Help Please

    here is a print out of the posision

    x = 758 y = 547
    x = 50 y = 524
    x = 757 y = 548
    x = 49 y = 525
    x = 756 y = 549
    x = 48 y = 526
    x = 755 y = 550
    x = 47 y = 527
    x = 754 y = 551
    x = 46 y = 528
    x = 753 y = 552
    x = 45 y = 529
    x = 752 y = 553
    x = 44 y = 530
    x = 751 y = 554
    x = 43 y = 531
    x = 750 y = 555
    x = 42 y = 532
    x = 749 y = 556
    x = 41 y = 533
    x = 748 y = 557
    x = 40 y = 534
    x = 747 y = 558
    x = 39 y = 535
    x = 746 y = 559
    x = 38 y = 536
    x = 745 y = 560
    x = 37 y = 537
    x = 744 y = 561
    x = 36 y = 538
    x = 743 y = 562
    x = 35 y = 539
    x = 742 y = 563
    x = 34 y = 540
    x = 741 y = 564
    x = 33 y = 541
    x = 740 y = 565
    x = 32 y = 542
    x = 739 y = 566
    x = 31 y = 543
    x = 738 y = 567
    x = 30 y = 544
    x = 737 y = 568
    x = 29 y = 545
    x = 736 y = 569
    x = 28 y = 546
    x = 735 y = 570
    x = 27 y = 547

    X:\Desktop\Programing Resit#\tests\bb2\test 2\test3>

  7. #32
    Junior Member viper_07's Avatar
    Join Date
    Jul 2011
    Location
    manchester
    Posts
    23
    My Mood
    Cheerful
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Help Please

    thats just for one ball

  8. #33
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Help Please

    And I assume that the one balll moved as expected. Is that correct?
    Now run the test with two balls.

    Did you read post#30?

  9. #34
    Junior Member viper_07's Avatar
    Join Date
    Jul 2011
    Location
    manchester
    Posts
    23
    My Mood
    Cheerful
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Help Please

    one ball is moving strange too as the print out shows it seems to be on the x axis, i saw post #30 yeah i am going to chenge the window size now

  10. #35
    Junior Member viper_07's Avatar
    Join Date
    Jul 2011
    Location
    manchester
    Posts
    23
    My Mood
    Cheerful
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Help Please

    found the problem

    for (int i=0; i<opc;i++){
    insted of
    for (int i=0; i<=opc;i++){

    now the balls are moving the same way at the same speed

  11. #36
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Help Please

    One more bug out. Maybe three left.
    Then a big redesign.

  12. The Following User Says Thank You to Norm For This Useful Post:

    viper_07 (July 10th, 2011)

  13. #37
    Junior Member viper_07's Avatar
    Join Date
    Jul 2011
    Location
    manchester
    Posts
    23
    My Mood
    Cheerful
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Help Please

    haha yeah thankyou so much for helping me with this i am most greatfull

  14. #38
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Help Please

    Ok, Good luck.

  15. #39
    Junior Member viper_07's Avatar
    Join Date
    Jul 2011
    Location
    manchester
    Posts
    23
    My Mood
    Cheerful
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Help Please

    thanks mate

Page 2 of 2 FirstFirst 12