Last active
November 8, 2017 00:45
-
-
Save wibbia/1416b60a082e45823ea6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygame, sys, time, math, random, os | |
from pygame.locals import * | |
pygame.init() | |
size = width, height = 1000,600 | |
black = 0,0,0 | |
brown = 168,132,32 | |
grey = 119,119,119 | |
white = 255,255,255 | |
blue = 0,0,255 | |
red = 255,0,0 | |
green = 0,255,0 | |
os.system(":b") | |
screen = pygame.display.set_mode(size) | |
player = pygame.image.load("Player.png") | |
player2 = pygame.image.load("Player2.png") | |
ball_image = pygame.image.load("Ball.png") | |
ball_image2 = pygame.image.load("Ball.png") | |
ball_image3 = pygame.image.load("Ball.png") | |
ball_image4 = pygame.image.load("Ball.png") | |
class Player(pygame.sprite.Sprite): | |
def __init__(self,image): | |
pygame.sprite.Sprite.__init__(self) | |
self.image = image | |
self.rect = self.image.get_rect() | |
def up(self): | |
player_list.sprites()[0].rect.y -= 3 | |
def back(self): | |
player_list.sprites()[0].rect.y += 3 | |
def left(self): | |
player_list.sprites()[0].rect.x -= 3 | |
def right(self): | |
player_list.sprites()[0].rect.x += 3 | |
class Player2(pygame.sprite.Sprite): | |
def __init__(self, image): | |
pygame.sprite.Sprite.__init__(self) | |
self.image = image | |
self.rect = self.image.get_rect() | |
def up2(self): | |
player2_list.sprites()[0].rect.y -= 3 | |
def back2(self): | |
player2_list.sprites()[0].rect.y += 3 | |
def left2(self): | |
player2_list.sprites()[0].rect.x -= 3 | |
def right2(self): | |
player2_list.sprites()[0].rect.x += 3 | |
class ballTL(pygame.sprite.Sprite): | |
def __init__(self, image): | |
pygame.sprite.Sprite.__init__(self) | |
self.image = image | |
self.rect = self.image.get_rect() | |
def bounce(self): | |
ball_list.sprites()[0].rect.x += ball_list.sprites()[0].changex | |
ball_list.sprites()[0].rect.y += ball_list.sprites()[0].changey | |
if ttime >= 60: | |
ball_list.sprites()[0].rect.x += ball_list.sprites()[0].changex * 2 | |
ball_list.sprites()[0].rect.y += ball_list.sprites()[0].changey * 2 | |
if ball_list.sprites()[0].rect.y > 590 or ball_list.sprites()[0].rect.y < 0: | |
ball_list.sprites()[0].changey = ball_list.sprites()[0].changey * -1 | |
if ball_list.sprites()[0].rect.x > 990 or ball_list.sprites()[0].rect.x < 0: | |
ball_list.sprites()[0].changex = ball_list.sprites()[0].changex * -1 | |
class ballTR(pygame.sprite.Sprite): | |
def __init__(self, image): | |
pygame.sprite.Sprite.__init__(self) | |
self.image = image | |
self.rect = self.image.get_rect() | |
def bounce(self): | |
ball_list1.sprites()[0].rect.x += ball_list1.sprites()[0].changex | |
ball_list1.sprites()[0].rect.y += ball_list1.sprites()[0].changey | |
if ttime >= 60: | |
ball_list1.sprites()[0].rect.x += ball_list1.sprites()[0].changex * 2 | |
ball_list1.sprites()[0].rect.y += ball_list1.sprites()[0].changey * 2 | |
if ball_list1.sprites()[0].rect.y > 590 or ball_list1.sprites()[0].rect.y < 0: | |
ball_list1.sprites()[0].changey = ball_list1.sprites()[0].changey * -1 | |
if ball_list1.sprites()[0].rect.x > 990 or ball_list1.sprites()[0].rect.x < 0: | |
ball_list1.sprites()[0].changex = ball_list1.sprites()[0].changex * -1 | |
class ballBL(pygame.sprite.Sprite): | |
def __init__(self, image): | |
pygame.sprite.Sprite.__init__(self) | |
self.image = image | |
self.rect = self.image.get_rect() | |
def bounce(self): | |
ball_list2.sprites()[0].rect.x += ball_list2.sprites()[0].changex | |
ball_list2.sprites()[0].rect.y += ball_list2.sprites()[0].changey | |
if ttime >= 60: | |
ball_list2.sprites()[0].rect.x += ball_list2.sprites()[0].changex * 2 | |
ball_list2.sprites()[0].rect.y += ball_list2.sprites()[0].changey * 2 | |
if ball_list2.sprites()[0].rect.y > 590 or ball_list2.sprites()[0].rect.y < 0: | |
ball_list2.sprites()[0].changey = ball_list2.sprites()[0].changey * -1 | |
if ball_list2.sprites()[0].rect.x > 990 or ball_list2.sprites()[0].rect.x < 0: | |
ball_list2.sprites()[0].changex = ball_list2.sprites()[0].changex * -1 | |
class ballBR(pygame.sprite.Sprite): | |
def __init__(self, image): | |
pygame.sprite.Sprite.__init__(self) | |
self.image = image | |
self.rect = self.image.get_rect() | |
def bounce(self): | |
ball_list3.sprites()[0].rect.x += ball_list3.sprites()[0].changex | |
ball_list3.sprites()[0].rect.y += ball_list3.sprites()[0].changey | |
if ttime >= 60: | |
ball_list3.sprites()[0].rect.x += ball_list3.sprites()[0].changex * 2 | |
ball_list3.sprites()[0].rect.y += ball_list3.sprites()[0].changey * 2 | |
if ball_list3.sprites()[0].rect.y > 590 or ball_list3.sprites()[0].rect.y < 0: | |
ball_list3.sprites()[0].changey = ball_list3.sprites()[0].changey * -1 | |
if ball_list3.sprites()[0].rect.x > 990 or ball_list3.sprites()[0].rect.x < 0: | |
ball_list3.sprites()[0].changex = ball_list3.sprites()[0].changex * -1 | |
class Wall(pygame.sprite.Sprite): # class for making walls | |
def __init__(self, x, y, width, height, color): | |
pygame.sprite.Sprite.__init__(self) | |
self.image = pygame.Surface([width, height]) | |
self.image.fill(color) | |
self.rect = self.image.get_rect() | |
self.rect.x = x | |
self.rect.y = y | |
class Wall1(pygame.sprite.Sprite): # class for making walls | |
def __init__(self, x, y, width, height, color): | |
pygame.sprite.Sprite.__init__(self) | |
self.image = pygame.Surface([width, height]) | |
self.image.fill(color) | |
self.rect = self.image.get_rect() | |
self.rect.x = x | |
self.rect.y = y | |
class Wall2(pygame.sprite.Sprite): # class for making walls | |
def __init__(self, x, y, width, height, color): | |
pygame.sprite.Sprite.__init__(self) | |
self.image = pygame.Surface([width, height]) | |
self.image.fill(color) | |
self.rect = self.image.get_rect() | |
self.rect.x = x | |
self.rect.y = y | |
class Wall3(pygame.sprite.Sprite): # class for making walls | |
def __init__(self, x, y, width, height, color): | |
pygame.sprite.Sprite.__init__(self) | |
self.image = pygame.Surface([width, height]) | |
self.image.fill(color) | |
self.rect = self.image.get_rect() | |
self.rect.x = x | |
self.rect.y = y | |
player_list = pygame.sprite.Group() | |
player2_list = pygame.sprite.Group() | |
all_sprites_list = pygame.sprite.Group() | |
wall_list = pygame.sprite.Group() | |
wall_list1 = pygame.sprite.Group() | |
wall_list2 = pygame.sprite.Group() | |
wall_list3 = pygame.sprite.Group() | |
new_wall = Wall(10, 10, 980, 20, black) | |
new_wall2 = Wall1(10,570,980,20, black) | |
new_wall3 = Wall2(10, 10, 20, 580, black) | |
new_wall4 = Wall3(980, 10, 20, 580, black) | |
wall_list.add(new_wall) | |
wall_list1.add(new_wall2) | |
wall_list2.add(new_wall3) | |
wall_list3.add(new_wall4) | |
all_sprites_list.add(wall_list.sprites()) | |
all_sprites_list.add(wall_list1.sprites()) | |
all_sprites_list.add(wall_list2.sprites()) | |
all_sprites_list.add(wall_list3.sprites()) | |
new_player = Player(player) | |
player_list.add(new_player) | |
all_sprites_list.add(new_player) | |
new_player2 = Player2(player2) | |
player2_list.add(new_player2) | |
all_sprites_list.add(new_player2) | |
player_list.sprites()[0].rect.y = 390 | |
player_list.sprites()[0].rect.x = 660 | |
player2_list.sprites()[0].rect.y = 390 | |
player2_list.sprites()[0].rect.x = 330 | |
ball_list = pygame.sprite.Group() | |
ball_list1 = pygame.sprite.Group() | |
ball_list2 = pygame.sprite.Group() | |
ball_list3 = pygame.sprite.Group() | |
new_ball = ballTL(ball_image)# top left ball | |
ball_list.add(new_ball) | |
all_sprites_list.add(new_ball) | |
ball_list.sprites()[0].rect.x = 50 | |
ball_list.sprites()[0].rect.y = 50 | |
ball_list.sprites()[0].changex = 8 | |
ball_list.sprites()[0].changey = 8 | |
new_ball2 = ballTR(ball_image2)# top right ball | |
ball_list1.add(new_ball2) | |
all_sprites_list.add(new_ball2) | |
ball_list1.sprites()[0].rect.x = 935 | |
ball_list1.sprites()[0].rect.y = 50 | |
ball_list1.sprites()[0].changex = 8 | |
ball_list1.sprites()[0].changey = 8 | |
new_ball3 = ballBL(ball_image3)# bottom left wall | |
ball_list2.add(new_ball3) | |
all_sprites_list.add(new_ball3) | |
ball_list2.sprites()[0].rect.x = 50 | |
ball_list2.sprites()[0].rect.y = 540 | |
ball_list2.sprites()[0].changex = 8 | |
ball_list2.sprites()[0].changey = 8 | |
new_ball4 = ballBR(ball_image4)# bottom right wall | |
ball_list3.add(new_ball4) | |
all_sprites_list.add(new_ball4) | |
ball_list3.sprites()[0].rect.x = 935 | |
ball_list3.sprites()[0].rect.y = 540 | |
ball_list3.sprites()[0].changex = 8 | |
ball_list3.sprites()[0].changey = 8 | |
keysDown = [] | |
def is_key_down(key): | |
return key in keysDown | |
while True: | |
screen.fill(white) | |
myfont = pygame.font.SysFont("Ariel", 72) | |
label = myfont.render("3", 1, (0,0,0)) | |
screen.blit(label, (490, 30)) | |
time.sleep(1) | |
pygame.display.update() | |
myfont = pygame.font.SysFont("Ariel", 72) | |
label = myfont.render("2", 1, (0,0,0)) | |
screen.blit(label, (490, 90)) | |
time.sleep(1) | |
pygame.display.update() | |
myfont = pygame.font.SysFont("Ariel", 72) | |
label = myfont.render("1", 1, (0,0,0)) | |
screen.blit(label, (490, 150)) | |
time.sleep(1) | |
pygame.display.update() | |
myfont = pygame.font.SysFont("Ariel", 72) | |
label = myfont.render("", 1, (0,0,0)) | |
screen.blit(label, (490, 150)) | |
pygame.display.update() | |
time.sleep(1) | |
screen.fill(white) | |
pygame.display.update() | |
myfont = pygame.font.SysFont("Ariel", 230) | |
label = myfont.render("GO", 1, (0,0,0)) | |
screen.blit(label, (240, 190)) | |
time.sleep(1) | |
pygame.display.update() | |
myfont = pygame.font.SysFont("Ariel", 230) | |
label = myfont.render("", 1, (0,0,0)) | |
screen.blit(label, (200, 190)) | |
time.sleep(1) | |
break | |
a = 0 | |
b = 0 | |
c = 0 | |
d = 0 | |
i = 1 | |
HyperMode=pygame.image.load('Fade.png') | |
HyperMode=HyperMode.convert() | |
amountdown = 100 | |
upordown = random.randint(0,1) | |
upordown1 = random.randint(0,1) | |
time1 = time.time() | |
while True: | |
time2 = time.time() | |
ttime = time2 - time1 | |
amountdown = 100 | |
if upordown == 0:# top wall down | |
if a < amountdown: | |
wall_list.sprites()[0].rect.y += 3 | |
if wall_list.sprites()[0].rect.y > 500: | |
wall_list.sprites()[0].rect.y = 500 | |
if wall_list1.sprites()[0].rect.y - wall_list.sprites()[0].rect.y < 150: | |
wall_list.sprites()[0].rect.y -= 3 | |
a += 1 | |
if a == amountdown: | |
a = 0 | |
upordown = random.randint(0,1)# vertical walls | |
elif upordown == 1: # top wall up | |
if b < amountdown: | |
wall_list.sprites()[0].rect.y -= 3 | |
if wall_list.sprites()[0].rect.y < 10: | |
wall_list.sprites()[0].rect.y = 10 | |
if wall_list1.sprites()[0].rect.y - wall_list.sprites()[0].rect.y < 150: | |
wall_list.sprites()[0].rect.y += 3 | |
b += 1 | |
if b == amountdown: | |
b = 0 | |
upordown = random.randint(0,1)# vertical walls | |
amountdown1 = 100 | |
if upordown1 == 0:# bottom wall down | |
if c < amountdown1: | |
wall_list1.sprites()[0].rect.y += 3 | |
if wall_list1.sprites()[0].rect.y > 500: | |
wall_list1.sprites()[0].rect.y = 500 | |
if wall_list1.sprites()[0].rect.y - wall_list.sprites()[0].rect.y < 150: | |
wall_list1.sprites()[0].rect.y -= 3 | |
c += 1 | |
if c == amountdown1: | |
c = 0 | |
upordown1 = random.randint(0,1) | |
elif upordown1 == 1:# bottom wall up | |
if d < amountdown1: | |
wall_list1.sprites()[0].rect.y -= 3 | |
if wall_list1.sprites()[0].rect.y < 10: | |
wall_list1.sprites()[0].rect.y = 10 | |
if wall_list1.sprites()[0].rect.y - wall_list.sprites()[0].rect.y < 150: | |
wall_list1.sprites()[0].rect.y += 3 | |
d += 1 | |
if d == amountdown1: | |
d = 0 | |
upordown1 = random.randint(0,1) | |
screen.fill((white)) | |
for event in pygame.event.get(): | |
if event.type == pygame.KEYDOWN: | |
keysDown.append(event.key) | |
elif event.type == pygame.KEYUP: | |
keysDown.remove(event.key) | |
if is_key_down(pygame.K_ESCAPE): | |
sys.exit() | |
if is_key_down(pygame.K_UP): | |
player_list.sprites()[0].up() | |
if len(pygame.sprite.spritecollide(player_list.sprites()[0], player2_list, False)) > 0: | |
player_list.sprites()[0].back() | |
if is_key_down(pygame.K_DOWN): | |
player_list.sprites()[0].back() | |
if len(pygame.sprite.spritecollide(player_list.sprites()[0], player2_list, False)) > 0: | |
player_list.sprites()[0].up() | |
if is_key_down(pygame.K_w): | |
player2_list.sprites()[0].up2() | |
if len(pygame.sprite.spritecollide(player2_list.sprites()[0], player_list, False)) > 0: | |
player2_list.sprites()[0].back2() | |
if is_key_down(pygame.K_s): | |
player2_list.sprites()[0].back2() | |
if len(pygame.sprite.spritecollide(player2_list.sprites()[0], player_list, False)) > 0: | |
player2_list.sprites()[0].up2() | |
if is_key_down(pygame.K_LEFT): | |
player_list.sprites()[0].left() | |
if len(pygame.sprite.spritecollide(player_list.sprites()[0], player2_list, False)) > 0: | |
player_list.sprites()[0].right() | |
if is_key_down(pygame.K_RIGHT): | |
player_list.sprites()[0].right() | |
if len(pygame.sprite.spritecollide(player_list.sprites()[0], player2_list, False)) > 0: | |
player_list.sprites()[0].left() | |
if is_key_down(pygame.K_a): | |
player2_list.sprites()[0].left2() | |
if len(pygame.sprite.spritecollide(player2_list.sprites()[0], player_list, False)) > 0: | |
player2_list.sprites()[0].right2() | |
if is_key_down(pygame.K_d): | |
player2_list.sprites()[0].right2() | |
if len(pygame.sprite.spritecollide(player2_list.sprites()[0], player_list, False)) > 0: | |
player2_list.sprites()[0].left2() | |
if ttime >= 10: | |
amountdown = 100 | |
if upordown == 0:# left wall down | |
if a < amountdown: | |
wall_list2.sprites()[0].rect.x += 3 | |
if wall_list2.sprites()[0].rect.x > 850: | |
wall_list2.sprites()[0].rect.x = 850 | |
a = 99 | |
if wall_list3.sprites()[0].rect.x - wall_list2.sprites()[0].rect.x < 300: | |
wall_list2.sprites()[0].rect.x -= 3 | |
a += 1 | |
if a == amountdown: | |
a = 0 | |
upordown = random.randint(0,1) | |
elif upordown == 1: # top wall up | |
if b < amountdown: | |
wall_list2.sprites()[0].rect.x -= 3 | |
if wall_list2.sprites()[0].rect.x < 10: | |
wall_list2.sprites()[0].rect.x = 10 | |
b = 99 | |
if wall_list3.sprites()[0].rect.x - wall_list2.sprites()[0].rect.x < 300: | |
wall_list2.sprites()[0].rect.x -= 3 | |
b += 1 | |
if b == amountdown: | |
b = 0 | |
upordown = random.randint(0,1) | |
amountdown1 = 100 | |
if upordown1 == 0:# bottom wall down | |
if c < amountdown1: | |
wall_list3.sprites()[0].rect.x += 3 | |
if wall_list3.sprites()[0].rect.x > 850: | |
wall_list3.sprites()[0].rect.x = 850 | |
c = 99 | |
if wall_list3.sprites()[0].rect.x - wall_list2.sprites()[0].rect.x < 300: | |
wall_list3.sprites()[0].rect.x += 3 | |
c += 1 | |
if c == amountdown1: | |
c = 0 | |
upordown1 = random.randint(0,1) | |
elif upordown1 == 1:# bottom wall up | |
if d < amountdown1: | |
wall_list3.sprites()[0].rect.x -= 3 | |
if wall_list3.sprites()[0].rect.x == 10: | |
wall_list3.sprites()[0].rect.x = 10 | |
d = 99 | |
if wall_list3.sprites()[0].rect.x - wall_list2.sprites()[0].rect.x < 300: | |
wall_list3.sprites()[0].rect.x += 3 | |
d += 1 | |
if d == amountdown1: | |
d = 0 | |
upordown1 = random.randint(0,1) | |
if len(pygame.sprite.spritecollide(player_list.sprites()[0], wall_list2, False)) > 0: | |
time2 = time.time() | |
ttime = time2 - time1 | |
myfont = pygame.font.SysFont("Ariel", 100) | |
label = myfont.render("Player 2 wins!", 1, (255,0,255)) | |
screen.blit(label, (10, 30)) | |
myfont = pygame.font.SysFont("Ariel", 100) | |
label = myfont.render(("Time of "+str(round(ttime, 2))+" seconds"), 1, (255,0,255)) | |
screen.blit(label, (10, 100)) | |
pygame.display.update() | |
time.sleep(2) | |
sys.exit() | |
if len(pygame.sprite.spritecollide(player_list.sprites()[0], wall_list3, False)) > 0: | |
time2 = time.time() | |
ttime = time2 - time1 | |
myfont = pygame.font.SysFont("Ariel", 100) | |
label = myfont.render("Player 2 wins!", 1, (255,0,255)) | |
screen.blit(label, (10, 30)) | |
myfont = pygame.font.SysFont("Ariel", 100) | |
label = myfont.render(("Time of "+str(round(ttime, 2))+" seconds"), 1, (255,0,255)) | |
screen.blit(label, (10, 100)) | |
pygame.display.update() | |
time.sleep(2) | |
sys.exit() | |
if len(pygame.sprite.spritecollide(player2_list.sprites()[0], wall_list2, False)) > 0: | |
time2 = time.time() | |
ttime = time2 - time1 | |
myfont = pygame.font.SysFont("Ariel", 100) | |
label = myfont.render("Player 1 wins!", 1, (47,185,121)) | |
screen.blit(label, (10, 30)) | |
myfont = pygame.font.SysFont("Ariel", 100) | |
label = myfont.render(("Time of "+str(round(ttime, 2))+" seconds"), 1, (47,185,121)) | |
screen.blit(label, (10, 100)) | |
pygame.display.update() | |
time.sleep(2) | |
sys.exit() | |
if len(pygame.sprite.spritecollide(player2_list.sprites()[0], wall_list3, False)) > 0: | |
time2 = time.time() | |
ttime = time2 - time1 | |
myfont = pygame.font.SysFont("Ariel", 100) | |
label = myfont.render("Player 1 wins!", 1, (47,185,121)) | |
screen.blit(label, (10, 30)) | |
myfont = pygame.font.SysFont("Ariel", 100) | |
label = myfont.render(("Time of "+str(round(ttime, 2))+" seconds"), 1, (47,185,121)) | |
screen.blit(label, (10, 100)) | |
pygame.display.update() | |
time.sleep(2) | |
sys.exit() | |
if len(pygame.sprite.spritecollide(player_list.sprites()[0], wall_list, False)) > 0: | |
time2 = time.time() | |
ttime = time2 - time1 | |
myfont = pygame.font.SysFont("Ariel", 100) | |
label = myfont.render("Player 2 wins!", 1, (255,0,255)) | |
screen.blit(label, (10, 30)) | |
myfont = pygame.font.SysFont("Ariel", 100) | |
label = myfont.render(("Time of "+str(round(ttime, 2))+" seconds"), 1, (255,0,255)) | |
screen.blit(label, (10, 100)) | |
pygame.display.update() | |
time.sleep(2) | |
sys.exit() | |
if len(pygame.sprite.spritecollide(player_list.sprites()[0], wall_list1, False)) > 0: | |
time2 = time.time() | |
ttime = time2 - time1 | |
myfont = pygame.font.SysFont("Ariel", 100) | |
label = myfont.render("Player 2 wins!", 1, (255,0,255)) | |
screen.blit(label, (10, 30)) | |
myfont = pygame.font.SysFont("Ariel", 100) | |
label = myfont.render(("Time of "+str(round(ttime, 2))+" seconds"), 1, (255,0,255)) | |
screen.blit(label, (10, 100)) | |
pygame.display.update() | |
time.sleep(2) | |
sys.exit() | |
if len(pygame.sprite.spritecollide(player2_list.sprites()[0], wall_list, False)) > 0: | |
time2 = time.time() | |
ttime = time2 - time1 | |
myfont = pygame.font.SysFont("Ariel", 100) | |
label = myfont.render("Player 1 wins!", 1, (47,185,121)) | |
screen.blit(label, (10, 30)) | |
myfont = pygame.font.SysFont("Ariel", 100) | |
label = myfont.render(("Time of "+str(round(ttime, 2))+" seconds"), 1, (47,185,121)) | |
screen.blit(label, (10, 100)) | |
pygame.display.update() | |
time.sleep(2) | |
sys.exit() | |
if len(pygame.sprite.spritecollide(player2_list.sprites()[0], wall_list1, False)) > 0: | |
time2 = time.time() | |
ttime = time2 - time1 | |
myfont = pygame.font.SysFont("Ariel", 100) | |
label = myfont.render("Player 1 wins!", 1, (47,185,121)) | |
screen.blit(label, (10, 30)) | |
myfont = pygame.font.SysFont("Ariel", 100) | |
label = myfont.render(("Time of "+str(round(ttime, 2))+" seconds"), 1, (47,185,121)) | |
screen.blit(label, (10, 100)) | |
pygame.display.update() | |
time.sleep(2) | |
sys.exit() | |
if ttime >= 20: | |
ball_list.sprites()[0].bounce() | |
if ttime <= 30: | |
myfont = pygame.font.SysFont("Ariel", 26) | |
label = myfont.render("Level 2", 1, (64,174,128)) | |
screen.blit(label, (1015, 50)) | |
if len(pygame.sprite.spritecollide(player2_list.sprites()[0], ball_list, False)) > 0: | |
time2 = time.time() | |
ttime = time2 - time1 | |
myfont = pygame.font.SysFont("Ariel", 100) | |
label = myfont.render("Player 1 wins!", 1, (47,185,121)) | |
screen.blit(label, (10, 30)) | |
myfont = pygame.font.SysFont("Ariel", 100) | |
label = myfont.render(("Time of "+str(round(ttime, 2))+" seconds"), 1, (47,185,121)) | |
screen.blit(label, (10, 100)) | |
pygame.display.update() | |
time.sleep(2) | |
sys.exit() | |
if len(pygame.sprite.spritecollide(player_list.sprites()[0], ball_list, False)) > 0: | |
time2 = time.time() | |
ttime = time2 - time1 | |
myfont = pygame.font.SysFont("Ariel", 100) | |
label = myfont.render("Player 2 wins!", 1, (255,0,255)) | |
screen.blit(label, (10, 30)) | |
myfont = pygame.font.SysFont("Ariel", 100) | |
label = myfont.render(("Time of "+str(round(ttime, 2))+" seconds"), 1, (255,0,255)) | |
screen.blit(label, (10, 100)) | |
pygame.display.update() | |
time.sleep(2) | |
sys.exit() | |
if ttime >= 30: | |
ball_list1.sprites()[0].bounce() | |
if ttime <= 40: | |
myfont = pygame.font.SysFont("Ariel", 26) | |
label = myfont.render("Level 3", 1, (64,174,128)) | |
screen.blit(label, (1015, 50)) | |
if len(pygame.sprite.spritecollide(player2_list.sprites()[0], ball_list1, False)) > 0: | |
time2 = time.time() | |
ttime = time2 - time1 | |
myfont = pygame.font.SysFont("Ariel", 100) | |
label = myfont.render("Player 1 wins!", 1, (47,185,121)) | |
screen.blit(label, (10, 30)) | |
myfont = pygame.font.SysFont("Ariel", 100) | |
label = myfont.render(("Time of "+str(round(ttime, 2))+" seconds"), 1, (47,185,121)) | |
screen.blit(label, (10, 100)) | |
pygame.display.update() | |
time.sleep(2) | |
sys.exit() | |
if len(pygame.sprite.spritecollide(player_list.sprites()[0], ball_list1, False)) > 0: | |
time2 = time.time() | |
ttime = time2 - time1 | |
myfont = pygame.font.SysFont("Ariel", 100) | |
label = myfont.render("Player 2 wins!", 1, (255,0,255)) | |
screen.blit(label, (10, 30)) | |
myfont = pygame.font.SysFont("Ariel", 100) | |
label = myfont.render(("Time of "+str(round(ttime, 2))+" seconds"), 1,(255,0,255)) | |
screen.blit(label, (10, 100)) | |
pygame.display.update() | |
time.sleep(2) | |
sys.exit() | |
if ttime >= 40: | |
ball_list2.sprites()[0].bounce() | |
if ttime <= 50: | |
myfont = pygame.font.SysFont("Ariel", 26) | |
label = myfont.render("Level 4", 1, (64,174,128)) | |
screen.blit(label, (1015, 50)) | |
if len(pygame.sprite.spritecollide(player2_list.sprites()[0], ball_list2, False)) > 0: | |
time2 = time.time() | |
ttime = time2 - time1 | |
myfont = pygame.font.SysFont("Ariel", 100) | |
label = myfont.render("Player 1 wins!", 1, (47,185,121)) | |
screen.blit(label, (10, 30)) | |
myfont = pygame.font.SysFont("Ariel", 100) | |
label = myfont.render(("Time of "+str(round(ttime, 2))+" seconds"), 1, (47,185,121)) | |
screen.blit(label, (10, 100)) | |
pygame.display.update() | |
time.sleep(2) | |
sys.exit() | |
if len(pygame.sprite.spritecollide(player_list.sprites()[0], ball_list2, False)) > 0: | |
time2 = time.time() | |
ttime = time2 - time1 | |
myfont = pygame.font.SysFont("Ariel", 100) | |
label = myfont.render("Player 2 wins!", 1, (255,0,255)) | |
screen.blit(label, (10, 30)) | |
myfont = pygame.font.SysFont("Ariel", 100) | |
label = myfont.render(("Time of "+str(round(ttime, 2))+" seconds"), 1,(255,0,255)) | |
screen.blit(label, (10, 100)) | |
pygame.display.update() | |
time.sleep(2) | |
sys.exit() | |
if ttime >= 50: | |
ball_list3.sprites()[0].bounce() | |
if ttime <= 60: | |
myfont = pygame.font.SysFont("Ariel", 26) | |
label = myfont.render("Level 5", 1, (64,174,128)) | |
screen.blit(label, (1015, 50)) | |
if len(pygame.sprite.spritecollide(player2_list.sprites()[0], ball_list3, False)) > 0: | |
time2 = time.time() | |
ttime = time2 - time1 | |
myfont = pygame.font.SysFont("Ariel", 100) | |
label = myfont.render("Player 1 wins!", 1, (47,185,121)) | |
screen.blit(label, (10, 30)) | |
myfont = pygame.font.SysFont("Ariel", 100) | |
label = myfont.render(("Time of "+str(round(ttime, 2))+" seconds"), 1, (47,185,121)) | |
screen.blit(label, (10, 100)) | |
pygame.display.update() | |
time.sleep(2) | |
sys.exit() | |
if len(pygame.sprite.spritecollide(player_list.sprites()[0], ball_list3, False)) > 0: | |
time2 = time.time() | |
ttime = time2 - time1 | |
myfont = pygame.font.SysFont("Ariel", 100) | |
label = myfont.render("Player 2 wins!", 1, (255,0,255)) | |
screen.blit(label, (10, 30)) | |
myfont = pygame.font.SysFont("Ariel", 100) | |
label = myfont.render(("Time of "+str(round(ttime, 2))+" seconds"), 1, (255,0,255)) | |
screen.blit(label, (10, 100)) | |
pygame.display.update() | |
time.sleep(2) | |
sys.exit() | |
if ttime >= 60: | |
rect=HyperMode.get_rect() | |
HyperMode.set_alpha(i) | |
screen.fill((255, 255, 255)) | |
screen.blit(screen, screen.get_rect()) | |
screen.blit(HyperMode, rect) | |
i += 1 | |
if i >= 255: | |
i = 1 | |
myfont = pygame.font.SysFont("Ariel", 32) | |
label = myfont.render("Player 1", 1, (47,185,121)) | |
screen.blit(label, (400, 10)) | |
myfont = pygame.font.SysFont("Ariel", 32) | |
label = myfont.render(("Player 2"), 1, (255,0,255)) | |
screen.blit(label, (500, 10)) | |
myfont = pygame.font.SysFont("Ariel", 32) | |
label = myfont.render(("Your time is "+str(round(ttime, 2))+" seconds"), 1, (64,174,128)) | |
screen.blit(label, (700, 10)) | |
all_sprites_list.draw(screen) | |
pygame.display.update() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment