0

I have instantiated the function initPaddle(). The function returns a paddle and I can see it in the window at various location coordinates that I provide. But, when I provide location coordinates corresponding to the bottom middle of the window (i.e. WIDTH/2 - PADDLE_WIDTH/2, HEIGHT - PADDLE_HEIGHT), my paddle vanishes from the window. What is wrong and why I cannot see the paddle inside the window?

  • Could you post the part of the paddle you coded here? So people can take a look at it and give you some suggestions. – Viet Nguyen Apr 18 '15 at 4:26
  • After declaring constants, I wrote the following code: GRect paddle = newGRect(WIDTH/2 - PADDLE_WIDTH/2, HEIGHT - PADDLE_HEIGHT, PADDLE_WIDTH, PADDLE_HEIGHT); setColor(paddle, "BLACK"); setFilled(paddle, true); add(window, paddle); return paddle; – Bireschandra Bhaumik Apr 18 '15 at 4:34
  • If you can place the paddle arbitrarily by just using numbers, then the vars for placement are suspect. Try printing them out using printf() and see what they really are. Also, you might consider putting some arbitrary space between the bottom of the paddle and the bottom of the window, much like the original breakout by using, for instance, "HEIGHT - 50"? Adjust the number until it looks nice. – Cliff B Apr 18 '15 at 5:21
  • The paddle could be placed at desired positions by varying the coordinates of top left hand corner of the paddle in terms of constants. Now I have raised the position of the paddle a little and it looks ok. – Bireschandra Bhaumik Apr 18 '15 at 16:15

You must log in to answer this question.

Browse other questions tagged .