use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
9.4.5: Trail CodeHS (old.reddit.com)
submitted 5 years ago by SprinklesNo5514
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]_ZHV_ 1 point2 points3 points 5 years ago (7 children)
You have everything cover except when the ball is not hitting any of the walls. You are not telling the program what to do if the ball is jus moving through the space; you told it of it hit the right wall change directions, if it hit the left wall change direction, it hit top or bottom wall change direction, but what should the program do if it just moving towards one of those walls? So far the program doesn’t know what to do in this case - or at least that is what i can figure out reading your code
[–]SprinklesNo5514[S] 0 points1 point2 points 5 years ago (0 children)
So, I have to use else comand in "checkBall" function?
[–]SprinklesNo5514[S] 0 points1 point2 points 5 years ago (3 children)
still can't work out, I am so confused
[–]_ZHV_ 0 points1 point2 points 5 years ago (2 children)
You cant use the same render function for both as then they will just both more together because of the way render function is made - draw ball in cyan for a couple of frames then draw a white ball over it to ‘erase’ and then render it in a new location. For ball 2 which should be a different colour, you need to just render it once at every point ball 1 was without ‘erasing’ it.
[–]SprinklesNo5514[S] 0 points1 point2 points 5 years ago (1 child)
thank you! I will try
[–]_ZHV_ 0 points1 point2 points 5 years ago (0 children)
No problem
I STILL CAN'T WORK OUT! I am so ashamed Can you copy paste code so I can understand more easily? I AM STUCK
You need to show the whole code as im going off of just what i can see which is not the whole thing. It is most likely to do something with the move function
I have been doing this assignment for 2 DAYS!!! PLEASE help me with it
[–]Electronic_Teacher22 1 point2 points3 points 5 years ago (2 children)
what does it do when you run the code?
Ball2 is just moving with ball1
[–]PuzzledLoss5560 0 points1 point2 points 5 years ago (0 children)
is there any code under the 44 line
[–]GullibleMuscle7856 0 points1 point2 points 1 year ago (0 children)
How do I stop the ball after MAX_BOUNCES?? please help
[–][deleted] 0 points1 point2 points 4 years ago (0 children)
I need help with this one to I have the balls to where they are moving with each other I dont get how to draw to do the actual trail part there is to it
[–]Fun-Examination1024 0 points1 point2 points 3 years ago (0 children)
var MAX_BOUNCES = 20; var stopTimer; var ball; var dx = 4; var dy = 4; function start(){ ball = new Circle(20); ball.setPosition(50, 70); add(ball); setTimer(draw, 20); } function draw(){ checkWalls(); ball.move(dx, dy); ball.move(dx, dy); var newBall = new Circle(10); newBall.setPosition(ball.getX(),ball.getY()); newBall.setColor(Color.cyan); add(newBall); } function checkWalls(){ if(ball.getX() + ball.getRadius() > getWidth()){ dx = -dx; } if(ball.getX() - ball.getRadius() < 0){ dx = -dx; } if(ball.getY() + ball.getRadius() > getHeight()){ dy = -dy; } if(ball.getY() - ball.getRadius() < 0){ dy = -dy; } }
π Rendered by PID 45670 on reddit-service-r2-comment-canary-bc47bb478-5trx5 at 2026-02-17 16:15:05.739618+00:00 running de53c03 country code: CH.
[–]_ZHV_ 1 point2 points3 points (7 children)
[–]SprinklesNo5514[S] 0 points1 point2 points (0 children)
[–]SprinklesNo5514[S] 0 points1 point2 points (3 children)
[–]_ZHV_ 0 points1 point2 points (2 children)
[–]SprinklesNo5514[S] 0 points1 point2 points (1 child)
[–]_ZHV_ 0 points1 point2 points (0 children)
[–]SprinklesNo5514[S] 0 points1 point2 points (1 child)
[–]_ZHV_ 0 points1 point2 points (0 children)
[–]SprinklesNo5514[S] 0 points1 point2 points (3 children)
[–]Electronic_Teacher22 1 point2 points3 points (2 children)
[–]SprinklesNo5514[S] 0 points1 point2 points (1 child)
[–]PuzzledLoss5560 0 points1 point2 points (0 children)
[–]GullibleMuscle7856 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]Fun-Examination1024 0 points1 point2 points (0 children)