Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #40382 > unrolled thread
| Started by | Alex Gardner <agardner210@gmail.com> |
|---|---|
| First post | 2013-03-02 17:56 -0800 |
| Last post | 2013-03-18 16:05 -0700 |
| Articles | 20 on this page of 28 — 3 participants |
Back to article view | Back to comp.lang.python
Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-02 17:56 -0800
Re: Pygame mouse cursor load/unload Ian Kelly <ian.g.kelly@gmail.com> - 2013-03-02 20:08 -0700
Re: Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-02 19:52 -0800
Re: Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-02 19:52 -0800
Re: Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-03 14:04 -0800
Re: Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-03 14:09 -0800
Re: Pygame mouse cursor load/unload Ian Kelly <ian.g.kelly@gmail.com> - 2013-03-03 16:47 -0700
Re: Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-09 16:20 -0800
Re: Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-09 16:25 -0800
Re: Pygame mouse cursor load/unload Ian Kelly <ian.g.kelly@gmail.com> - 2013-03-10 13:23 -0600
Re: Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-10 15:25 -0700
Re: Pygame mouse cursor load/unload Ian Kelly <ian.g.kelly@gmail.com> - 2013-03-10 19:26 -0600
Re: Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-11 09:57 -0700
Re: Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-11 10:00 -0700
Re: Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-11 10:04 -0700
Re: Pygame mouse cursor load/unload Ian Kelly <ian.g.kelly@gmail.com> - 2013-03-11 11:24 -0600
Re: Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-11 10:33 -0700
Re: Pygame mouse cursor load/unload Ian Kelly <ian.g.kelly@gmail.com> - 2013-03-11 12:01 -0600
Re: Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-11 13:43 -0700
Re: Pygame mouse cursor load/unload MRAB <python@mrabarnett.plus.com> - 2013-03-11 20:54 +0000
Re: Pygame mouse cursor load/unload Ian Kelly <ian.g.kelly@gmail.com> - 2013-03-11 15:23 -0600
Re: Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-12 16:33 -0700
Re: Pygame mouse cursor load/unload Ian Kelly <ian.g.kelly@gmail.com> - 2013-03-12 21:00 -0600
Re: Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-14 15:16 -0700
Re: Pygame mouse cursor load/unload Ian Kelly <ian.g.kelly@gmail.com> - 2013-03-14 16:31 -0600
Re: Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-14 15:56 -0700
Re: Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-18 13:24 -0700
Re: Pygame mouse cursor load/unload Alex Gardner <agardner210@gmail.com> - 2013-03-18 16:05 -0700
Page 1 of 2 [1] 2 Next page →
| From | Alex Gardner <agardner210@gmail.com> |
|---|---|
| Date | 2013-03-02 17:56 -0800 |
| Subject | Pygame mouse cursor load/unload |
| Message-ID | <d6374016-8863-4e8b-9ec9-17a826ca2eee@googlegroups.com> |
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 way that 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 (agardner210@gmail.com)
[toc] | [next] | [standalone]
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2013-03-02 20:08 -0700 |
| Message-ID | <mailman.2809.1362280147.2939.python-list@python.org> |
| In reply to | #40382 |
On Sat, Mar 2, 2013 at 6:56 PM, Alex Gardner <agardner210@gmail.com> wrote:
> 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 way that I can. Here are the links that contain my code:
Your mouse motion code draws the paddle in the new position, waits
1/10th of a second, and then draws over it again with the "invisible"
paddle. Thus, approximately 1/10th of a second after you stop moving
the mouse, it disappears.
Mouse motion events are probably not the best way to do this. You can
instead just capture the current position of the mouse on every frame
and use that instead. I replaced your main loop with the following:
paddle_pos = (0, 0)
clock = pygame.time.Clock()
while True:
for event in pygame.event.get():
if event.type == QUIT:
sys.exit()
# Erase the paddle from the old mouse position.
screen.blit(bpaddle, paddle_pos)
# Redraw the net before the paddle so that the paddle can appear over it.
pygame.draw.line(screen, game.lineColor, game.net1, game.net2,
game.netWidth)
# Get the new mouse position.
paddle_pos = pygame.mouse.get_pos()
# Draw the paddle at the new mouse position.
screen.blit(beeper, paddle_pos)
# Update the screen if it's double-buffered.
pygame.display.update()
# Finally, let the CPU idle until it's time for the next frame.
# 50 here means that it will sleep long enough to achieve 50 FPS.
clock.tick(50)
And I think you will find that this does what you want.
A couple more observations while I'm at it. Generally there is no
need to be calling pygame.display.update() multiple times per frame.
Just draw everything that you need, and then call it once at the end
of the loop, as I have shown above. Also, the shebang line only does
anything if it's the very first line in the file, so it would need to
appear before the module docstring to do anything useful.
[toc] | [prev] | [next] | [standalone]
| From | Alex Gardner <agardner210@gmail.com> |
|---|---|
| Date | 2013-03-02 19:52 -0800 |
| Message-ID | <4010f9c7-7a1a-4168-ac32-841d7d8ba486@googlegroups.com> |
| In reply to | #40390 |
On Saturday, March 2, 2013 9:08:18 PM UTC-6, Ian wrote: > On Sat, Mar 2, 2013 at 6:56 PM, Alex Gardner <agardner210@gmail.com> wrote: > > > 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 way that I can. Here are the links that contain my code: > > > > Your mouse motion code draws the paddle in the new position, waits > > 1/10th of a second, and then draws over it again with the "invisible" > > paddle. Thus, approximately 1/10th of a second after you stop moving > > the mouse, it disappears. > > > > Mouse motion events are probably not the best way to do this. You can > > instead just capture the current position of the mouse on every frame > > and use that instead. I replaced your main loop with the following: > > > > paddle_pos = (0, 0) > > clock = pygame.time.Clock() > > > > while True: > > for event in pygame.event.get(): > > if event.type == QUIT: > > sys.exit() > > > > # Erase the paddle from the old mouse position. > > screen.blit(bpaddle, paddle_pos) > > # Redraw the net before the paddle so that the paddle can appear over it. > > pygame.draw.line(screen, game.lineColor, game.net1, game.net2, > > game.netWidth) > > # Get the new mouse position. > > paddle_pos = pygame.mouse.get_pos() > > # Draw the paddle at the new mouse position. > > screen.blit(beeper, paddle_pos) > > # Update the screen if it's double-buffered. > > pygame.display.update() > > # Finally, let the CPU idle until it's time for the next frame. > > # 50 here means that it will sleep long enough to achieve 50 FPS. > > clock.tick(50) > > > > And I think you will find that this does what you want. > > > > A couple more observations while I'm at it. Generally there is no > > need to be calling pygame.display.update() multiple times per frame. > > Just draw everything that you need, and then call it once at the end > > of the loop, as I have shown above. Also, the shebang line only does > > anything if it's the very first line in the file, so it would need to > > appear before the module docstring to do anything useful. Thank you very much, Ian. I understand the code and have learned from it. If I were more knowledgeable in python I wouldn't have had to ask; I am learning as I go with this project. Again, thank you :)
[toc] | [prev] | [next] | [standalone]
| From | Alex Gardner <agardner210@gmail.com> |
|---|---|
| Date | 2013-03-02 19:52 -0800 |
| Message-ID | <mailman.2813.1362282722.2939.python-list@python.org> |
| In reply to | #40390 |
On Saturday, March 2, 2013 9:08:18 PM UTC-6, Ian wrote: > On Sat, Mar 2, 2013 at 6:56 PM, Alex Gardner <agardner210@gmail.com> wrote: > > > 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 way that I can. Here are the links that contain my code: > > > > Your mouse motion code draws the paddle in the new position, waits > > 1/10th of a second, and then draws over it again with the "invisible" > > paddle. Thus, approximately 1/10th of a second after you stop moving > > the mouse, it disappears. > > > > Mouse motion events are probably not the best way to do this. You can > > instead just capture the current position of the mouse on every frame > > and use that instead. I replaced your main loop with the following: > > > > paddle_pos = (0, 0) > > clock = pygame.time.Clock() > > > > while True: > > for event in pygame.event.get(): > > if event.type == QUIT: > > sys.exit() > > > > # Erase the paddle from the old mouse position. > > screen.blit(bpaddle, paddle_pos) > > # Redraw the net before the paddle so that the paddle can appear over it. > > pygame.draw.line(screen, game.lineColor, game.net1, game.net2, > > game.netWidth) > > # Get the new mouse position. > > paddle_pos = pygame.mouse.get_pos() > > # Draw the paddle at the new mouse position. > > screen.blit(beeper, paddle_pos) > > # Update the screen if it's double-buffered. > > pygame.display.update() > > # Finally, let the CPU idle until it's time for the next frame. > > # 50 here means that it will sleep long enough to achieve 50 FPS. > > clock.tick(50) > > > > And I think you will find that this does what you want. > > > > A couple more observations while I'm at it. Generally there is no > > need to be calling pygame.display.update() multiple times per frame. > > Just draw everything that you need, and then call it once at the end > > of the loop, as I have shown above. Also, the shebang line only does > > anything if it's the very first line in the file, so it would need to > > appear before the module docstring to do anything useful. Thank you very much, Ian. I understand the code and have learned from it. If I were more knowledgeable in python I wouldn't have had to ask; I am learning as I go with this project. Again, thank you :)
[toc] | [prev] | [next] | [standalone]
| From | Alex Gardner <agardner210@gmail.com> |
|---|---|
| Date | 2013-03-03 14:04 -0800 |
| Message-ID | <4294807e-4798-4eb1-873d-7ea169c08fc7@googlegroups.com> |
| In reply to | #40382 |
On Saturday, March 2, 2013 7:56:31 PM UTC-6, Alex Gardner wrote:
> 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 way that 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 (agardner210@gmail.com)
I have a new problem :(. I want to restrict the paddle to a certain plane. I have it working but when the paddle reaches the limit it locks up. I have no idea how I can redraw it back in the plane. I am using the code that Ian provided (thank you so much). I was thinking of making an else to redraw the paddle using the same code, but part of me thinks that it would be rather sloppy.
if (0,0) <= paddle_pos <= (300,300):
paddle_pos = pygame.mouse.get_pos()
screen.blit(beeper, paddle_pos)
pygame.display.update()
clock.tick(50)
[toc] | [prev] | [next] | [standalone]
| From | Alex Gardner <agardner210@gmail.com> |
|---|---|
| Date | 2013-03-03 14:09 -0800 |
| Message-ID | <9c352284-08c4-439e-b324-caffa3718429@googlegroups.com> |
| In reply to | #40382 |
On Saturday, March 2, 2013 7:56:31 PM UTC-6, Alex Gardner wrote:
> 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 way that 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 (agardner210@gmail.com)
I have a new problem that I'm dealing with. I want to restrict the paddle to a certain plane. When the paddle reaches the boundary, it locks up. I am using the code that Ian provided earlier (thank you so much). Here is what I have so far:
if (0,0) <= paddle_pos <= (300,300):
paddle_pos = pygame.mouse.get_pos()
screen.blit(beeper, paddle_pos)
pygame.display.update()
clock.tick(50)
I tried making an else statement and copying Ian's code in it, but I don't think that it would work. I have tried to fix this myself; this is my second GUI program that I have ever made.... please forgive me if I seem needy.
[toc] | [prev] | [next] | [standalone]
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2013-03-03 16:47 -0700 |
| Message-ID | <mailman.2828.1362354471.2939.python-list@python.org> |
| In reply to | #40424 |
On Sun, Mar 3, 2013 at 3:09 PM, Alex Gardner <agardner210@gmail.com> wrote: > if (0,0) <= paddle_pos <= (300,300): This doesn't do what you think it does. Tuples are compared lexicographically, not element-wise. So (250, 350) < (300, 300), but (350, 250) > (300, 300). > paddle_pos = pygame.mouse.get_pos() > screen.blit(beeper, paddle_pos) > pygame.display.update() > clock.tick(50) You're updating paddle_pos inside the if block. Once paddle_pos falls outside that range, the if block won't trigger, and paddle_pos will no longer be updated, so it will never fall inside that range again. pygame has a Rect class for rectangle logic that can solve both of these problems for you. Given: paddle_rect = beeper.get_rect() bounds_rect = pygame.Rect(0, 0, 300, 300) your position update code then becomes: paddle_rect.center = pygame.mouse.get_pos() paddle_rect.clamp_ip(bounds_rect) Note that paddle_rect can replace paddle_pos entirely. The code: screen.blit(beeper, paddle_pos) simply becomes: screen.blit(beeper, paddle_rect)
[toc] | [prev] | [next] | [standalone]
| From | Alex Gardner <agardner210@gmail.com> |
|---|---|
| Date | 2013-03-09 16:20 -0800 |
| Message-ID | <45fee47a-1e4d-4a38-b368-3e95d128d854@googlegroups.com> |
| In reply to | #40382 |
On Saturday, March 2, 2013 7:56:31 PM UTC-6, Alex Gardner wrote: > 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 way that 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 (agardner210@gmail.com) I followed your advice, but now I have a drawing problem. I simply tried rewriting the paddle with a black one, but its failing. I would like to pester you fine folks one last time. The code is here: http://pastebin.com/gVPPJYWs I really appreciate your help and am learning from your advice. Thank you so much, Alex
[toc] | [prev] | [next] | [standalone]
| From | Alex Gardner <agardner210@gmail.com> |
|---|---|
| Date | 2013-03-09 16:25 -0800 |
| Message-ID | <d7296c8c-589f-4955-8643-70dd93ac5dbf@googlegroups.com> |
| In reply to | #40382 |
On Saturday, March 2, 2013 7:56:31 PM UTC-6, Alex Gardner wrote: > 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 way that 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 (agardner210@gmail.com) I would like to bother you fine folks one last time! There are drawing problems that I am running into. The paddle keeps on moving but it doesn't rewrite the black paddle. This is a problem because the paddle just keeps leaving a green trail. The code is here: http://pastebin.com/gVPPJYWs I feel as though I am missing something...
[toc] | [prev] | [next] | [standalone]
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2013-03-10 13:23 -0600 |
| Message-ID | <mailman.3165.1362943457.2939.python-list@python.org> |
| In reply to | #40988 |
On Sat, Mar 9, 2013 at 5:25 PM, Alex Gardner <agardner210@gmail.com> wrote: > On Saturday, March 2, 2013 7:56:31 PM UTC-6, Alex Gardner wrote: >> 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 way that 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 (agardner210@gmail.com) > > I would like to bother you fine folks one last time! There are drawing problems that I am running into. The paddle keeps on moving but it doesn't rewrite the black paddle. This is a problem because the paddle just keeps leaving a green trail. The code is here: http://pastebin.com/gVPPJYWs > > I feel as though I am missing something... You get the streaking because the first blanking operation only ever blanks at (0, 0), and the second one blanks at the new paddle position, not the previous position. You don't need two separate rects to keep track of where the paddle is. blank_rect and b_bounds_rect are entirely unnecessary, so get rid of them. The line "screen.blit(bpaddle, paddle_pos)" should be replaced with "screen.blit(bpaddle, paddle_rect)", because paddle_rect is what you're using to track the paddle location. Since paddle_pos is not being updated, the former would always draw the blank paddle in the upper-left corner. This should also be the only place where you're blanking the paddle, so get rid of the other one. You also don't need the if statement at all. The clamping operation already ensures that the paddle is bounded to the region (0, 0, 300, 300). Once that's gone, you no longer need paddle_pos at all, so you can delete that as well.
[toc] | [prev] | [next] | [standalone]
| From | Alex Gardner <agardner210@gmail.com> |
|---|---|
| Date | 2013-03-10 15:25 -0700 |
| Message-ID | <8d5299d0-dcf2-4f16-985c-d1f4a5e1ac69@googlegroups.com> |
| In reply to | #40382 |
On Saturday, March 2, 2013 7:56:31 PM UTC-6, Alex Gardner wrote: > 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 way that 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 (agardner210@gmail.com) Now the cursor isn't moving at all! while True: for event in pygame.event.get(): if event.type == QUIT: sys.exit() screen.blit(bpaddle, paddle_rect) # Draw the net pygame.draw.line(screen, game.lineColor, game.net1, game.net2, game.netWidth) paddle_rect.clamp_ip(bounds_rect) screen.blit(beeper, paddle_rect) clock.tick(50) pygame.display.update()
[toc] | [prev] | [next] | [standalone]
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2013-03-10 19:26 -0600 |
| Message-ID | <mailman.3173.1362965257.2939.python-list@python.org> |
| In reply to | #41043 |
On Sun, Mar 10, 2013 at 4:25 PM, Alex Gardner <agardner210@gmail.com> wrote: > Now the cursor isn't moving at all! > > while True: > for event in pygame.event.get(): > if event.type == QUIT: > sys.exit() > > screen.blit(bpaddle, paddle_rect) > # Draw the net > pygame.draw.line(screen, game.lineColor, game.net1, game.net2, game.netWidth) > > paddle_rect.clamp_ip(bounds_rect) > screen.blit(beeper, paddle_rect) > > clock.tick(50) > > pygame.display.update() You deleted the line where you update the paddle_rect from the current mouse position.
[toc] | [prev] | [next] | [standalone]
| From | Alex Gardner <agardner210@gmail.com> |
|---|---|
| Date | 2013-03-11 09:57 -0700 |
| Message-ID | <32c01b7e-a118-44f3-a79c-8ca7bc0916cf@googlegroups.com> |
| In reply to | #40382 |
On Saturday, March 2, 2013 7:56:31 PM UTC-6, Alex Gardner wrote: > 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 way that 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 (agardner210@gmail.com) I added the blank paddle and now the green one is just gone..... I feel like such a newbie ><
[toc] | [prev] | [next] | [standalone]
| From | Alex Gardner <agardner210@gmail.com> |
|---|---|
| Date | 2013-03-11 10:00 -0700 |
| Message-ID | <e73490d8-7013-4ed1-b348-ff2fba2e849f@googlegroups.com> |
| In reply to | #41075 |
On Monday, March 11, 2013 11:57:49 AM UTC-5, Alex Gardner wrote: > On Saturday, March 2, 2013 7:56:31 PM UTC-6, Alex Gardner wrote: > > > 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 way that 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 (agardner210@gmail.com) > > > I added the blank paddle and now the green one is just gone..... I feel like such a newbie >< screen.blit(bpaddle, paddle_rect)
[toc] | [prev] | [next] | [standalone]
| From | Alex Gardner <agardner210@gmail.com> |
|---|---|
| Date | 2013-03-11 10:04 -0700 |
| Message-ID | <6c7e41eb-57a1-4a05-84ca-1285813100ce@googlegroups.com> |
| In reply to | #41076 |
On Monday, March 11, 2013 12:00:37 PM UTC-5, Alex Gardner wrote: > On Monday, March 11, 2013 11:57:49 AM UTC-5, Alex Gardner wrote: > > > On Saturday, March 2, 2013 7:56:31 PM UTC-6, Alex Gardner wrote: > > > > > > > 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 way that 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 (agardner210@gmail.com) > > > > > > > > > > > > > I added the blank paddle after the green one and now the green one is just gone..... I feel like such a newbie >< > screen.blit(bpaddle, paddle_rect)
[toc] | [prev] | [next] | [standalone]
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2013-03-11 11:24 -0600 |
| Message-ID | <mailman.3197.1363022695.2939.python-list@python.org> |
| In reply to | #41076 |
On Mon, Mar 11, 2013 at 11:00 AM, Alex Gardner <agardner210@gmail.com> wrote: > I added the blank paddle and now the green one is just gone..... I feel like such a newbie >< > > > screen.blit(bpaddle, paddle_rect) We're not psychic, so you'll need to post the current code if you want any suggestions on how to fix it.
[toc] | [prev] | [next] | [standalone]
| From | Alex Gardner <agardner210@gmail.com> |
|---|---|
| Date | 2013-03-11 10:33 -0700 |
| Message-ID | <5cd72005-e3c3-4ab7-850c-5c2e55e74353@googlegroups.com> |
| In reply to | #40382 |
On Saturday, March 2, 2013 7:56:31 PM UTC-6, Alex Gardner wrote: > 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 way that 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 (agardner210@gmail.com) My bad! http://pastebin.com/yuvpT7bH
[toc] | [prev] | [next] | [standalone]
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2013-03-11 12:01 -0600 |
| Message-ID | <mailman.3200.1363024956.2939.python-list@python.org> |
| In reply to | #41080 |
On Mon, Mar 11, 2013 at 11:33 AM, Alex Gardner <agardner210@gmail.com> wrote: > My bad! http://pastebin.com/yuvpT7bH You're still drawing the blank paddle in two different places. One of those places is immediately after you draw the paddle, which undoes the work you just did in drawing it. That's why you're not seeing the paddle. You're also still not updating the paddle_rect from the current mouse position, so if you fix the above issue you will find that the paddle still will not move. You should restore the "paddle_rect.center = pygame.mouse.get_pos()" line that you deleted prior to the line that clamps it. Finally, you currently have the "clock.tick()" call before the "pygame.display.update()" call, which makes no sense. You're doing your drawing, asking pygame to sleep for 20 milliseconds, and only then updating the display. You want to update the display before the clock.tick() so that the user can actually see the most recent frame during those 20 milliseconds.
[toc] | [prev] | [next] | [standalone]
| From | Alex Gardner <agardner210@gmail.com> |
|---|---|
| Date | 2013-03-11 13:43 -0700 |
| Message-ID | <cc22b584-ed70-4a3e-b342-bb8d6c289891@googlegroups.com> |
| In reply to | #40382 |
On Saturday, March 2, 2013 7:56:31 PM UTC-6, Alex Gardner wrote:
> 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 way that 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 (agardner210@gmail.com)
I tried to append what you told me to. Now it appears that I have a syntax error! I checked my indentations and they look fine to me, but I get this error:
paddle_pos = pygame.mouse.get_pos()
^
IndentationError: unindent does not match any outer indentation level
I added "paddle_rect.center = pygame.mouse.get_pos()" and removed the double blank paddles. I have no idea if it works though because of the parse error! New code: http://pastebin.com/maqWCdNB
[toc] | [prev] | [next] | [standalone]
| From | MRAB <python@mrabarnett.plus.com> |
|---|---|
| Date | 2013-03-11 20:54 +0000 |
| Message-ID | <mailman.3207.1363035241.2939.python-list@python.org> |
| In reply to | #41091 |
On 11/03/2013 20:43, Alex Gardner wrote: > On Saturday, March 2, 2013 7:56:31 PM UTC-6, Alex Gardner wrote: >> 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 way that 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 (agardner210@gmail.com) > I tried to append what you told me to. Now it appears that I have a syntax error! I checked my indentations and they look fine to me, but I get this error: > > paddle_pos = pygame.mouse.get_pos() > ^ > IndentationError: unindent does not match any outer indentation level > > I added "paddle_rect.center = pygame.mouse.get_pos()" and removed the double blank paddles. I have no idea if it works though because of the parse error! New code: http://pastebin.com/maqWCdNB > It's complaining because the preceding 'for' loop is indented more that that line.
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | comp.lang.python
csiph-web