Pygame Beginner Tutorial in Python - PART 1 || Bricks Game Design

Published: 01 January 1970
on channel: UGC NET
180
8

This is a small game development project. The source code of this project is given below (Some youtube restrictions, greater than, less than symbol written in word Press like and subscribe button for more game development video):

............................................................................................................................
import pygame, os, sys
from pygame.locals import *

pygame.init()
fpsClock=pygame.time.Clock()
mainSurface = pygame.display.set_mode((800, 600))
pygame.display.set_caption('Bricks')

black=pygame.Color(0,0,0)

bat = pygame.image.load('I:/game design/bat.png')

playerY = 580
batRect = bat.get_rect()
mousex, mousey = (0, playerY)
mousex = 0
mousey = playerY
mainSurface.fill(black)



ball=pygame.image.load('I:/game design/ball.PNG')
ballRect=ball.get_rect()
ballStartY=200
ballSpeed=3
ballServed=False
bx,by=(24,ballStartY)
sx,sy=(ballSpeed,ballSpeed)
ballRect.topleft=(bx,by)


brick=pygame.image.load('I:/game design/Brick.PNG')
bricks=[]
for y in range(5):
brickY=(y*24)+100
for x in range(10):
brickX=(x*31)+245
width=brick.get_width()
height=brick.get_height()
rect=Rect(brickX, brickY, width,height)
bricks.append(rect)




while True:
mainSurface.fill(black)


for b in bricks:
mainSurface.blit(brick,b)







mainSurface.blit(bat, batRect)
mainSurface.blit(ball,ballRect)


for event in pygame.event.get():
if event.type==QUIT:
pygame.quit()
sys.exit()
elif event.type==MOUSEMOTION:
mousex,mousey=event.pos
if(mousex less than 800-55):
batRect.topleft=(mousex,playerY)
else:
batRect.topleft=(800-55,playerY)


if ballServed:
bx+=sx
by+=sy
ballRect.topleft=(bx,by)
elif event.type==MOUSEBUTTONUP and not ballServed:
ballServed=True

if(by less than=0):
by=0
sy*=-1

if(by greater than=600-8):
ballServed=False
bx,by=(24,ballStartY)
ballSpeed=3
sx,sy=(ballSpeed,ballSpeed)
ballRect.topleft=(bx,by)
by=600-8
sy*=-1

if(bx less than=0):
bx=0
sx*=-1

if(bx greater than=800-8):
bx=800-8
sx*=-1




if ballRect.colliderect(batRect):
by=playerY-40
sy*=-1


brickHitIndex=ballRect.collidelist(bricks)
if brickHitIndex greater than=0:
hb=bricks[brickHitIndex]
mx=bx+4
my=by+4
if mx greater than hb.x+ hb.width or mx less than hb.x:
sx*=-1
else:
sy*=-1
del(bricks[brickHitIndex])







pygame.display.update()
fpsClock.tick(30)



............................................................................................................................

Subscribe:
   / @computerscienceandapplicat8016  

follow me :   / ugc-net-108943208141515  

blog : https://computersolution2016.blogspot...

youtube channel link:    / @computerscienceandapplicat8016  

#Python #PythonProject #ProjectForStudents #Pygame #Pygametutorial #Pygameprojects #python2021 #pythongame #gamedevelopment #bricksgame #latest #trends


On this page of the site you can watch the video online Pygame Beginner Tutorial in Python - PART 1 || Bricks Game Design with a duration of hours minute second in good quality, which was uploaded by the user UGC NET 01 January 1970, share the link with friends and acquaintances, this video has already been watched 180 times on youtube and it was liked by 8 viewers. Enjoy your viewing!