Esempio n. 1
0
def show_gameover_screen():
    draw_text(screen, "GALACTICMOON", 64, WIDTH / 2,
              HEIGHT / 4)  #show game over
    draw_text(screen, "Press W to move up", 40, WIDTH / 2,
              HEIGHT / 2 - 70)  # DISPLAY INSTRUCTION
    draw_text(screen, "Press S to move down", 40, WIDTH / 2,
              HEIGHT / 2 - 30)  # DISPLAY INSTRUCTION
    draw_text(screen, "Press A to move left", 40, WIDTH / 2,
              HEIGHT / 2 + 10)  # DISPLAY INSTRUCTION
    draw_text(screen, "Press D to move right", 40, WIDTH / 2,
              HEIGHT / 2 + 50)  # DISPLAY INSTRUCTION
    draw_text(screen, "Press UP-ARROW to shoot", 40, WIDTH / 2,
              HEIGHT / 2 + 90)  # DISPLAY INSTRUCTION
    draw_text(screen, "PRESS SPACE BEGIN", 40, WIDTH / 2,
              HEIGHT - 100)  #DISPLAY INSTRUCTIONS
    pygame.display.flip()  #allow users to see the endgame screen
    waiting = True  #set a new loop
    while waiting:
        clock.tick(FPS)  #speed at which the loop if gone through
        for event in pygame.event.get():  #quite if the player exits the game
            if event.type == pygame.QUIT:
                pygame.quite()
            if event.type == pygame.KEYUP:  #start the game if the player presses a button
                if event.key == pygame.K_SPACE:
                    waiting = False
Esempio n. 2
0
def play():
    exit=True
    while exit:
        for event in pygame.event.get():
            text("aperte 0 para sair", green)
            pygame.display.update()
            
            if event.type==pygame.QUIT:
                exit=False
            if event.type==pygame.KEYDOWN:
            if event.key==pygame.K_0:
                exit=False
            if event.type==pygame.K_BACKSPACE:
                if c_intro==0:
                    intro1()
                    c_intro+=1
                if c_intro==1:
                    intro2()
                    c_intro+=1
                if c_intro==2:
                    intro3()
                    c_intro+=1
                if c_intro==3:
                    intro4()
                    c_intro+=1
                if c_intro==4:
                    intro5()
                    c_intro+=1
            if event.key==pygame.K_1:
                room=1
                c_action+=1
                living()
            if event.key==pygame.K_2:
                room=2
                c_action+=1
                bed1()
            if event.key==pygame.K_3:
                room=3
                c_action+=1
                bed2()
            if event.key==pygame.K_4:
                room=4
                c_action+=1
                kitchen()
            if event.key==pygame.K_5:
                room=5
                c_action+=1
                bath()
            if c_action==50:
                proves()

        back.fill(back_color)
        relogio.trick(20)
        pygame.display.update()

    pygame.quite()
Esempio n. 3
0
def fireShell(xy, tankx, tanky, turPos, gun_power, xlocation, barrier_width,
              randomHeight, enemyTankX, enemyTankY):
    fire = True
    damage = 0

    startingShell = list(xy)
    print("Fire!", xy)

    while fire:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quite()
                quit()
        #print(startingShell [0],startingShell[1])
        pygame.draw.circle(gameDisplay, red,
                           (startingShell[0], startingShell[1]), 5)

        startingShell[0] -= (12 - turPos) * 2

        startingShell[1] += int((((startingShell[0] - xy[0]) * 0.015 /
                                  (gun_power / 50))**2) - (turPos + turPos /
                                                           (12 - turPos)))

        if startingShell[1] > display_height - ground_height:
            print("Last shell:", startingShell, [0], startingShell[1])
            hit_x = int((startingShell[0] * display_height - ground_height) /
                        startingShell[1])
            hit_y = int(display_height - ground_height)
            print("Impact:", hit_x, hit_y)

            if enemyTankX + 15 > hit_x > enemyTankY - 15:
                print("Hit Target!")
                damage = 25

            explosion(hit_x, hit_y)
            fire = False

        check_x_1 = startingShell[0] <= xlocation + barrier_width
        check_x_2 = startingShell[0] >= xlocation

        check_y_1 = startingShell[1] <= display_height
        check_y_2 = startingShell[1] >= display_height - randomHeight

        if check_x_1 and check_x_2 and check_y_1 and check_y_2:
            print("Last shell:", startingShell, [0], startingShell[1])
            hit_x = int(startingShell[0])
            hit_y = int(startingShell[1])
            print("Impact:", hit_x, hit_y)
            explosion(hit_x, hit_y)
            fire = False

        pygame.display.update()
        clock.tick(60)
    return damage
