This tutorial assumes you have already install Python and PyGame onto your machine. This is one of the most basic PyGame programs you could make and all it does is get a window setup for further coding. The code is pretty easy to follow along. You basically just initiate PyGame and then setup your window properties. Then you use PyGame to draw the window to the screen.
The code is:
# Michael L. Kelley Jr.# 2/20/2019# Pygame Window Demo # Include statementsimport sys
import pygame def Run_Game(): # Initiate pygame pygame.init() # Initiate pygame window
windowSurface = pygame.display.set_mode((640, 480), 0, 32)pygame.display.set_caption('Window Title Goes Here') # Keep the window visible until quit
GameRunning = True
while GameRunning:
for event in pygame.event.get():
if event.type == pygame.QUIT:
GameRunning = False pygame.display.flip() Run_Game()
No comments:
Post a Comment