Pygame mouse cursor load/unload

A

Alex Gardner

I am in the process of making a pong game in python using the pygame library. My current problem is that when I move the mouse, it turns off as soon as the mouse stops moving. The way I am doing this is by making the default cursor invisible and using .png files as replacements for the cursor. Perhaps my code would best explain my problem. I will take help in any waythat I can. Here are the links that contain my code:



Main class: http://pastebin.com/HSQzX6h2

Main file (where the problem lies): http://pastebin.com/67p97RsJ



If the links yield nothing, please let me know ([email protected])

Sorry but im back to square one. My paddle isn't showing up at all! http://pastebin.com/PB5L8Th0
 
I

Ian Kelly

Sorry but im back to square one. My paddle isn't showing up at all! http://pastebin.com/PB5L8Th0

paddle_rect.center = pygame.mouse.get_pos()

This updates the paddle position.

screen.blit(beeper, paddle_rect)

This draws the paddle at that position.

screen.blit(bpaddle, paddle_rect)

This draws the blank paddle at that same position. Try to think about
why this results in the paddle not showing up.

If this is for a class, I think you should spend some quality time
with the TA rather than continue to throw non-functional code at this
list, which is clearly getting you nowhere.
 
A

Alex Gardner

I am in the process of making a pong game in python using the pygame library. My current problem is that when I move the mouse, it turns off as soon as the mouse stops moving. The way I am doing this is by making the default cursor invisible and using .png files as replacements for the cursor. Perhaps my code would best explain my problem. I will take help in any waythat I can. Here are the links that contain my code:



Main class: http://pastebin.com/HSQzX6h2

Main file (where the problem lies): http://pastebin.com/67p97RsJ



If the links yield nothing, please let me know ([email protected])

It's all working now with one exception. I just want to arrange the paddleto the right side. I managed to do just that, but it won't move freely vertically. I am not fully aware of the arguments of pygame.Rect(). Here iswhat I am using:


bounds_rect = pygame.Rect(880,200,0,500)


Again, it all works minus the vertcal movement. The full code (keep in mind it works fine now) is http://pastebin.com/xAAda30e

I thank you all (esp. Ian) for this help. I broke down and remade the codeand behold it works (with this exception). Oh, Ian, this isn't a class assignment; it's a personal project to help me in the process of learning python.
 
I

Ian Kelly

It's all working now with one exception. I just want to arrange the paddle to the right side. I managed to do just that, but it won't move freely vertically. I am not fully aware of the arguments of pygame.Rect().

I recommend you read the docs, then:

http://www.pygame.org/docs/ref/rect.html

In particular, the clamp method documentation states:

If the rectangle is too large to fit inside, it is centered
inside the argument Rect, but its size is not changed.

This is the case because your bounds_rect has width 0. I suggest
changing the width of the bounds_rect to be equal to the width of the
paddle.
 
A

Alex Gardner

I am in the process of making a pong game in python using the pygame library. My current problem is that when I move the mouse, it turns off as soon as the mouse stops moving. The way I am doing this is by making the default cursor invisible and using .png files as replacements for the cursor. Perhaps my code would best explain my problem. I will take help in any waythat I can. Here are the links that contain my code:



Main class: http://pastebin.com/HSQzX6h2

Main file (where the problem lies): http://pastebin.com/67p97RsJ



If the links yield nothing, please let me know ([email protected])

The docs helped (never knew they were there!) and its all safe and sound for now. Thanks :)
 
A

Alex Gardner

I am in the process of making a pong game in python using the pygame library. My current problem is that when I move the mouse, it turns off as soon as the mouse stops moving. The way I am doing this is by making the default cursor invisible and using .png files as replacements for the cursor. Perhaps my code would best explain my problem. I will take help in any waythat I can. Here are the links that contain my code:



Main class: http://pastebin.com/HSQzX6h2

Main file (where the problem lies): http://pastebin.com/67p97RsJ



If the links yield nothing, please let me know ([email protected])

All is okay save for one thing! I joined the ball and the p1 paddle in thesame program. Both of the images flicker to some extent. The paddle itself rarely shows up. I am not quite sure where / when to flip the display :(

[ http://pastebin.com/xzMwa85X ]
 
A

Alex Gardner

All is okay save for one thing! I joined the ball and the p1 paddle in the same program. Both of the images flicker to some extent. The paddle itself rarely shows up. I am not quite sure where / when to flip the display :(



[ http://pastebin.com/i1GbT6JB ]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,149
Latest member
Vinay Kumar Nevatia0
Top