ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 11.01.2024
Просмотров: 50
Скачиваний: 1
ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.
# 130-bet ????????????????
# 1-kod
import pygame
pygame.init()
screen=pygame.display.set_mode([400,300])
screen.fill([255,255,255])
jaulay_surf=pygame.image.load('001.bmp').convert()
jaulay_surf.set_colorkey([255,225,255])
jaulay_rect=jaulay_surf.get_rect(center=[200,150])
screen.blit(jaulay_surf,jaulay_rect)
bala_surf=pygame.image.load('bala.png')
bala_rect=bala_surf.get_rect(bottomright=[300,270])
screen.blit(bala_surf,bala_rect)
#pygame.display.update()
#wpygame.display.update()
pygame.display.flip() # ekranni 180 gradusga buradi
running=True
while running==True:
for event in pygame.event.get():
if event.type==pygame.QUIT:
running=False
pygame.quit()
import pygame
pygame.init()
w=400 # bo’yi
h=300 # eni
oq=[255,255,255]
qora=[0,0,0]
qizil=[255,0,0]
yashil=[0,255,0]
kok=[0,0,255]
screen=pygame.display.set_mode([w,h]) # oyna o'lchamlari
screen.fill(qizil) # fon zalivkasi
jaylau_surf=pygame.image.load("001.bmp") # image.load -- rasmni yuklash
jaylau_surf.set_colorkey(oq) # set.colorkey -- rasm fonidagi oq rangni o'chirib, rasm fonini prozrachniy qilish
jaylau_rect=jaylau_surf.get_rect(center=[150,150]) # get_rect -- markazi 150;150 bo'lgan tekislik
screen.blit(jaylau_surf,jaylau_rect) # blit -- shu tekislikka rasmni joylashtirish
bala_surf=pygame.image.load("002.png")
bala_surf.set_colorkey(oq)
bala_rect=bala_surf.get_rect(topleft=[50,50])
screen.blit(bala_surf,bala_rect)
"""
x,y
top, left, bottom, right
topleft, bottomleft, topright, bottomright
midtop, midleft, midbottom, midright
center, centerx, centery
size, width, height
w,h
"""
pygame.display.flip() # обновить экран
pygame.display.update() # обновить экран
running=True
while running==True:
for event in pygame.event.get():
if event.type==pygame.QUIT:
running=False
pygame.quit()
import pygame
pygame.init()
w=400
h=300
oq=[255,255,255]
qora=[0,0,0]
qizil=[255,0,0]
yashil=[0,255,0]
kok=[0,0,255]
screen=pygame.display.set_mode([w,h])
screen.fill(qizil) # fon zalivkasi
avto=pygame.image.load("avto.bmp") # rasmni yuklash
avto.set_colorkey(oq) # rasm fonidagi oq rangni o'chirib, rasm fonini prozrachniy qilish
screen.blit(avto,[0,0]) # tekislikdan foydalanmadik, rasmning tepa chap tomoni 0;0 nuqtada
pygame.display.flip() #
pygame.display.update() #
running=True
while running==True:
for event in pygame.event.get():
if event.type==pygame.QUIT:
running=False
pygame.quit()
# 134-bet
import pygame as pg # pygame ning o’rniga qisqacha pg deb yozish uchun
pg.init()
pg.display.set_caption('avto') # okno nomini o'zgartiradi
w=400
h=300
oq=[255,255,255]
qora=[0,0,0]
qizil=[255,0,0]
yashil=[0,255,0]
kok=[0,0,255]
screen=pg.display.set_mode([w,h])
screen.fill(qizil) # fon zalivkasi
avto=pg.image.load("avto.bmp") # rasmni yuklash
avto.set_colorkey(oq) # rasm fonidagi oq rangni o'chirib, rasm fonini prozrachniy qilish
screen.blit(avto,[0,0])
screen.blit(avto,[0,70])
screen.blit(avto,[0,140])
pg.display.flip() #
pg.display.update() #
running=True
while running==True:
for event in pg.event.get():
if event.type==pg.QUIT:
running=False
pg.quit()
#135-bet
import pygame as pg
pg.init()
pg.display.set_caption('avto') # okno nomini o'zgartiradi
w=400
h=200
oq=[255,255,255]
qora=[0,0,0]
qizil=[255,0,0]
yashil=[0,255,0]
kok=[0,0,255]
screen=pg.display.set_mode([w,h])
screen.fill(qizil) # fon zalivkasi
jol=pg.image.load("jol.png") # rasmni yuklash
jol=pg.transform.scale(jol,(400,200)) # transform – shaklini o’zgartirish
screen.blit(jol,[0,0]) # scale – masshtab – razmerini 400*200 qilib oladi
avto=pg.image.load("avto2.bmp") # rasmni yuklash
avto.set_colorkey(oq) # rasm fonidagi oq rangni o'chirib, rasm fonini prozrachniy qilish
avto=pg.transform.scale(avto,(200,100)) # rasm o'lchamlarini o'zgartirish(masshtab)
screen.blit(avto,[100,80])
pg.display.flip() #
pg.display.update() # если надо до цикла отобразить
# какие-то объекты, обновляем экран
running=True
while running==True:
for event in pg.event.get():
if event.type==pg.QUIT:
running=False
pg.quit()
# 138-bet
import pygame as pg
pg.init()
pg.display.set_caption('avto') # okno nomini o'zgartiradi
w=600
h=300
oq=[255,255,255]
qora=[0,0,0]
qizil=[255,0,0]
yashil=[0,255,0]
kok=[0,0,255]
screen=pg.display.set_mode([w,h])
screen.fill(qizil) # fon zalivkasi
avto=pg.image.load("avto.bmp") # rasmni yuklash
avto.set_colorkey(oq) # rasm fonidagi oq rangni o'chirib, rasm fonini prozrachniy qilish
avto=pg.transform.scale(avto,(200,100)) # rasm o'lchamlarini o'zgartirish(masshtab)
screen.blit(avto,[0,50])
pg.display.flip() # obnovit ekran
pg.time.delay(1000) # pauza 1000 millisekund = 1 sekund
screen.blit(avto,[400,50])
pg.display.flip() # obnovit ekran
pg.display.update() #
running=True
while running==True:
for event in pg.event.get():
if event.type==pg.QUIT:
running=False
pg.quit()
[10:27, 30.06.2022] Азиз Программист: # 138-bet
import pygame as pg
pg.init()
pg.display.set_caption('avto') # okno nomini o'zgartiradi
w=600
h=300
oq=[255,255,255]
qora=[0,0,0]
qizil=[255,0,0]
yashil=[0,255,0]
kok=[0,0,255]
screen=pg.display.set_mode([w,h])
screen.fill(qizil) # fon zalivkasi
avto=pg.image.load("avto.bmp") # rasmni yuklash
avto.set_colorkey(oq) # rasm fonidagi oq rangni o'chirib, rasm fonini prozrachniy qilish
avto=pg.transform.scale(avto,(200,100)) # rasm o'lchamlarini o'zgartirish(masshtab)
screen.blit(avto,[0,50])
pg.display.flip() # obnovit ekran
pg.time.delay(1000) # pauza 1000 millisekund = 1 sekund
screen.blit(avto,[400,50])
pg.display.flip() # obnovit ekran
pg.display.update() #
running=True
while running==True:
for event in pg.event.get():
if event.type==pg.QUIT:
running=False
pg.quit()
[10:30, 30.06.2022] Азиз Программист: # 139-bet
import pygame as pg
pg.init()
pg.display.set_caption('avto') # okno nomini o'zgartiradi
w=600
h=300
oq=[255,255,255]
qora=[0,0,0]
qizil=[255,0,0]
yashil=[0,255,0]
kok=[0,0,255]
screen=pg.display.set_mode([w,h])
screen.fill(qizil) # fon zalivkasi
avto=pg.image.load("avto.bmp") # rasmni yuklash
avto.set_colorkey(oq) # rasm fonidagi oq rangni o'chirib, rasm fonini prozrachniy qilish
avto=pg.transform.scale(avto,(200,100)) # rasm o'lchamlarini o'zgartirish(masshtab)
screen.blit(avto,[0,50])
pg.display.flip() # obnovit ekran
pg.time.delay(1000) # pauza 1000 millisekund = 1 sekund
pg.draw.rect(screen,qizil,[10,30,170,110],0)
screen.blit(avto,[400,50])
pg.display.flip() # obnovit ekran
pg.display.update() #
running=True
while running==True:
for event in pg.event.get():
if event.type==pg.QUIT:
running=False
pg.quit()
# 139-bet
import pygame as pg
pg.init()
pg.display.set_caption('avto') # okno nomini o'zgartiradi
w=600
h=300
oq=[255,255,255]
qora=[0,0,0]
qizil=[255,0,0]
yashil=[0,255,0]
kok=[0,0,255]
screen=pg.display.set_mode([w,h])
screen.fill(qizil) # fon zalivkasi
avto=pg.image.load("avto.bmp") # rasmni yuklash
avto.set_colorkey(oq) # rasm fonidagi oq rangni o'chirib, rasm fonini prozrachniy qilish
avto=pg.transform.scale(avto,(200,100)) # rasm o'lchamlarini o'zgartirish(masshtab)
for i in range(60):
screen.blit(avto,[10*i,50])
pg.display.flip() # obnovit ekran
pg.time.delay(40) # pauza 1000 millisekund = 1 sekund
pg.draw.rect(screen,qizil,[10*i,30,170,110],0)
pg.display.flip() # obnovit ekran
pg.display.update() #
running=True
while running==True:
for event in pg.event.get():
if event.type==pg.QUIT:
running=False
pg.quit()
# 140-bet raqs
import pygame as pg
pg.init()
pg.display.set_caption('raqs') # okno nomini o'zgartiradi
w=300
h=600
oq=[255,255,255]
qora=[0,0,0]
qizil=[255,0,0]
yashil=[0,255,0]
kok=[0,0,255]
screen=pg.display.set_mode([w,h])
screen.fill(qizil) # fon zalivkasi
raqs1=pg.image.load("raqs1.bmp") # rasmni yuklash
raqs1.set_colorkey([193,221,193]) # rasm fonidagi oq rangni o'chirib, rasm fonini prozrachniy qilish
raqs1=pg.transform.scale(raqs1,(200,400)) # rasm o'lchamlarini o'zgartirish(masshtab)
raqs2=pg.image.load("raqs2.bmp") # rasmni yuklash
raqs2.set_colorkey([193,221,193]) # rasm fonidagi oq rangni o'chirib, rasm fonini prozrachniy qilish
raqs2=pg.transform.scale(raqs2,(200,400)) # rasm o'lchamlarini o'zgartirish(masshtab)
raqs3=pg.image.load("raqs3.bmp") # rasmni yuklash
raqs3.set_colorkey([210,210,210]) # rasm fonidagi oq rangni o'chirib, rasm fonini prozrachniy qilish
raqs3=pg.transform.scale(raqs3,(200,400)) # rasm o'lchamlarini o'zgartirish(masshtab)
raqs4=pg.image.load("raqs4.bmp") # rasmni yuklash
raqs4.set_colorkey([209,211,223]) # rasm fonidagi oq rangni o'chirib, rasm fonini prozrachniy qilish
raqs4=pg.transform.scale(raqs4,(200,400)) # rasm o'lchamlarini o'zgartirish(masshtab)
for i in range(10):
screen.blit(raqs1,[50,100])
pg.display.flip() # obnovit ekran
pg.time.delay(250) # pauza 250 millisekund
pg.draw.rect(screen,qizil,[50,100,200,400],0)
screen.blit(raqs2,[50,100])
pg.display.flip() # obnovit ekran
pg.time.delay(250) # pauza 250 millisekund
pg.draw.rect(screen,qizil,[50,100,200,400],0)
screen.blit(raqs3,[50,100])
pg.display.flip() # obnovit ekran
pg.time.delay(250) # pauza 250 millisekund
pg.draw.rect(screen,qizil,[50,100,200,400],0)
screen.blit(raqs4,[50,100])
pg.display.flip() # obnovit ekran
pg.time.delay(250) # pauza 250 millisekund
pg.draw.rect(screen,qizil,[50,100,200,400],0)
pg.display.update() #
running=True
while running==True:
for event in pg.event.get():
if event.type==pg.QUIT:
running=False
pg.quit()
# 140-bet raqs
import pygame as pg
pg.init()
pg.display.set_caption('raqs') # okno nomini o'zgartiradi
w=300
h=600
oq=[255,255,255]
qora=[0,0,0]
qizil=[255,0,0]
yashil=[0,255,0]
kok=[0,0,255]
screen=pg.display.set_mode([w,h])
screen.fill(qizil) # fon zalivkasi
raqs1=pg.image.load("raqs1.bmp") # rasmni yuklash
raqs1.set_colorkey([193,221,193]) # rasm fonidagi oq rangni o'chirib, rasm fonini prozrachniy qilish
raqs1=pg.transform.scale(raqs1,(200,400)) # rasm o'lchamlarini o'zgartirish(masshtab)
raqs2=pg.image.load("raqs2.bmp") # rasmni yuklash
raqs2.set_colorkey([193,221,193]) # rasm fonidagi oq rangni o'chirib, rasm fonini prozrachniy qilish
raqs2=pg.transform.scale(raqs2,(200,400)) # rasm o'lchamlarini o'zgartirish(masshtab)
raqs3=pg.image.load("raqs3.bmp") # rasmni yuklash
raqs3.set_colorkey([210,210,210]) # rasm fonidagi oq rangni o'chirib, rasm fonini prozrachniy qilish
raqs3=pg.transform.scale(raqs3,(200,400)) # rasm o'lchamlarini o'zgartirish(masshtab)
raqs4=pg.image.load("raqs4.bmp") # rasmni yuklash
raqs4.set_colorkey([209,211,223]) # rasm fonidagi oq rangni o'chirib, rasm fonini prozrachniy qilish
raqs4=pg.transform.scale(raqs4,(200,400)) # rasm o'lchamlarini o'zgartirish(masshtab)
for i in range(10):
screen.blit(raqs1,[50,100])
pg.display.flip() # obnovit ekran
pg.time.delay(250) # pauza 250 millisekund
pg.draw.rect(screen,qizil,[50,100,200,400],0)
screen.blit(raqs2,[50,100])
pg.display.flip() # obnovit ekran
pg.time.delay(250) # pauza 250 millisekund
pg.draw.rect(screen,qizil,[50,100,200,400],0)
screen.blit(raqs3,[50,100])
pg.display.flip() # obnovit ekran
pg.time.delay(250) # pauza 250 millisekund
pg.draw.rect(screen,qizil,[50,100,200,400],0)
screen.blit(raqs4,[50,100])
pg.display.flip() # obnovit ekran
pg.time.delay(250) # pauza 250 millisekund
pg.draw.rect(screen,qizil,[50,100,200,400],0)
pg.display.update() #
running=True
while running==True:
for event in pg.event.get():
if event.type==pg.QUIT:
running=False
pg.quit()
# 142-bet
import pygame as pg
pg.init()
pg.display.set_caption('avto') # okno nomini o'zgartiradi
w=600
h=300
oq=[255,255,255]
qora=[0,0,0]
qizil=[255,0,0]
yashil=[0,255,0]
kok=[0,0,255]
screen=pg.display.set_mode([w,h])
screen.fill(qizil) # fon zalivkasi
avto=pg.image.load("avto.bmp") # rasmni yuklash
avto.set_colorkey(oq) # rasm fonidagi oq rangni o'chirib, rasm fonini prozrachniy qilish
avto=pg.transform.scale(avto,(200,100)) # rasm o'lchamlarini o'zgartirish(masshtab)
screen.blit(avto,[0,50])
pg.display.flip() # obnovit ekran
pg.time.delay(1000) # pauza 1000 millisekund = 1 sekund
running=True
while running==True:
for event in pg.event.get():
if event.type==pg.QUIT:
running=False
elif event.type==pg.KEYDOWN: # klavish bosilsa
if event.key==pg.K_RIGHT: # --> strelka vpravo
pg.draw.rect(screen,qizil,[10,30,170,110],0)
screen.blit(avto,[400,50])
pg.display.flip() # obnovit ekran
pg.quit()
# 143-bet
import pygame
pygame.init()
screen = pygame.display.set_mode([380,120])
screen.fill([255, 255, 255])
pygame.display.set_caption('"Пернебасу" жобасы' )
avto = pygame.image.load('avto.bmp')
x = 20 #автокөліктің қозғалыс бастайтын х.у координаталарының орнын көрсетеді
y = 40
x_speed = 10 #автокөліктің пикселдегі жылдамдығы
avto=pygame.transform.scale(avto, (160, 80))
pygame.display.flip()
running = True
while running:
#Автокөлікті тоқтаусыз қозғалтуды ұйымдастырады
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE: #SPACE пернесінің басылуын күтеді Space - probel
pygame.time.delay(50)
#Автокөліктің алдыңғы суретін өшіреді, егер өшірмесе суреттер қабаттасып көрінеді
pygame.draw.rect(screen, [255,255,255], [x, y, 180, 120], 0)
x = x + x_speed #х бойынша көліктің жылдамдығын 10-ға арттырады
#Көліктің қабырғаға тірелуін анықтайды
if x > screen.get_width()-170 or x<0: # get_width - oynaning eni
#Көлік қабырғаға тірелгенде жылдамдық кері мәнге ауысады
x_speed = - x_speed
pygame.draw.rect (screen, [255,255,255], [x, y, 90, 90], 0)
screen.blit(avto, [x, y])
pygame.display.flip()
pygame.quit()
import pygame
class Robots(pygame.sprite.Sprite):
def _init_(self, image_file, location):
pygame.sprite.Sprite._init_(self)
self.image=pygame.image.load('robot.png')
self.image=pygame.transform.scale(self.image, (80, 140))
self.rect = self.image.get_rect()
self.rect.left, self.rect.top = location
size = width, height = 640, 480
screen = pygame.display.set_mode(size);
pygame.display.set_caption('Робот жобасы' )
screen.fill([255, 255, 255])
robi = []
img_file = "robot.png"
for row in range (0, 2):
for column in range (0, 2):
location = [column * 180 + 10, row * 180 + 10]
robot = Robots(img_file, location)
robi.append(robot)
for robot in robi:
screen.blit(robot.image, robot.rect)
pygame.display.flip()
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame.quit()
import pygame
class Robots(pygame.sprite.Sprite):
def _init_(self, image_file, location):
pygame.sprite.Sprite._init_(self)
self.image=pygame.image.load('robot.png')
self.image=pygame.transform.scale(self.image, (80, 140))
self.rect = self.image.get_rect()
self.rect.left, self.rect.top = location
size = width, height = 640, 480
screen = pygame.display.set_mode(size);
pygame.display.set_caption('Робот жобасы' )
screen.fill([255, 255, 255])
robi = []
img_file = "robot.png"
for row in range (0, 2):
for column in range (0, 2):
location = [column * 180 + 10, row * 180 + 10]
robot = Robots(img_file, location)
robi.append(robot)
for robot in robi:
screen.blit(robot.image, robot.rect)
pygame.display.flip()
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame.quit()
import pygame
class Robots(pygame.sprite.Sprite):
def __init__(self, image_file, location):
pygame.sprite.Sprite.__init__(self)
1-код. «Футболшы» ойынының программа коды
import pygame, sys
#Доптың спрайтын құру, доп класын таныстырады
class MyBallClass(pygame.sprite.Sprite):
def _init_(self, image_file, speed, location):
pygame.sprite.Sprite._init_(self)
self.image = pygame.image.load('futball.png')
#Доптың өлшемдерін береді (30 х 30 пиксель)
self.image=pygame.transform.scale(self.image, (30, 30))
self.rect = self.image.get_rect()
self.rect.left, self.rect.top = location
self.speed = speed
#Допты қозғалту блогы
def move(self):
global score, score_surf, score_font
self.rect = self.rect.move(self.speed)
#Доп қабырғалармен соқтығысқанда жылдамдығын кері өзгертеді
if self.rect.left < 0 or self.rect.right > screen.get_width():
self.speed[0] = -self.speed[0]
#Доп әр рет жоғары қабырғаға соғылғанда 1 ұпай қосады
if self.rect.top <= 0 :
self.speed[1] = -self.speed[1]
score = score + 1
#Ұпайдың өзгерісін str жолдық функциясы көмегімен терезеге жазады
score_surf = score_font.render(str(score), 1, (0, 0, 0))
#Ойыншының спрайтын және класын таныстырады
class MyPaddleClass(pygame.sprite.Sprite):
def _init_(self, location = [0,0]):
pygame.sprite.Sprite._init_(self)
self.image = pygame.image.load('futbolist1.png')
#Ойыншының ойын алаңындағы өлшемдерін береді (150 х 220 пиксель)
self.image=pygame.transform.scale(self.image, (150, 220))
self.rect = self.image.get_rect()
self.rect.left, self.rect.top = location
pygame.init()
screen = pygame.display.set_mode([460,320])
pygame.display.set_caption ('Футболшы ойыны жобасы' )
clock = pygame.time.Clock()
myBall = MyBallClass('futbolist.png', [10,20], [20, 20])
ballGroup = pygame.sprite.Group(myBall)
paddle = MyPaddleClass([270, 150])
#Ойыншыға «өмір» тағайындайды ( бір ойын кезінде 3 доп береді)
lives = 3; score = 0
score_font = pygame.font.Font(None, 50)
#Қаріп нысанын құрады
score_surf = score_font.render(str(score), 1, (0, 0, 0))
score_pos = [10, 10]; done = False; running = True
#Негізгі программа бөлігін іске қосатын цикл
while running:
clock.tick(30)
#Ойынға артқы фон ретінде футбол алаңын жүктейді
pole_surf = pygame.image.load('pole.png')
pole_rect = pole_surf.get_rect(center=(230, 160))
screen.blit(pole_surf, pole_rect)
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False