import pygame,random
#paketlerimizi başlattık.
pygame.init()
#penceremizi oluşturduk.
GENISLIK,YUKSEKLIK=612,408
pencere=pygame.display.set_mode((GENISLIK,YUKSEKLIK))
#Arkaplan şarkısı ve ses efektlerinin oluşması.
pygame.mixer.music.load("hop-no-copyright-30-seconds-by-infraction.wav")
pygame.mixer.music.play(-1,0,0)
seviye_yukselme_sesi=pygame.mixer.Sound("level-up-sound-effect.wav")
silah_alma_sesi=pygame.mixer.Sound("pickup.wav")
#FPS Değerleri.
HIZ=5
saat=pygame.time.Clock()
FPS=60
#Karakter ve Silah Tanımı.
tetikci=pygame.image.load("user.png")
tetikci_koordinat=tetikci.get_rect()
tetikci_koordinat=topleft=(GENISLIK/2,YUKSEKLIK/2)
silah=pygame.image.load("weapon.png")
silah_koordinat=silah.get_rect()
silah_koordinat=topleft=(150,150)
arka_plan=pygame.image.load("arkaplan.jpg")
#Font ayarlaması.
Font=pygame.font.SysFont("Consoles",25)
#Skor
Skor=0
#Oyun Döngüsü.
durum=True
while durum:
for etkinlik in pygame.event.get():
if etkinlik.type==pygame.QUIT:
durum=False
pencere.blit(arka_plan,(0,0))
pencere.blit(tetikci,tetikci_koordinat)
pencere.blit(silah,silah_koordinat)
YAZI=Font.render("Skor:"+str(Skor),True,(0,0,0))
YAZI_KOORDINAT=YAZI.get_rect()
YAZI_KOORDINAT.topleft=(20,20)
pygame.draw.line(pencere,(255,127,0),(0,45),(612,45),3)
pencere.blit(YAZI,YAZI_KOORDINAT)
tus=pygame.key.get_pressed()
if tus[pygame.K_LEFT] and tetikci_koordinat.left>0:
tetikci_koordinat.x-=HIZ
elif tus[pygame.K_RIGHT] and tetikci_koordinat.right<GENISLIK:
tetikci_koordinat.x+=HIZ
elif tus[pygame.K_UP] and tetikci_koordinat.top>0:
tetikci_koordinat.y-=HIZ
elif tus[pygame.K_DOWN] and tetikci_koordinat.bottom<YUKSEKLIK:
tetikci_koordinat.y+=HIZ
pygame.display.update()
saat.tick(FPS)
pygame.quit()