Jump to content

  • Log In with Google      Sign In   
  • Create Account

Created Rect is bigger then circle in it, why?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 Zed McJack   Members   -  Reputation: 349

Like
0Likes
Like

Posted 31 October 2012 - 02:05 PM

HI,

I started my Pong game and was wondering why is Rect bigger then the circle in it?

Attached Thumbnails

  • mypong.jpg


Sponsor:

#2 frob   Moderators   -  Reputation: 21245

Like
0Likes
Like

Posted 31 October 2012 - 02:16 PM

A link to your code would be useful.
Check out my personal indie blog at bryanwagstaff.com.

#3 caldiar   Members   -  Reputation: 702

Like
0Likes
Like

Posted 31 October 2012 - 02:18 PM

From the looks of it, you have a circle image that most likely has excess empty space around it. Make sure you trim all the excess blank space off from around the circle so that the image is no larger than the square needed to contain the circle.

However I can't be 100% positive that this is the case. It helps to be a bit more verbose with what you expect, what actually happened, and what you tried to do in order to fix it. Relevant code doesn't hurt either ;)

Hopefully it's just that you need to trim the image to fit the circle better.

EDIT: I'm making more assumptions than I usually do. I'm assuming you're making a rect with the same dimensions as your image which you want to use.

Edited by caldiar, 31 October 2012 - 02:21 PM.


#4 Zed McJack   Members   -  Reputation: 349

Like
0Likes
Like

Posted 31 October 2012 - 02:22 PM

A link to your code would be useful.

Sorry, I thought there is a reson for it beside my erronous code Posted Image
def draw_circle(radius, color):

size = radius * 3

pict = pygame.Surface((size, size))

pygame.draw.circle( pict, color, (radius, radius), radius)

return pict, pict.get_rect()

Edited by Zed McJack, 31 October 2012 - 02:51 PM.


#5 frob   Moderators   -  Reputation: 21245

Like
0Likes
Like

Posted 31 October 2012 - 03:12 PM

>> size = radius * 3

The width of a circle is twice its radius, not three times its radius.
Check out my personal indie blog at bryanwagstaff.com.

#6 Zed McJack   Members   -  Reputation: 349

Like
0Likes
Like

Posted 31 October 2012 - 03:26 PM

>> size = radius * 3

The width of a circle is twice its radius, not three times its radius.

Hey, where I was looking at? Posted Image
Thanks a lot.

#7 Zed McJack   Members   -  Reputation: 349

Like
0Likes
Like

Posted 31 October 2012 - 03:30 PM

And when I have opportunity to ask...
Why is code segment in my replay in one row instead as it was in message editor? Should I add <br> to force new line?




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS