Python Forum
Pygame in 90 Minutes - For Beginners syntax issues
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pygame in 90 Minutes - For Beginners syntax issues
#3
Just a few typos. This is mainly use for testing.
# It double underscore.
if __name__ == '__main__':
    # It lower case main to match your function.
    main()
Example
import pygame

def main():
    # Active all pygame modules.
    pygame.init()
    surface = pygame.display.set_mode((900, 500))
    # Get the area of the surface as a rect.
    rect = surface.get_rect()
    clock = pygame.time.Clock()
    fps = 60

    run = True
    while run:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                run = False

        surface.fill('black')
        # Render surface to screen.
        pygame.display.flip()
        # Let the computer do other jobs or rest.
        clock.tick(fps)

    pygame.quit()

main()
GoldenHarvey likes this post
99 percent of computer problems exists between chair and keyboard.
Reply


Messages In This Thread
RE: Pygame in 90 Minutes - For Beginners syntax issues - by Windspar - Jun-08-2023, 07:38 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyGame] Beginners to share pygame project? michael1789 4 3,230 Dec-04-2019, 07:17 AM
Last Post: michael1789
  [PyGame] Python pygame hangs up after 40 minutes chileflora 10 4,912 Jul-28-2019, 01:30 AM
Last Post: chileflora
  Beginners question Youmanity 4 3,920 Apr-08-2018, 07:02 PM
Last Post: Youmanity

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020