0

Python doesn't respond when I play it. No syntax error appears either. Not sure what is wrong. I tried running another game I made which worked fine so I don't think it's my computer. error message

This is my code:

import pygame
import math

# Inisialisasi pygame
pygame.init()

# Buat window pygame dengan ukuran 800x600
screen = pygame.display.set_mode((800, 600))
poly_color=(128,128,128)

while True:

    # Gambar garis putih pada radius 200, 300, 400, 500, dan 600
    for r in range(100,210,50):
        pygame.draw.circle(screen, (128, 128, 128), (400, 300), r, 1)

    # Gambar garis-garis merah pada sudut 0, 45, 90, 135, 180, 225, 270, dan 315 derajat
    for a in range(0,360,45):
       
        x = 400 + 200 * math.cos(math.radians(a)/0.5)
        y = 300 + 200 * math.sin(math.radians(a)/0.5)
        pygame.draw.line(screen, (128, 128, 128), (400, 300), (x, y), 1)

    for b in range(0,360,30):
       
        x = 400 + 200 * math.cos(math.radians(b))
        y = 300 + 200 * math.sin(math.radians(b))
        pygame.draw.line(screen, poly_color, (400, 300), (x, y), 1)

    # Tampilkan window pygame
    pygame.display.flip()


Python doesn't respond when I play it. No syntax error appears either. Not sure what is wrong. I tried running another game I made which worked fine so I don't think it's my computer.

  • The window does not respond, because you do not handle the events. You have to handle the events by either [`pygame.event.pump()`](https://www.pygame.org/docs/ref/event.html#pygame.event.pump) or [`pygame.event.get()`](https://www.pygame.org/docs/ref/event.html#pygame.event), to keep the window responding. See [PyGame window not responding after a few seconds](https://stackoverflow.com/questions/20165492/pygame-window-not-responding-after-a-few-seconds) – Rabbid76 Dec 30 '22 at 10:15

0 Answers0