├── .DS_Store ├── .idea ├── .gitignore ├── Python_Little_Projects.iml ├── inspectionProfiles │ ├── Project_Default.xml │ └── profiles_settings.xml ├── misc.xml ├── modules.xml └── vcs.xml ├── README.md ├── [00] DiscordBot └── turistomer.py ├── [01] ATM-sistemi-ve-TC-algoritmasi └── main.py ├── [02] Harf Notu Hesaplama └── main.py ├── [03] Calculator └── main.py ├── [04] Kumanda ├── .idea │ ├── .gitignore │ ├── Kumanda.iml │ ├── inspectionProfiles │ │ ├── Project_Default.xml │ │ └── profiles_settings.xml │ ├── misc.xml │ ├── modules.xml │ └── vcs.xml └── main.py ├── [05] sql ├── .idea │ ├── [05] sql.iml │ ├── inspectionProfiles │ │ └── profiles_settings.xml │ ├── misc.xml │ ├── modules.xml │ ├── vcs.xml │ └── workspace.xml ├── kutuphane.db └── main.py ├── [06] Tiklama-Botu └── tiklama_botu.py └── [07] OOP Tabanlı Oyun ├── README.md ├── blocks.py ├── bullet.py ├── main.py ├── player.py └── read.md /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/overflow-sudo/Python_Little_Projects/c7c4cf31ebcf08fd2435da9215cdfc24560d5d7d/.DS_Store -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /.idea/Python_Little_Projects.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Python 2 | Little projects that I made with python 3 | -------------------------------------------------------------------------------- /[00] DiscordBot/turistomer.py: -------------------------------------------------------------------------------- 1 | import discord 2 | import time 3 | import random 4 | from discord.ext.commands import Bot 5 | from bs4 import BeautifulSoup 6 | import urllib 7 | import requests 8 | from datetime import datetime 9 | 10 | from urllib.request import urlopen 11 | TOKEN = "ODc3Nzk3MzYxMjY1NTY5Nzk0.YR32fw.yqKIuGBxLo_qxKmG3aS9Qx6cpL8" 12 | 13 | client = discord.Client() 14 | bot = Bot(command_prefix="!") 15 | now = datetime.now() 16 | current_time = now.strftime("%D:%m:%H:%M:%S") 17 | 18 | 19 | @bot.event 20 | async def on_ready(): 21 | print("Bot Hazır " + str(bot.user)) 22 | 23 | @bot.event 24 | async def on_message(message): 25 | print("[{}][{}]{}: {}\n".format(message.guild.name,current_time,message.author.name,message.content)) 26 | log = open("log.txt","a") 27 | log.write("[{}][{}]{}: {}\n".format(message.guild.name,current_time,message.author.name,message.content)) 28 | if message.author == client.user: 29 | return 30 | 31 | if message.content == "sa": 32 | await message.channel.send("as {}" .format(message.author.name)) 33 | 34 | if message.content == "Merhaba" or message.content =="merhaba": 35 | await message.channel.send("Merhabana merhaba {}" .format(message.author.name)) 36 | 37 | if message.content == "!tahmin r6": 38 | await message.channel.send("Mavi vs Turuncu") 39 | await message.channel.send("Düşünüyorum...") 40 | time.sleep(2) 41 | x = random.randint(1,2) 42 | takim = 0 43 | if x == 1: 44 | takim = "Mavi" 45 | if x == 2: 46 | takim = "Turuncu" 47 | await message.channel.send("Bu maçı {} takım kazanır bileğinize kuvvet Yüce Kudretli ALLAHIN aslanları".format(takim)) 48 | 49 | quest= message.content 50 | quest = quest.split() 51 | 52 | if quest[0] == "!skor": 53 | url = "https://www.google.com.tr/search?q="+quest[1] 54 | headersparam = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36"} 55 | sayfa = requests.get(url,headers=headersparam) 56 | soup = BeautifulSoup(sayfa.content,"lxml", from_encoding='UTF-8') 57 | div = soup.find_all("div", attrs={"class": "imso_mh__l-tm-sc imso_mh__scr-it imso-light-font"}) 58 | div2 = soup.find_all("div", attrs={"class": "imso_mh__r-tm-sc imso_mh__scr-it imso-light-font"}) 59 | bastir = str(div) 60 | bastir2 = str(div2) 61 | xtakimadi1 = soup.find_all("div",attrs={"class":"imso_mh__first-tn-ed imso_mh__tnal-cont imso-tnol"}) 62 | xtakimadi2 = soup.find_all("div", attrs={"class": "imso_mh__second-tn-ed imso_mh__tnal-cont imso-tnol"}) 63 | takimadi1 = str(xtakimadi1) 64 | takimadi2 = str(xtakimadi2) 65 | await message.channel.send("{} : {} - {} : {}" .format(takimadi1[748:-26],bastir[63:-7],takimadi2[749:-26],bastir2[63:-7])) 66 | 67 | if quest[0] == "!stats": 68 | url = "https://r6.tracker.network/profile/pc/"+quest[1] 69 | headersparam = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36"} 70 | sayfa = requests.get(url,headers=headersparam) 71 | soup = BeautifulSoup(sayfa.content,"lxml", from_encoding='UTF-8') 72 | kd = soup.find_all("div", attrs={"data-stat":"RankedKDRatio"}) 73 | kd = str(kd) 74 | kd = kd[59:-8] 75 | wins = soup.find_all("div",attrs={"data-stat":"RankedWLRatio"}) 76 | wins = str(wins) 77 | wins = wins[59:-8] 78 | hs = soup.find_all("div",attrs={"data-stat":"PVPAccuracy"}) 79 | hs = str(hs) 80 | hs = hs[57:-7] 81 | print( "İsim: {} \n" "KD:{}\n Kazanılan Maç Oranı:{}\n Kafadan Vuruş Oranı:{} ".format(quest[1],kd,wins,hs)) 82 | await message.channel.send( "İsim: {} \n" "KD:{}\n Kazanılan Maç Oranı:{}\n Kafadan Vuruş Oranı:{} ".format(quest[1],kd,wins,hs)) 83 | bot.run(TOKEN) 84 | -------------------------------------------------------------------------------- /[01] ATM-sistemi-ve-TC-algoritmasi/main.py: -------------------------------------------------------------------------------- 1 | import random,time 2 | 3 | def Tc(x): #TC no'nun doğru olması için gereken şartları kontrol ediyoruz 4 | list(x) 5 | if x[0] == "0": 6 | return 0 7 | tek_rakamlar = int(x[0]) + int(x[2]) + int(x[4]) + int(x[6]) + int(x[8]) 8 | cift_rakamlar = int(x[1]) + int(x[3]) + int(x[5]) + int(x[7]) 9 | 10 | if int(x[9]) != (tek_rakamlar * 7 + cift_rakamlar * 9) % 10: 11 | return 0 12 | 13 | if (tek_rakamlar + cift_rakamlar + int(x[9])) % 10 != int(x[10]): 14 | return 0 15 | 16 | 17 | while True: 18 | TC = str(input("TC No giriniz: ")) 19 | isCorrect = Tc(TC) 20 | if isCorrect == False: 21 | print("TC Hatalı") 22 | continue 23 | if len(TC) != 11: 24 | print("TC 11 Haneli Olmalı") 25 | continue 26 | while True: 27 | sifre = str(input("4 haneli bir şifre oluşturun: ")) 28 | if len(sifre) < 4: 29 | print("Şifre 4 haneden küçük olamaz!") 30 | continue 31 | elif len(sifre) > 4: 32 | print("Şifre 4 haneden büyük olamaz!") 33 | continue 34 | sifre_tekrar = str(input("Oluşturduğunuz şifreyi tekrar giriniz: ")) 35 | if sifre != sifre_tekrar: 36 | print("Şifreler eşleşmiyor.") 37 | continue 38 | else: 39 | break 40 | break 41 | 42 | bakiye = 5000 43 | 44 | while True: 45 | islem_no = int(input("Bir işlem seçiniz: \n[1] Para Yatır \n" 46 | "[2] Para Çek\n")) 47 | if islem_no == 1: 48 | print("...") 49 | time.sleep(1) 50 | print("Güncel bakiyeniz: {}".format(str(bakiye) + "TL")) 51 | yatir = int(input("Yatırmak istediğiniz tutar: ")) 52 | print("Para yatırılıyor...") 53 | time.sleep(1) 54 | bakiye += yatir 55 | print("Yatırdığınız tutar: {}, Güncel bakiye: {}".format(yatir,bakiye)) 56 | 57 | isOk = input("Başka bir işlem yapmak istiyor musunuz? E/H: ") 58 | if isOk == "E": 59 | continue 60 | elif isOk == "H": 61 | break 62 | 63 | elif islem_no == 2: 64 | print("...") 65 | time.sleep(1) 66 | print("Güncel bakiyeniz: {}".format(str(bakiye) + "TL")) 67 | cek = int(input("Çekmek istediğiniz tutar: ")) 68 | print("Para çekiliyor...") 69 | time.sleep(1) 70 | bakiye -= cek 71 | print("Çektiğiniz tutar: {}, Güncel bakiye: {}".format(cek,bakiye)) 72 | isOk = input("Başka bir işlem yapmak istiyor musunuz? E/H: ") 73 | if isOk == "E": 74 | continue 75 | elif isOk == "H": 76 | break 77 | 78 | else: 79 | print("Geçersiz giriş...") 80 | continue 81 | 82 | -------------------------------------------------------------------------------- /[02] Harf Notu Hesaplama/main.py: -------------------------------------------------------------------------------- 1 | def not_hesapla(satir): 2 | 3 | satir = satir[:-1] # End parametresiyle aynı işlevde 4 | 5 | 6 | liste = satir.split(",") 7 | 8 | print(liste) 9 | 10 | isim = liste[0] 11 | not1 = int(liste[1]) 12 | not2 = int(liste[2]) 13 | not3 = int(liste[3]) 14 | 15 | son_not = not1 * (3/10) + not2 * (3/10) + not3 * (4/10) 16 | 17 | if (son_not >= 90): 18 | 19 | harf = "AA" 20 | 21 | elif (son_not >= 85): 22 | harf = "BA" 23 | 24 | elif (son_not >= 80): 25 | harf = "BB" 26 | elif (son_not >= 75): 27 | harf = "CB" 28 | elif (son_not >= 70): 29 | harf = "CC" 30 | elif (son_not >= 65): 31 | harf = "DC" 32 | elif (son_not >= 60): 33 | harf = "DD" 34 | elif (son_not >= 55): 35 | harf = "FD" 36 | else: 37 | harf = "FF" 38 | 39 | return isim + "------------>" + harf + "\n" 40 | 41 | with open("dosya.txt" , "r" , encoding="utf-8") as file: 42 | eklenecekler_listesti = [] 43 | for i in file: 44 | not_hesapla(i) 45 | eklenecekler_listesti.append(not_hesapla(i)) 46 | 47 | with open("notlar.txt" , "w", encoding="utf-8") as file2: 48 | for i in eklenecekler_listesti: 49 | file2.write(i) -------------------------------------------------------------------------------- /[03] Calculator/main.py: -------------------------------------------------------------------------------- 1 | class Calculator(): 2 | def __init__(self,x,y): 3 | self.x = x 4 | self.y = y 5 | self.sonuc = 0 6 | def toplama(self): 7 | self.sonuc = self.x + self.y 8 | return self.sonuc 9 | def cıkarma(self): 10 | self.sonuc = self.x - self.y 11 | return self.sonuc 12 | def carpma(self): 13 | self.sonuc = self.x * self.y 14 | return self.sonuc 15 | def bolme(self): 16 | self.sonuc = self.x / self.y 17 | return self.sonuc 18 | 19 | while True: 20 | print("[1] Toplama\n[2] Çıkarma\n[3] Çarpma\n[4] Bölme\n") 21 | islem = int(input("Bir İşlem Seçin: ")) 22 | x = int(input("Birinci sayıyı giriniz: \n")) 23 | y = int(input("İkinci sayıyı giriniz: \n")) 24 | hesapMakinesi = Calculator(x, y) 25 | if islem == 1: 26 | print(hesapMakinesi.toplama()) 27 | elif islem == 2: 28 | print(hesapMakinesi.cıkarma()) 29 | elif islem == 3: 30 | print(hesapMakinesi.carpma()) 31 | elif islem == 4: 32 | print(hesapMakinesi.bolme()) 33 | 34 | 35 | -------------------------------------------------------------------------------- /[04] Kumanda/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /[04] Kumanda/.idea/Kumanda.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /[04] Kumanda/.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | -------------------------------------------------------------------------------- /[04] Kumanda/.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /[04] Kumanda/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /[04] Kumanda/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /[04] Kumanda/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /[04] Kumanda/main.py: -------------------------------------------------------------------------------- 1 | class Kumanda(): 2 | def __init__(self,tvDurum = "Kapalı",tvSes = 0,tvKanal = ["TRT", "Kanal D", "Show TV", "ATV", "FOX"],miktar = 0): 3 | self.tvDurum = tvDurum 4 | self.tvSes = tvSes 5 | self.tvKanal = tvKanal 6 | self.miktar = miktar 7 | def tvAc(self): 8 | self.tvDurum = "Açık" 9 | 10 | def sesArttir(self): 11 | self.miktar = int(input("Sesi ne kadar arttırmak istiyorsun? : ")) 12 | if (self.tvSes <= 99): 13 | self.tvSes += self.miktar 14 | print("Yeni ses seviyesi {}".format(self.tvSes)) 15 | else: 16 | print("Ses seviyesi maximum") 17 | 18 | def sesAzalt(self): 19 | self.miktar = int(input("Sesi ne kadar azaltmak istiyorsun? : ")) 20 | if (self.tvSes > 0): 21 | self.tvSes -= self.miktar 22 | print("Yeni ses seviyesi {}".format(self.tvSes)) 23 | else: 24 | print("Ses seviyesi minimum") 25 | 26 | def kanalSec(self): 27 | self.kanalNo = int(input("Kanal No giriniz: ")) 28 | print("{} kanalı İzleniyor" .format(self.tvKanal[self.kanalNo - 1])) 29 | 30 | def tvKapat(self): 31 | self.tvDurum = "Kapalı" 32 | kumanda = Kumanda() 33 | 34 | while kumanda.tvDurum == "Kapalı": 35 | print("TV Kapalı açmak için [1]'e basın") 36 | secim = int(input("")) 37 | if secim == 1: 38 | kumanda.tvAc() 39 | else: 40 | pass 41 | 42 | while kumanda.tvDurum == "Açık": 43 | print("[1] Sesi Arttır\n" 44 | "[2] Sesi Azalt\n" 45 | "[3] Kanal Değiştir\n" 46 | "[4] TV'yi Kapat\n" ) 47 | secim = int(input("")) 48 | if secim == 1: 49 | kumanda.sesArttir() 50 | elif secim == 2: 51 | kumanda.sesAzalt() 52 | elif secim == 3: 53 | kumanda.kanalSec() 54 | elif secim == 4: 55 | kumanda.tvKapat() 56 | 57 | 58 | -------------------------------------------------------------------------------- /[05] sql/.idea/[05] sql.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /[05] sql/.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /[05] sql/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /[05] sql/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /[05] sql/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /[05] sql/.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 23 | 24 | 26 | 27 | 28 | 31 | 49 | 50 | 51 | 52 | 72 | 73 | 74 | 75 | 76 | 77 | 1677175861845 78 | 83 | 84 | 85 | 86 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /[05] sql/kutuphane.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/overflow-sudo/Python_Little_Projects/c7c4cf31ebcf08fd2435da9215cdfc24560d5d7d/[05] sql/kutuphane.db -------------------------------------------------------------------------------- /[05] sql/main.py: -------------------------------------------------------------------------------- 1 | import sqlite3 2 | con = sqlite3.connect("kutuphane.db") 3 | cursor = con.cursor() 4 | class Kitaplik(): 5 | def __init__(self,kitap_adi, yazar, yayinevi, sayfa): 6 | 7 | self.kitap_adi = kitap_adi 8 | self.yazar = yazar 9 | self.yayinevi = yayinevi 10 | self.sayfa = sayfa 11 | 12 | def tablo_olustur(self): 13 | cursor.execute("CREATE TABLE IF NOT EXISTS kitaplik (Kitap TEXT, Yazar TEXT, Yayinevi TEXT, Sayfa INT)") 14 | con.commit() 15 | def kitap_ekle(self): 16 | cursor.execute("INSERT INTO kitaplik VALUES (?, ?, ?, ?)" ,(self.kitap_adi, self.yazar, self.yayinevi, self.sayfa)) 17 | con.commit() 18 | 19 | 20 | kitap_adi = input("Kitap adı: ") 21 | yazar = input("Yazar: ") 22 | yayinevi = input("Yayınevi: ") 23 | sayfa = int(input("Sayfa sayısı: ")) 24 | 25 | kitaplik = Kitaplik(kitap_adi,yazar,yayinevi,sayfa) 26 | 27 | kitaplik.tablo_olustur() 28 | kitaplik.kitap_ekle() 29 | -------------------------------------------------------------------------------- /[06] Tiklama-Botu/tiklama_botu.py: -------------------------------------------------------------------------------- 1 | import pyautogui 2 | 3 | canta = 736,938 4 | sepet = 943,623 5 | urun = 849,469 6 | onayla = 1029,607 7 | exit = 1078,419 8 | while True: 9 | pyautogui.click(canta,interval = 1) 10 | pyautogui.click(sepet,interval = 1) 11 | pyautogui.click(urun,interval = 1) 12 | for i in range(640,1400,69): 13 | pyautogui.click(i,810,interval = 1) 14 | hasat = True 15 | i = 640 16 | while hasat: 17 | for b in range(0,12): 18 | pyautogui.dragTo(849, 469, 2, button='left') 19 | pyautogui.dragTo(i, 810, 2, button='left') 20 | pyautogui.click(onayla,interval = 1) 21 | i += 69 22 | hasat = False 23 | pyautogui.click(exit,interval = 1) 24 | -------------------------------------------------------------------------------- /[07] OOP Tabanlı Oyun/README.md: -------------------------------------------------------------------------------- 1 | Ekran Resmi 2023-03-09 16 11 12 2 | -------------------------------------------------------------------------------- /[07] OOP Tabanlı Oyun/blocks.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | import pygame 4 | 5 | class Blocks(): 6 | def __init__(self,screen,x,y,width,height): 7 | self.blocks = [] 8 | self.screen = screen 9 | self.x = x 10 | self.y = y 11 | self.width = width 12 | self.height = height 13 | self.add = 0 14 | self.rect = pygame.Rect(self.x + self.add,self.y,5,5) 15 | 16 | 17 | def create(self): 18 | self.block = pygame.Rect(self.x + self.add,self.y,5,5) 19 | self.blocks.append(self.block) 20 | self.add += 18 21 | 22 | def draw(self): 23 | for block in self.blocks: 24 | self.rect= pygame.draw.rect(self.screen,(255,0,0),pygame.Rect(block[0],block[1],self.width,self.height)) 25 | 26 | def move(self): 27 | for block in self.blocks: 28 | block[1] += 15 29 | -------------------------------------------------------------------------------- /[07] OOP Tabanlı Oyun/bullet.py: -------------------------------------------------------------------------------- 1 | import pygame 2 | from blocks import * 3 | class Bullet(Blocks): 4 | 5 | def __init__(self,screen,x,y,width,height): 6 | super().__init__(screen,x,y,width,height) 7 | self.bullets = [] 8 | self.rect = pygame.Rect(self.x ,self.y,self.width,self.height) 9 | 10 | 11 | def create(self): 12 | 13 | self.bullet = pygame.Rect(self.x ,self.y,self.width,self.height) 14 | self.bullets.append(self.bullet) 15 | def fire(self): 16 | for bullet in self.bullets: 17 | bullet[1] -= 2 18 | 19 | 20 | 21 | 22 | def draw(self): 23 | for bullet in self.bullets: 24 | 25 | self.rect=pygame.draw.rect(self.screen,(255,255,255),pygame.Rect(bullet[0],bullet[1],self.width,self.height)) 26 | -------------------------------------------------------------------------------- /[07] OOP Tabanlı Oyun/main.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from player import * 3 | from bullet import * 4 | from blocks import * 5 | import pygame 6 | class Main: 7 | def __init__(self): 8 | pygame.init() 9 | self.screen_width = 800 10 | self.screen = pygame.display.set_mode((self.screen_width, 800)) 11 | self.player1 = Player(150, 650, 30, 50, self.screen, 1, "playerrect") 12 | self.bullet = Bullet(self.screen, self.player1.x, self.player1.y - 55, 18, 18) 13 | self.block = Blocks(self.screen, 5, 5, 15, 12) 14 | 15 | for i in range(int(self.screen_width / self.block.width)): 16 | self.block.create() 17 | 18 | def run(self): 19 | while True: 20 | self.screen.fill((0, 0, 0)) 21 | 22 | for event in pygame.event.get(): 23 | if event.type == pygame.QUIT: 24 | sys.exit() 25 | 26 | if event.type == pygame.KEYDOWN: 27 | if event.key == pygame.K_RIGHT: 28 | self.player1.right = True 29 | 30 | if event.key == pygame.K_LEFT: 31 | self.player1.left = True 32 | if event.key == pygame.K_SPACE: 33 | 34 | self.bullet.x = self.player1.x 35 | self.bullet.create() 36 | self.block.move() # Blokların aşağı hareketinden sorumlu method 37 | 38 | for i in range(int(self.screen_width / self.block.width)): 39 | self.block.create() 40 | self.block.add = 0 41 | 42 | if event.type == pygame.KEYUP: 43 | if event.key == pygame.K_RIGHT: 44 | self.player1.right = False 45 | if event.key == pygame.K_LEFT: 46 | self.player1.left = False 47 | 48 | self.player1.move() 49 | self.player1.draw() 50 | self.bullet.draw() 51 | self.bullet.fire() 52 | self.block.draw() 53 | 54 | for blo in self.block.blocks: # Bu iç içe döngü Mermilerin ve Blokların Çarpışmalarını Kontrol Ediyor 55 | for bul in self.bullet.bullets: 56 | if bul.colliderect(blo): 57 | self.bullet.bullets.remove(bul) 58 | self.block.blocks.remove(blo) 59 | if blo.colliderect(self.player1.rectangle): 60 | print("cOLLİDE") 61 | 62 | pygame.display.update() 63 | 64 | 65 | App = Main() 66 | App.run() 67 | -------------------------------------------------------------------------------- /[07] OOP Tabanlı Oyun/player.py: -------------------------------------------------------------------------------- 1 | import pygame 2 | class Player(): 3 | def __init__(self,x,y,width,height,screen,vel,rectangle): 4 | self.x = x 5 | self.y = y 6 | self.width = width 7 | self.height = height 8 | self.screen = screen 9 | self.left = False 10 | self.right = False 11 | self.vel = vel 12 | self.rectangle = rectangle 13 | def move(self): 14 | if self.right: 15 | self.x += self.vel 16 | if self.left: 17 | self.x -= self.vel 18 | 19 | def draw(self): 20 | self.rectangle = pygame.Rect(self.x,self.y,self.width,self.height) 21 | pygame.draw.rect(self.screen,(255,255,255),self.rectangle) 22 | -------------------------------------------------------------------------------- /[07] OOP Tabanlı Oyun/read.md: -------------------------------------------------------------------------------- 1 | İleriki projelerimde referans olarak kullanacağım güzel bir kaynak oldu benim için. 2 | --------------------------------------------------------------------------------