Python Not Responding when I Run it

diya joshi

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 

pygame.init()

screen = pygame.display.set_mode((800,600))

pygame.display.set_caption("Draft")

icon = pygame.image.load("doctor.png")

pygame.display.set_icon(icon)

white = (255,255,255)
black = (0,0,0) red = (255,0,0)
green = (0,255,0)
blue = (0,0,255)

def draw_ground():
    groundx = 20
    groundy = 30
    Ground = pygame.Rect(groundx,groundy,width = 800,height = 20)
    pygame.draw.rect(screen,green,Ground)

running = True
while running:

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    draw_ground()

It isn't complete yet, I'm trying to test it first before moving ahead.

Rabbid76

There is a typo in your code:

black = (0,0,0) red = (255,0,0)

It has to be

black = (0,0,0) 
red = (255,0,0)

However, there is more.


pygame.Rect does not accept keyword arguments:

Ground = pygame.Rect(groundx,groundy,width = 800,height = 20)

Ground = pygame.Rect(groundx,groundy,800,20)

You have to update the display by calling either pygame.display.update() or pygame.display.flip():

clock = pygame.time.Clock()
running = True
while running:
    clock.tick(60)
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    # clear dispaly
    screen.fill(0)

    # draw objects
    draw_ground()

    # update dispaly
    pygame.display.flip()

The typical PyGame application loop has to:

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

When I run my Python Turtle game, the Graphics Window stops responding

Pygame window not responding error when i try to run a code

My app stops responding when I run it on the Profiling mode

LabVIEW not responding when I run this code. C++ code issue or LabVIEW issue?

Application not responding when i press the back button

The function does not run when I call it, Python

Python 3.6 is not default when I run a script

pygames not working for python when I try and run it

Why I get "ImportError" only when I run a python script?

I have a problem when I try to run python command in bash

How to run Python 3 when I type "python" in windows CMD

Why is Plupload container not responding when I try to drop a file?

Input's onclick event is not responding when i declare the name="band[ ]"

Should I avoid calling require when responding to a request?

TextInput is not responding when I use TouchableWithoutFeedback in React Native

Firefox is not responding when I close all active Firefox windows and reopen

What do I do when a program stops responding?

Should I use the file system asynchronously when responding http requests?

I get a traceback error when using the command "pipenv run python"

Getting errors when I run "python manage.py check"

What is Debugger PIN when I run the flask app python

How do I run code when a Python class is evaluated

An unexpected URLError is raised when I run my compiled Python script

Can not run nosetests when i use argparse in my python code

HTTP error when I run the APMonitor nlc example in python

How do I make a function run when a program finishes in Python?

when i run my python code it continuously show syntax error

When I run python in vscode it opens a tab in my browser

Error occuring when I try to run decorator with @ - Python