Example #1
0
level = text.level()
###Sprite groups
sprites= pygame.sprite.RenderUpdates(s, score, lives, level)
blocks= pygame.sprite.Group()
bullets= pygame.sprite.Group()
bombs= pygame.sprite.RenderUpdates()
enemy_group = pygame.sprite.Group()
###Instances of blocks
block.make_wall(75, 450, sprites, blocks, width, height)
block.make_wall(275, 450, sprites, blocks, width, height)
block.make_wall(475, 450, sprites, blocks, width, height)
block.make_wall(675, 450, sprites, blocks, width, height)
###Variables for enemy
e_x= 50
e_y= 50
e_image1= load_resources.load_image("graphics/enemy1.png", -1)
e_image2= load_resources.load_image("graphics/enemy2.png", -1)
e_image3= load_resources.load_image("graphics/enemy3.png", -1)
e_image1_2= load_resources.load_image("graphics/enemy1_2.png", -1)
e_image2_2= load_resources.load_image("graphics/enemy2_2.png", -1)
e_image3_2= load_resources.load_image("graphics/enemy3_2.png", -1)
###Main loop	  
while running:   	
    for event in pygame.event.get():
	keys_pressed = pygame.key.get_pressed()
	if event.type == QUIT:
	    running = splash.show_splash(screen)
	    screen.blit(bg_image, (0, 0))
	    pygame.display.flip()
	elif event.type == pygame.KEYDOWN:    
	    if event.key== K_q:
Example #2
0
def show_splash(screen):
    s = start_button()
    q = quit_button()
    h = highscore_button()
    sprites = pygame.sprite.RenderUpdates(s, q, h)
    clock = pygame.time.Clock()
    splash = True
    bg_image = pygame.image.load("graphics/splash/background.png").convert()
    screen.blit(bg_image, (0, 0))
    pygame.display.flip()
    title = load_resources.load_image("graphics/splash/title.png", -1)
    points = load_resources.load_image("graphics/splash/points.png", -1)
    screen.blit(title, (250, 50))
    screen.blit(points, (290, 250))
    pygame.display.flip()
    play = True
    file = "code/highscores.txt"
    while splash:
        for event in pygame.event.get():
            if event.type == QUIT:
                splash = False
                play = False
            if event.type == pygame.KEYDOWN:
                if event.key == K_q:
                    splash = False
                    play = False
                elif event.key == K_ESCAPE:
                    splash = False
                    play = False
            if event.type == MOUSEBUTTONDOWN:
                x, y = event.pos
                distance_s = ((x - s.x)**2 + (y - s.y)**2)**0.5
                if distance_s < 25:
                    splash = False
                distance_q = ((x - q.x)**2 + (y - q.y)**2)**0.5
                if distance_q < 20:
                    splash = False
                    play = False
                distance_h = ((x - h.x)**2 + (y - h.y)**2)**0.5
                if distance_h < 25:
                    pass
            if event.type == MOUSEMOTION:
                x, y = event.pos
                distance_s = ((x - s.x)**2 + (y - s.y)**2)**0.5
                if distance_s < 25:
                    s.color = 0, 255, 0
                else:
                    s.color = 255, 255, 255
                distance_q = ((x - q.x)**2 + (y - q.y)**2)**0.5
                if distance_q < 20:
                    q.color = 0, 255, 0
                else:
                    q.color = 255, 255, 255
                distance_h = ((x - h.x)**2 + (y - h.y)**2)**0.5
                if distance_h < 25:
                    h.color = 0, 255, 0
                else:
                    h.color = 255, 255, 255
        sprites.clear(screen, bg_image)
        sprites.update()
        rectlist = sprites.draw(screen)
        pygame.display.update(rectlist)
        clock.tick(15)
    return play
Example #3
0
def show_splash(screen):
    s = start_button()
    q = quit_button()
    h = highscore_button()
    sprites= pygame.sprite.RenderUpdates(s, q, h)
    clock = pygame.time.Clock()
    splash = True
    bg_image= pygame.image.load("graphics/splash/background.png").convert()
    screen.blit(bg_image, (0, 0))
    pygame.display.flip()
    title = load_resources.load_image("graphics/splash/title.png", -1)
    points = load_resources.load_image("graphics/splash/points.png", -1)
    screen.blit(title, (250, 50))
    screen.blit(points, (290, 250))
    pygame.display.flip()
    play = True
    file = "code/highscores.txt"
    while splash:
	for event in pygame.event.get():
	    if event.type == QUIT:
		splash = False
		play = False
	    if event.type == pygame.KEYDOWN:		
		if event.key== K_q:
		    splash = False
		    play = False
		elif event.key== K_ESCAPE:
		    splash = False
		    play = False
	    if event.type == MOUSEBUTTONDOWN:
		x, y = event.pos
		distance_s= ((x - s.x)**2 + (y - s.y)**2)** 0.5
		if distance_s < 25:
		    splash = False
		distance_q= ((x - q.x)**2 + (y - q.y)**2)** 0.5
		if distance_q < 20:
		    splash = False
		    play = False
		distance_h= ((x - h.x)**2 + (y - h.y)**2)** 0.5
		if distance_h < 25:
		    pass
	    if event.type == MOUSEMOTION:
		x, y = event.pos
		distance_s= ((x - s.x)**2 + (y - s.y)**2)** 0.5
		if distance_s < 25:
		    s.color= 0, 255, 0
		else:
		    s.color= 255, 255, 255
		distance_q= ((x - q.x)**2 + (y - q.y)**2)** 0.5
		if distance_q < 20:
		    q.color= 0, 255, 0
		else:
		    q.color= 255, 255, 255
		distance_h= ((x - h.x)**2 + (y - h.y)**2)** 0.5
		if distance_h < 25:
		    h.color= 0, 255, 0
		else:
		    h.color= 255, 255, 255
	sprites.clear(screen, bg_image) 
	sprites.update()
	rectlist = sprites.draw(screen)
	pygame.display.update(rectlist) 
	clock.tick(15)
    return play