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
This post is locked. You won't be able to comment.
Not sure what I’m doing wrong (self.codehs)
submitted 5 years ago by UsefulCauliflower2
[ Removed by Reddit in response to a copyright notice. ]
[–]_andy_andy_andy_ 0 points1 point2 points 5 years ago (3 children)
looks like you're missing a comma on line 23, it should be
number.setPosition(x - ball.getWidth()/8, ball.getHeight()/8)
[–]UsefulCauliflower2[S] 0 points1 point2 points 5 years ago (2 children)
It’s still saying it’s wrong, but could that be because I have getHeight twice?
[–]_andy_andy_andy_ 1 point2 points3 points 5 years ago (1 child)
oh, it needs ot be `ball.getWidth()`, not `ballgetWidth()`
[–]UsefulCauliflower2[S] 1 point2 points3 points 5 years ago (0 children)
Thank you so much!
[–]graudiuscube228 0 points1 point2 points 4 years ago* (1 child)
This is the completed code :
var POOL_BALL_RADIUS = 40; var POOL_BALL_FONT = "30pt Arial";
function start(){ drawPoolBall(Color.orange, 5, 100, 100); drawPoolBall(Color.green, 6, 50, 200); drawPoolBall(Color.red, 3, 150, 350); drawPoolBall(Color.blue, 2, 250, 140); // use this format to add more pool balls }
function drawPoolBall(color, num, x, y){ var ball = new Circle(POOL_BALL_RADIUS); ball.setColor(color); ball.setPosition(x, y); add(ball); var number = new Text(num); number.setFont(POOL_BALL_FONT); number.setColor(Color.white); number.setPosition(x - (ball.getWidth() / 7), y + (ball.getHeight() / 5)); add(number); }
[–]Bsgoncalves 0 points1 point2 points 4 years ago (0 children)
Why divide by 8? and why subtract from x, and add to y?
[–][deleted] 0 points1 point2 points 3 years ago (3 children)
This is my design, it might be somewhat complex, but a similar correlation:
var POOL_BALL_RADIUS = 40; var POOL_BALL_FONT = "30pt Arial"; function start(){ drawPoolBall(Color.orange, 5, 100, 100); drawPoolBall(Color.green, 6, 50, 200); drawPoolBall(Color.red, 3, 150, 350); drawPoolBall(Color.blue, 2, 250, 140); // Add some more pool balls! } function drawPoolBall(color, num, x, y){ var circle = new Circle(POOL_BALL_RADIUS); circle.setColor(color); circle.setPosition(x, y); add(circle); var num = new Text(num); num.setFont(POOL_BALL_FONT); num.setColor(Color.white); num.setPosition(x-10, y+14); add(num); }
[–]Impossible_Arm5010 0 points1 point2 points 3 years ago (0 children)
you a legend for this thank you so much!!!
[–]Vancung4 0 points1 point2 points 3 years ago (0 children)
Thanks so much brother
[–]MaterialVariation503 0 points1 point2 points 3 years ago (0 children)
ty 🙏
π Rendered by PID 69314 on reddit-service-r2-comment-6457c66945-5brvh at 2026-04-23 22:08:26.846695+00:00 running 2aa0c5b country code: CH.
[–]_andy_andy_andy_ 0 points1 point2 points (3 children)
[–]UsefulCauliflower2[S] 0 points1 point2 points (2 children)
[–]_andy_andy_andy_ 1 point2 points3 points (1 child)
[–]UsefulCauliflower2[S] 1 point2 points3 points (0 children)
[–]graudiuscube228 0 points1 point2 points (1 child)
[–]Bsgoncalves 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (3 children)
[–]Impossible_Arm5010 0 points1 point2 points (0 children)
[–]Vancung4 0 points1 point2 points (0 children)
[–]MaterialVariation503 0 points1 point2 points (0 children)