Esempio n. 4
0
def paused():
	largeText = pygame.font.SysFont("comicsansms",115)
	TextSurf, TextRect = text_objects("Paused", largeText)
	TextRect.center = ((d_width/2),(d_height/2))
	gameDisplay.blit(TextSurf, TextRect)
	pygame.mixer.music.pause()
	while pause:
		for event in pygame.event.get():
			if event.type ==pygame.QUIT:
				pygame.quite()
				quit()
		button("Continue", 150,450, 100,50, green, bright_green, unpause)
		button("Quit", 550,450,100,50, red, bright_red, quitgame)
		pygame.display.update()
		clock.tick(15)
Esempio n. 5
0
def main(win, width):
    ROWS = 50
    grid = make_grid(ROWS, width)

    start = None
    end = None

    run = True
    started = False

    while run:
        draw(win, grid, ROWS, width)
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                run = False

            if started:
                continue

            if pygame.mouse.get_pressed()[0]:  # Left click
                pos = pygame.mouse.get_pos()
                row, col = get_clicked_pos(pos, ROWS, width)
                node = grid[row][col]
                if not start and node != end:
                    start = node
                    start.make_start()

                elif not end and node != start:
                    end = node
                    end.make_end()

                elif node != end and node != start:
                    node.make_barrier()

            elif pygame.mouse.get_pressed()[2]:  # Right click
                pass

    pygame.quite()
Esempio n. 6
0
def play():
    exit=True
    while exit:
        for event in pygame.event.get():
            if event.type==pygame.QUIT:
                exit=False
            if event.type==pygame.KEYDOWN:
            if event.key==pygame.
            if event.key==pygame.K_0:
                exit=False
            if event.key==pygame.K_1:
                room=1
                def living()
            if event.key==pygame.K_2:
            if event.key==pygame.K_3:
            if event.key==pygame.K_4:
            if event.key==pygame.K_5:

        back.fill(back_color)
        relogio.trick(20)
        pygame.display.update()

    pygame.quite()
Esempio n. 7
0
import pygame, sys
from pygame.locals import *

pygame.init()
screen = pygame.display.set_mode((600, 600), 0, 32)

while True:
    for event in pygame.event.get():
        if event.type == QUIT:
            pygame.quite()
            sys.exit()

    screen.lock()
    pygame.draw.rect(screen, (140, 240, 145), Rect((100, 100), (100, 100)))
    screen.unloc
    k()

    pygame.display.update()
Esempio n. 8
0
def e_fireShell(xy, tankx, tanky, turPos, gun_power, xlocation, barrier_width,
                randomHeight, ptankx, ptanky):

    damage = 0
    currentPower = 1
    power_found = False

    while not power_found:
        currentPower += 1
        if currentPower > 100:
            power_found = True
        fire = True
        startingShell = list(xy)

        while fire:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    pygame.quite()
                    quit()
            #pygame.draw.circle(gameDisplay, red, (startingShell[0],startingShell[1]),5)

            startingShell[0] += (12 - turPos) * 2
            startingShell[1] += int((((startingShell[0] - xy[0]) * 0.015 /
                                      (currentPower / 50))**2) -
                                    (turPos + turPos / (12 - turPos)))

            if startingShell[1] > display_height - ground_height:
                hit_x = int(
                    (startingShell[0] * display_height - ground_height) /
                    startingShell[1])
                hit_y = int(display_height - ground_height)
                #explosion(hit_x,hit_y)
                if ptankx + 15 > hit_x > ptankx - 15:
                    print("target acquired!")
                    power_found = True
                fire = False

            check_x_1 = startingShell[0] <= xlocation + barrier_width
            check_x_2 = startingShell[0] >= xlocation

            check_y_1 = startingShell[1] <= display_height
            check_y_2 = startingShell[1] >= display_height - randomHeight

            if check_x_1 and check_x_2 and check_y_1 and check_y_2:
                hit_x = int(startingShell[0])
                hit_y = int(startingShell[1])
                #explosion(hit_x,hit_y)
                fire = False

    fire = True
    startingShell = list(xy)
    print("Fire!", xy)

    while fire:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quite()
                quit()
        #print(startingShell [0],startingShell[1])
        pygame.draw.circle(gameDisplay, red,
                           (startingShell[0], startingShell[1]), 5)

        startingShell[0] += (12 - turPos) * 2

        startingShell[1] += int((((startingShell[0] - xy[0]) * 0.015 /
                                  (currentPower / 50))**2) - (turPos + turPos /
                                                              (12 - turPos)))

        if startingShell[1] > display_height - ground_height:
            print("Last shell:", startingShell, [0], startingShell[1])
            hit_x = int((startingShell[0] * display_height - ground_height) /
                        startingShell[1])
            hit_y = int(display_height - ground_height)
            print("Impact:", hit_x, hit_y)
            if ptankx + 15 > hit_x > ptankx - 15:
                print("Hit Target!")
                damage = 25
            explosion(hit_x, hit_y)
            fire = False

        check_x_1 = startingShell[0] <= xlocation + barrier_width
        check_x_2 = startingShell[0] >= xlocation

        check_y_1 = startingShell[1] <= display_height
        check_y_2 = startingShell[1] >= display_height - randomHeight

        if check_x_1 and check_x_2 and check_y_1 and check_y_2:
            print("Last shell:", startingShell, [0], startingShell[1])
            hit_x = int(startingShell[0])
            hit_y = int(startingShell[1])
            print("Impact:", hit_x, hit_y)
            explosion(hit_x, hit_y)
            fire = False

        pygame.display.update()
        clock.tick(60)
    return damage
