Skip to main content

Posts

Showing posts with the label Python game tutorial

Part 1: Make your own game in Python

Python Code[Just Copy paste the code and you are done] : # Import a library of functions called 'pygame' import pygame # Initialize the game engine pygame.init() gamedisplay = pygame.display.set_mode((700, 500)) pygame.display.set_caption("Cool Game") clock=pygame.time.Clock() crashed=False while not crashed: for event in pygame.event.get(): if event.type == pygame.QUIT: crashed= True print(event) pygame.display.update() clock.tick(60) pygame.quit() quit() In command prompt: pip install pygame Keywords : puruworldofficial python game engine 2d, python game library, python game development, pygame game, python game creator, python game programming tutorial for beginners, pygame tutorial, python based games, Game development in python, build your own game in python with pygame, build your own game in python, make your own game in python, invent your own game in python, how to make a game in python for beginners, python game programmi...

Part 3 || Gaming in python || pygame

python game code: # Import a library of functions called 'pygame' import pygame # Initialize the game engine pygame.init() display_width=800 display_height=600 img_width=100 black=(0,0,0) white=(255,255,255) red=(255,0,0) gamedisplay = pygame.display.set_mode((display_width,display_height)) pygame.display.set_caption("Cool Game") clock=pygame.time.Clock() carImg= pygame.image.load('car.png') def car(x,y): gamedisplay.blit(carImg,(x,y)) def gamerender(): x=(display_width * 0.45) y=(display_height * 0.65) x_change=0 crashed=False while not crashed: for event in pygame.event.get(): if event.type == pygame.QUIT: crashed= True if event.type == pygame.KEYDOWN: if event.key==pygame.K_LEFT: x_change=-5 if event.key==pygame.K_RIGHT: x_change=5 if event.type==pygame.KEYUP: if event.key==pygame.K_LEFT or event.key==pygame.K_RIGHT: x_change=0 x+=x_change gamedi...

Part 2 : Making a game in python || pygame

In this video, you will learn - Changing background of the game - Displaying image in the game - putting an image in a definite position Stay tuned -Stay subscribed for other parts of the tutorial.Meanwhile like, share and comment your queries. python code: # Import a library of functions called 'pygame' import pygame # Initialize the game engine pygame.init() display_width=800 display_height=600 black=(0,0,0) white=(255,255,255) red=(255,0,0) gamedisplay = pygame.display.set_mode((display_width,display_height)) pygame.display.set_caption("Cool Game") clock=pygame.time.Clock() crashed=False carImg= pygame.image.load('car.png') def car(x,y): gamedisplay.blit(carImg,(x,y)) x=(display_width * 0.45) y=(display_height * 0.65) while not crashed: for event in pygame.event.get(): if event.type == pygame.QUIT: crashed= True gamedisplay.fill(red) #print (event) car(x,y) pygame.display.update() clock.tick(60) pygame.quit() quit() Ke...