• 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.

6 replies to this topic

### #1Zed McJack  Members

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?

### #2frob  Moderators

41398
Like
0Likes
Like

Posted 31 October 2012 - 02:16 PM

Check out my book, Game Development with Unity, aimed at beginners who want to build fun games fast.

Also check out my personal website at bryanwagstaff.com, where I occasionally write about assorted stuff.

### #3caldiar  Members

715
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.

### #4Zed McJack  Members

349
Like
0Likes
Like

Posted 31 October 2012 - 02:22 PM

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

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

return pict, pict.get_rect()


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

### #5frob  Moderators

41398
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 book, Game Development with Unity, aimed at beginners who want to build fun games fast.

Also check out my personal website at bryanwagstaff.com, where I occasionally write about assorted stuff.

### #6Zed McJack  Members

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?
Thanks a lot.

### #7Zed McJack  Members

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.