Esempio n. 9
0
import pygame,sys
from pygame.locals import *
pygame.init()
MYDISPLAY=pygame.display.set_mode((400,200))
MYDISPLAY.fill((255,255,255))
pygame.draw.line(MYDISPLAY,(0,255,0),(50,50),(100,100))
while 1:
   for event in pygame.event.get():
       if event.type==QUIT:
           pygame.quite()
           sys.exit()
   pygame.display.update()   


Esempio n. 10
0
    def events(self):
        for event in pg.event.get():
            if event.type == pg.QUIT:
                if self.playing:
                    self.playing = False
                self.running = False

    def draw(self):
        self.screen.fill(BLACK)
        self.all_sprites.draw(self.screen)
        pg.display.flip()

    def show_start_screen(self):
        pass

    def show_go_screen(self):
        # show game over screen
        pass


g = Game()
g.show_start_screen()

while g.running:
    g.new()
    g.run()
    g.show_go_screen()

pg.quite()
Esempio n. 11
0
def option():
    global musics
    musics=True
    screen.fill(BLACK)
    regNo = 0
    clicked=False
    onoff='on'
    while True:
        if regNo<0:
            regNo=4
        if regNo>4:
            regNo=1
        message_display('Snake Game',
                    80,red,(330),(100))
        mouse = pygame.mouse.get_pos()
        
        for event in pygame.event.get():
            if event.type== pygame.QUIT:
                pygame.quite()
                quit()
            if event.type==pygame.KEYDOWN:
                
                if event.key==pygame.K_UP:
                    regNo-=1
                if event.key==pygame.K_DOWN:
                    regNo+=1
                if event.key==pygame.K_KP_ENTER:
                    clicked=True
                    if musics==True:
                        musics=False
                    else:
                        musics=True
            if event.type==pygame.KEYUP:
                if event.key==pygame.K_KP_ENTER:
                    clicked = False
                    
        
        click = pygame.mouse.get_pressed()
        
        if (250 < mouse[0] <250 + 300 and 200 < mouse[1] < 250) or regNo==1:
            pygame.draw.rect(screen, bright_black,(250,200,300,50))
            message_display('Classic Mode',30,WHITE,(360),(220))
            if click[0]==1 or clicked==True:
                gameloopclass()
        else:
            pygame.draw.rect(screen, BLACK,(250,200,300,50))
            message_display('Classic Mode',30,WHITE,(360),(220))
        if (250 < mouse[0] <250 + 300 and 270< mouse[1] <320) or regNo==2:
            pygame.draw.rect(screen, bright_black,(250,270,300,50))
            message_display('Standard Mode',30,WHITE,(360),(290))
            if click[0]==1 or clicked==True:
                gameloop()
        else:
            pygame.draw.rect(screen, BLACK,(250,270,300,50))
            message_display('Standard Mode',30,WHITE,(360),(290))
        
        if (250 < mouse[0] <250 + 300 and 340< mouse[1] <390) or regNo==3:
            pygame.draw.rect(screen, bright_black,(250,340,300,50))
            message_display('Sound '+str(onoff),30,WHITE,(360),(360))
            if click[0]==1 or clicked==True:
                if musics==True:
                    pygame.mixer.music.unpause()
                    onoff='on'
                elif musics==False:
                    pygame.mixer.music.pause()
                    onoff='off'
        else:
            pygame.draw.rect(screen, BLACK,(250,340,300,50))
            message_display('Sound '+str(onoff),30,WHITE,(360),(360))
        if (250 < mouse[0] <250 + 300 and 410< mouse[1] <460) or regNo==4:
            pygame.draw.rect(screen, bright_black,(250,410,300,50))
            message_display('Quit',30,WHITE,(360),(430))
            if click[0]==1 or clicked==True:
                pygame.quit()
                quit()
        else:
            pygame.draw.rect(screen, BLACK,(250,410,300,50))
            message_display('Quit',30,WHITE,(360),(430))
    
                
        pygame.display.update()
        clock.tick(10)