2

I am very new to coding overall, so its more than likely my fault this is happening.

I tried to create a pong game using Turtle. The window would open and the background was black, the way I had meant it to be, but my curser would load and my tab would indicate 'not responding'. I then tried to switch to Pygame, I went to my command prompt and run pip install pygame. I am on Windows so this was what I was was instructed to run; I watched the download bar fill up and complete, but when i go to import pygame it got the error message no module named pygame. I tried to download pygame again and got the message requirement already satisfied. I tried to switch to Arcade yet the same thing happened. Any suggestions?

Here is my code:

import turtle
window = turtle.Screen()
window.title("i made a pong game")
window.bgcolor("black")
window.setup(width=800, height=600)
window.tracer(0)

def paddle_function():
    paddle_a = turtle.Turtle()
    paddle_a.speed(0)
    paddle_a.shape("square")
    paddle_a.color("black")
    paddle_a.shapesize(stretch_wid=5, stretch_len=1)
    paddle_a.penup()
    paddle_a.goto(-350, 0)
    turtle.mainloop()
    turtle.done()
Rabbid76
  • 202,892
  • 27
  • 131
  • 174
  • 1
    What IDE are you using to run Python? It sounds like you're installing pygame to your system environment, but that your IDE is using another environment. As far as the actual black screen issue with the `turtle` module, we can't help you without seeing your code, but it sounds like your code is probably spending all its time executing something that's taking up the main thread, and not giving any time to read the user's keyboard inputs. That's usually why Python UI programs freeze - you're doing some kind of loop in your program that blocks everything else, such as display and input. – Random Davis Sep 28 '20 at 20:24
  • import turtle window = turtle.Screen() window.title("i made a pong game") window.bgcolor("black") window.setup(width=800, height=600) window.tracer(0) def paddle_function(): paddle_a = turtle.Turtle() paddle_a.speed(0) paddle_a.shape("square") paddle_a.color("black") paddle_a.shapesize(stretch_wid=5, stretch_len=1) paddle_a.penup() paddle_a.goto(-350, 0) turtle.mainloop() turtle.done() – Blake Alvey Sep 28 '20 at 20:30
  • also im using pycharm, but i do have multiple IDE installed , how would i fix that? – Blake Alvey Sep 28 '20 at 20:30
  • 1
    You code must go in your original post, not in comments. Also, having multiple IDEs installed won't be an issue, you just have to install pygame on your project's interpreter (or configure your project to use the system interpreter). – Random Davis Sep 28 '20 at 20:33
  • 1
    Your turtle example doesn't indicate how you call `paddle_function()`; it seems like having `turtle.mainloop()` in there would be a problem if you call that function more than once. – Random Davis Sep 28 '20 at 20:39

0 Answers0