├── .DS_Store ├── .gitattributes ├── README.md ├── font └── poxel-font.ttf ├── heart.png ├── main.py └── zxf.jpg /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/overflow-sudo/Absolutely-Simple-Pinpon-Game/e49dbff53c4de06177068bf04b607c53d569f011/.DS_Store -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Absolutely Simple Pinpon Game 2 | 3 | ![TlHU5j](https://user-images.githubusercontent.com/85408428/199672344-ad80a631-72e2-4310-90a3-4e2fd1dcbf3e.png) 4 | ![+jX8zJ](https://user-images.githubusercontent.com/85408428/199672355-e6f1a806-90c6-4d63-9682-8042a09bfa81.png) 5 | -------------------------------------------------------------------------------- /font/poxel-font.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/overflow-sudo/Absolutely-Simple-Pinpon-Game/e49dbff53c4de06177068bf04b607c53d569f011/font/poxel-font.ttf -------------------------------------------------------------------------------- /heart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/overflow-sudo/Absolutely-Simple-Pinpon-Game/e49dbff53c4de06177068bf04b607c53d569f011/heart.png -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | #Sınıflara ayır 2 | #Nesne Tabanlı Programla! 3 | 4 | import pygame 5 | import time 6 | import random 7 | pygame.init() 8 | screen = pygame.display.set_mode((800,600)) 9 | pygame.display.set_caption("Absolutely Simple Pinpon Game") 10 | assets = ["heart.png","zxf.jpg"] 11 | 12 | bg = pygame.image.load(assets[1]) 13 | bg = pygame.transform.scale(bg,(800,600)) 14 | #Player 15 | player_x = 400 16 | player_y = 550 17 | player2_x = 400 18 | player2_y = 50 19 | #Ball 20 | ball_x = random.randint(0,795) 21 | ball_y = random.randint(0,450) 22 | spawn = True 23 | #Heart 24 | heart_x = random.randint(0,745) 25 | heart_y = random.randint(0,450) 26 | heart_spawn = False 27 | #Player Move Mechanics 28 | move_left = False 29 | move_right = False 30 | #Ball Move Mechanics 31 | color = (255,255,255) 32 | ball_move_up = False 33 | ball_move_down = True 34 | ball_move_left = True 35 | ball_move_right = False 36 | ball_vel=4 37 | playervel = 5*2 38 | #Values 39 | skor = 0 40 | player2_lives = 3 41 | pause = False 42 | stop = False 43 | main_menu = True 44 | spawn_time = 0 45 | font = pygame.font.Font("font/poxel-font.ttf",35) 46 | fps = 90 47 | ball_touch_count = 0 48 | heart_box = False 49 | player1_lives = 3 50 | #player2 51 | 52 | player2_move_right = False 53 | player2_move_left = False 54 | 55 | while True: 56 | pygame.time.Clock().tick(fps) 57 | 58 | 59 | for event in pygame.event.get(): 60 | if event.type == pygame.QUIT: 61 | pygame.quit() 62 | sys.exit() 63 | if event.type == pygame.KEYDOWN: 64 | if event.key == pygame.K_RIGHT: 65 | player2_move_right = True 66 | if event.key == pygame.K_LEFT: 67 | player2_move_left = True 68 | if event.key == pygame.K_ESCAPE: 69 | pause = True 70 | if event.key == pygame.K_d: 71 | move_right = True 72 | if event.key == pygame.K_a: 73 | move_left = True 74 | if event.type == pygame.KEYUP: 75 | if event.key == pygame.K_RIGHT: 76 | player2_move_right = False 77 | if event.key == pygame.K_LEFT: 78 | player2_move_left = False 79 | if event.key == pygame.K_d: 80 | move_right = False 81 | if event.key == pygame.K_a: 82 | move_left = False 83 | 84 | #Player Controls 85 | if stop == False: 86 | if player2_move_left: 87 | player2_x -= playervel 88 | if player2_move_right: 89 | player2_x += playervel 90 | if move_right: 91 | player_x += playervel 92 | if move_left: 93 | player_x -= playervel 94 | if player_x <= 4: 95 | player_x = 4 96 | if player_x>= 695: 97 | player_x = 695 98 | if player2_x <= 4: 99 | player2_x = 4 100 | if player2_x >= 695: 101 | player2_x = 695 102 | screen.fill((0,0,0)) 103 | screen.blit(bg,(0,0)) 104 | player = pygame.draw.rect(screen,(255,0,0),pygame.Rect(player_x,player_y,100,10)) 105 | player2 = pygame.draw.rect(screen,(0,0,255),pygame.Rect(player2_x,player2_y,100,10)) 106 | 107 | if spawn == True: 108 | ball = pygame.draw.rect(screen,(255,255,255),pygame.Rect(ball_x,ball_y,10,10)) 109 | 110 | #Ball Movement 111 | if ball_move_left: 112 | ball_x -= ball_vel 113 | if ball_x <= 0: 114 | ball_move_left = False 115 | ball_move_right = True 116 | if ball_move_right: 117 | ball_x += ball_vel 118 | if ball_x >= 799: 119 | ball_move_left = True 120 | ball_move_right = False 121 | if ball_move_up: 122 | ball_y -= ball_vel 123 | if pygame.Rect.colliderect(player2,ball): 124 | ball_move_down = True 125 | ball_move_up = False 126 | spawn_time += 1 127 | ball_touch_count +=1 128 | color = (0,0,255) 129 | if ball_y <= 0: 130 | spawn = False 131 | ball_y = random.randint(589,599) 132 | ball_x = random.randint(0,795) 133 | player2_lives -= 1 134 | 135 | if ball_move_down: 136 | ball_y += ball_vel 137 | if pygame.Rect.colliderect(player,ball): 138 | ball_move_down = False 139 | ball_move_up = True 140 | skor += 1 141 | spawn_time += 1 142 | ball_touch_count +=1 143 | 144 | if ball_y >= 600: 145 | spawn = False 146 | ball_y = random.randint(0,1) 147 | ball_x = random.randint(0,795) 148 | player1_lives -= 1 149 | 150 | if ball_y <= 600: 151 | spawn = True 152 | 153 | if ball_touch_count >= 5: 154 | heart_spawn = False 155 | if ball_touch_count >= 7: 156 | heart_spawn = False 157 | ball_touch_count = 0 158 | #Heart 159 | heart = pygame.image.load(assets[0]) 160 | if heart_spawn: 161 | heart_box = pygame.Rect(heart_x+25,heart_y+17,15,18) 162 | screen.blit(heart,(heart_x,heart_y)) 163 | if pygame.Rect.colliderect(heart_box,ball): 164 | heart_x = random.randint(0,785) 165 | heart_y = random.randint(0,450) 166 | # lives += 1 167 | heart_spawn = False 168 | ball_touch_count = 0 169 | draw_skor = font.render("Player 1: {} ".format(player1_lives),True,(255,0,0)) 170 | draw_lives = font.render("Player 2: {}".format(player2_lives),True,(0,0,255)) 171 | screen.blit(draw_skor,(10,0)) 172 | screen.blit(draw_lives,(600,0)) 173 | if player2_lives <= 0 or player1_lives <= 0: 174 | if event.type == pygame.KEYDOWN: 175 | if event.key == pygame.K_ESCAPE: 176 | pause = False 177 | pos = pygame.mouse.get_pos() 178 | stop = True 179 | restrat_text = font.render(" Restrat",True,(255,255,255)) 180 | quit_text = font.render("Quit",True,(255,255,255)) 181 | restrat_text_rect = pygame.draw.rect(screen,(255,255,255),pygame.Rect(310,130,152,39),2) 182 | quit_text_rect = pygame.draw.rect(screen,(255,255,255),pygame.Rect(310,180,152,39),2) 183 | screen.blit(restrat_text,(310,130)) 184 | screen.blit(quit_text,(350,180)) 185 | if event.type == pygame.MOUSEBUTTONUP: 186 | if restrat_text_rect.collidepoint(pos): 187 | ball_x = random.randint(0,795) 188 | ball_y = random.randint(0,450) 189 | stop = False 190 | player2_lives = 3 191 | player1_lives = 3 192 | if quit_text_rect.collidepoint(pos): 193 | pygame.quit() 194 | sys.exit() 195 | 196 | if pause == True: 197 | stop = True 198 | continue_text = font.render("Continue",True,(255,255,255)) 199 | quit_text = font.render("Quit",True,(255,255,255)) 200 | continue_text_rect = pygame.draw.rect(screen,(255,255,255),pygame.Rect(310,130,152,39),2) 201 | quit_text_rect = pygame.draw.rect(screen,(255,255,255),pygame.Rect(310,180,152,39),2) 202 | 203 | screen.blit(continue_text,(310,130)) 204 | screen.blit(quit_text,(350,180)) 205 | pos = pygame.mouse.get_pos() 206 | if event.type == pygame.MOUSEBUTTONUP: 207 | if continue_text_rect.collidepoint(pos): 208 | pause = False 209 | stop = False 210 | if quit_text_rect.collidepoint(pos): 211 | pygame.quit() 212 | sys.exit() 213 | 214 | pygame.display.update() 215 | -------------------------------------------------------------------------------- /zxf.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/overflow-sudo/Absolutely-Simple-Pinpon-Game/e49dbff53c4de06177068bf04b607c53d569f011/zxf.jpg --------------------------------------------------------------------------------