You are on page 1of 5

import pygame

import time
import random
#...............................................................................
................................................................................
..............
#...............................................................................
................................................................................
..............
pygame.init()
#colours
white = (255,255,255)
black = (0,0,0)
red = (255,0,0)
green = (0,255,0)
blue = (0,0,255)
#FPS
clock = pygame.time.Clock()
#Display
gameDisplay = pygame.display.set_mode((1000,1000))
#main variables
x = 200
y = 200
changeinx = 0
changeiny = 0
#font
font = pygame.font.SysFont(None, 25)
#...............................................................................
................................................................................
..............
#...............................................................................
................................................................................
..............
def title(msg, colour):
text = font.render(msg, True, colour)
gameDisplay.blit(text, [400,20])
def dialoguex(msg, colour):
text = font.render(msg, True, colour)
gameDisplay.blit(text, [400,20])
def dialogue(msg, colour):
text = font.render(msg, True, colour)
gameDisplay.blit(text, [0,70])
def dialogue1(msg, colour):
text = font.render(msg, True, colour)
gameDisplay.blit(text, [0,100])
def dialogue2(msg, colour):
text = font.render(msg, True, colour)
gameDisplay.blit(text, [0,120])
def dialoguee(msg, colour):
text = font.render(msg, True, colour)
gameDisplay.blit(text, [0,140])
def dialogue3(msg, colour):
text = font.render(msg, True, colour)
gameDisplay.blit(text, [0,200])
def dialogue4(msg, colour):
text = font.render(msg, True, colour)
gameDisplay.blit(text, [0,230])
def dialogue5(msg, colour):

text = font.render(msg, True, colour)


gameDisplay.blit(text, [0,260])
def dialogue6(msg, colour):
text = font.render(msg, True, colour)
gameDisplay.blit(text, [0,300])
def dialogue7(msg, colour):
text = font.render(msg, True, colour)
gameDisplay.blit(text, [0,330])
def dialogue8(msg, colour):
text = font.render(msg, True, colour)
gameDisplay.blit(text, [0,360])
def dialogue9(msg, colour):
text = font.render(msg, True, colour)
gameDisplay.blit(text, [0,390])
def dialoguees(msg, colour):
text = font.render(msg, True, colour)
gameDisplay.blit(text, [0,420])
#main code
fps = 4
difficulty = raw_input("Enter difficulty level eg= hard, med or amt")
if difficulty == "hard":
fps = 40
elif difficulty == "amt":
fps = 20
elif difficulty == "med":
fps = 30

def startup():
start = True
while start:
gameDisplay.fill(white)
title("DASH BLOCK Version 3.0",red)
dialogue("OBJECTIVE OF THE GAME-->",red)
dialogue1("Hello there user, in the game you are the red block t
here will 3 black blocks coming from the righthand side.",red)
dialogue2("User should try to coincide with any one of the 3 blo
cks to score points and in the game 1 block moves straight",red)
dialoguee("forward and the other two blocks move diagonally.",re
d)
dialogue3("POINT SYSTEM",green)
dialogue4("MIDDLE BLOCK ---- 5 POINTS",green)
dialogue5("DIAGONAL BLOCKS ---- 10 POINTS",green)
dialogue6("MADE By--> ",blue)
dialogue7("DARSHAN SHETH",blue)
dialogue8("SAI SOURABH",blue)
dialogue9("SHAIKH FAIZAAN",blue)
dialoguees("HIT y to START THE GAME or n TO Exit", red)
pygame.display.update()
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_y:
my_blockgame()
elif event.key == pygame.K_n:
start = False
pygame.display.update()

def my_blockgame():
x = 200
y = 200
changeinx = 0
changeiny = 0
changeinobsx = 0
changeinobsy = 0
obsx = 990
obsy = round(random.randrange(0,100)/10.0)*10.0
changeinobsx1 = 0
changeinobsy1 = 0
obsx1 = 990
obsy1 = round(random.randrange(150,300)/10.0)*10.0
changeinobsx2 = 0
changeinobsy2 = 0
obsx2 = 990
obsy2 = round(random.randrange(320,500)/10.0)*10.0

exit = True
over = False
while exit:
while over == True:
gameDisplay.fill(blue)
dialoguex("Press K to continue or L to Exit", red)
pygame.display.update()
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_k:
my_blockgame()
elif event.key == pygame.K_l:
over = False
exit = False
for event in pygame.event.get():
c=True
while c:
changeinobsx = -10
changeinobsx1 = -10
changeinobsy2 = -6
changeinobsy = 6
changeinobsx2 = -10
pygame.display.update()
c=False
if event.type == pygame.QUIT:
pygame.display.set_caption("bye :D")
exit = False
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
changeinx = -10
changeiny = 0
elif event.key == pygame.K_RIGHT:
changeinx = +10

changeiny
elif event.key ==
changeiny
changeinx
elif event.key ==
changeiny
changeinx

= 0
pygame.K_UP:
= -10
= 0
pygame.K_DOWN:
= +10
= 0

a = 0
if x==500 or x==0 or y==750 or y==0:
time.sleep(3)
over = True
if (obsx==0 or obsy==750 or obsy==0) and (obsx1==0 or obsy1==750
or obsy1==0) and (obsx2==0 or obsy2==750 or obsy2==0):
my_blockgame()
if (obsx==x and obsy == y):
a=a+10
print"Points",a
if (obsx1==x and obsy1 == y):
a=a+5
print"Points",a
if (obsx2==x and obsy2 == y):
a=a+10
print"Points",a
x = changeinx+x
y = changeiny+y
obsx = changeinobsx+obsx
obsy = changeinobsy+obsy
obsx1 = changeinobsx1+obsx1
obsx2 = changeinobsx2+obsx2
obsy2 = changeinobsy2+obsy2
gameDisplay.fill(black)
pygame.draw.rect(gameDisplay, red, [x,y,100,100])#(x,y,width,hei
ght)
pygame.draw.rect(gameDisplay, white,
pygame.draw.rect(gameDisplay, white,
pygame.draw.rect(gameDisplay, white,
pygame.draw.rect(gameDisplay, white,
pygame.display.update()
clock.tick(fps)#frames per second

[600,0,10,1000])
[obsx,obsy,100,100])
[obsx1,obsy1,100,100])
[obsx2,obsy2,100,100])

#...............................................................................
................................................................................
..............
#...............................................................................
................................................................................
..............
startup()
pygame.quit()
quit

You might also like