Skip to main content

Posts

Showing posts from February, 2018

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