Exemplo n.º 1
0
    def generateInterface(self, interfaceWidth, interfaceHeight):

        lineMargin = 10
        interfaceText = interfaceWidth * 0.06
        heightMargin = self.Height * 0.08
        widthMargin = self.Width * 0.04
        image(self.img, self.Width - self.imgWidth - 200,
              self.Height - self.imgHeight)
        image(self.img1, interfaceWidth - 50, self.Height - self.imgHeight + 7)
        font = createFont("Georgia", interfaceText)
        textFont(font)
        textAlign(LEFT)

        fill(0, 0, 0)
        stroke(255, 255, 255)
        rect(0, 0, interfaceWidth, interfaceHeight)

        fill(250, 250, 250)

        text("Frame Count =  " + str(frameCount), widthMargin, heightMargin)
        lst = []
        for i in range(12):
            lst.append(False)
        #line(40, interfaceWidth - 100, 40, heightMargin - 20)
        text("Swarm Count =  " + str(self.swarmCount), widthMargin,
             heightMargin * 2)
        but = button(interfaceWidth - 60, heightMargin * 2 - 18, "I", 20)
        lst[0] = but.draw(20, 20)
        but1 = button(interfaceWidth - 30, heightMargin * 2 - 18, "D", 20)
        lst[1] = but1.draw(20, 20)
        text("Inertia = " + str(self.inertia), widthMargin, heightMargin * 3)
        but2 = button(interfaceWidth - 60, heightMargin * 3 - 18, "I", 20)
        lst[2] = but2.draw(20, 20)
        but3 = button(interfaceWidth - 30, heightMargin * 3 - 18, "D", 20)
        lst[3] = but3.draw(20, 20)
        text("c1 = " + str(self.c1), widthMargin, heightMargin * 4)
        but4 = button(interfaceWidth - 60, heightMargin * 4 - 18, "I", 20)
        lst[4] = but4.draw(20, 20)
        but5 = button(interfaceWidth - 30, heightMargin * 4 - 18, "D", 20)
        lst[5] = but5.draw(20, 20)
        text("c2 = " + str(self.c2), widthMargin, heightMargin * 5)
        but6 = button(interfaceWidth - 60, heightMargin * 5 - 18, "I", 20)
        lst[6] = but6.draw(20, 20)
        but7 = button(interfaceWidth - 30, heightMargin * 5 - 18, "D", 20)
        lst[7] = but7.draw(20, 20)

        button1 = button(widthMargin, heightMargin * 6, "Restart", 23)
        button2 = button(widthMargin, heightMargin * 7 + 20, "Pause", 23)
        #button3 = button(widthMargin,heightMargin*8+40,"Restart", 23)

        lst[8] = button1.Draw()

        lst[9] = button2.Draw()

        #lst[10] = button3.Draw()
        button1.addText(widthMargin + 15)
        button2.addText(widthMargin + 8)
        #button3.addText(widthMargin+2)

        return lst
Exemplo n.º 2
0
def tela_inicial():
    abertura = pygame.image.load("./images/capa.png")
    abertura = pygame.transform.smoothscale(abertura, (largura, altura))
    fim_inicial = False
    tempo_inicio = 10000000

    running = True
    while running:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_ESCAPE:
                    pygame.quit()

        tela.blit(abertura, (0, 0))
        if button(40, "START", (190, 510), (255, 255, 255), (255, 0, 0), tela,
                  (255, 255, 38), (255, 0, 0), './fonte.ttf'):
            fim_inicial = True
            tempo_inicio = pygame.time.get_ticks()

        if fim_inicial and (pygame.time.get_ticks() - tempo_inicio) / 1000 < 2:
            corra = pygame.image.load('./images/tela de inicio.png')
            corra = pygame.transform.smoothscale(corra, (largura, altura))
            tela.blit(corra, (0, 0))

        if (pygame.time.get_ticks() - tempo_inicio) / 1000 > 1.9:
            running = False

        pygame.display.update()
        relogio.tick(27)
Exemplo n.º 3
0
 def parseRow(self,row,num):
     for j in range(len(row)):
         if isinstance(row[j], tuple):
             char_ = row[j][0]
         else:
             char_ = row[j]
     #    print char_
         self.rows[num].pack_start(button(self,char_),True,True,5)
Exemplo n.º 4
0
    def mainMenu(self, paleLavander, lightRed, green, event):
        mouse = pygame.mouse.get_pos()
        playButton = button(self.window, paleLavander, 75, 480, 100, 50,
                            "PLAY")
        moreButton = button(self.window, paleLavander, 425, 480, 100, 50,
                            "MORE")

        playButton.draw()
        moreButton.draw()

        if playButton.hover(mouse):
            playButton.color = green
            playButton.draw()
            if event.type == pygame.MOUSEBUTTONDOWN:
                self.stage = "createPlayer"

        if moreButton.hover(mouse):
            moreButton.color = green
            moreButton.draw()
            if event.type == pygame.MOUSEBUTTONDOWN:
                self.stage = "optionsMenu"
Exemplo n.º 5
0
    def optionsMenu(self, paleLavander, lightRed, green, event):
        mouse = pygame.mouse.get_pos()

        controlsButton = button(self.window, paleLavander, 45, 240, 100, 50,
                                "CTRLS")
        returnButton = button(self.window, paleLavander, 45, 430, 100, 50,
                              "BACK")

        controlsButton.draw()
        returnButton.draw()

        if controlsButton.hover(mouse):
            controlsButton.color = green
            controlsButton.draw()
            if event.type == pygame.MOUSEBUTTONDOWN:
                self.stage = "controlsMenu"

        if returnButton.hover(mouse):
            returnButton.color = green
            returnButton.draw()
            if event.type == pygame.MOUSEBUTTONDOWN:
                self.stage = "mainMenu"
Exemplo n.º 6
0
 def __init__(self):
     pygame.init()
     pygame.display.set_caption('Conquer')
     self.setting = Setting()
     self.screen = pygame.display.set_mode(
         (self.setting.width, self.setting.height))
     self.play_button = button(self, 'Play Game')
     self.stats = Game_Stats(self)
     self.sb = scoreboard(self)
     self.ship = Ship(self)
     self.bullets = pygame.sprite.Group()
     self.aliens = pygame.sprite.Group()
     self.raindrops = pygame.sprite.Group()
     self.Fleet()
Exemplo n.º 7
0
    def controlsMenu(self, paleLavander, lightRed, green, event):
        mouse = pygame.mouse.get_pos()

        arrowsImage = pygame.transform.scale(
            pygame.image.load('images/mainMenu/arrows.png'), (150, 100))
        wasdImage = pygame.transform.scale(
            pygame.image.load('images/mainMenu/wasd.png'), (150, 100))

        self.window.blit(arrowsImage, (75, 300))
        self.window.blit(wasdImage, (375, 300))

        returnButton = button(self.window, paleLavander, 450, 500, 100, 50,
                              "BACK")
        returnButton.draw()

        if returnButton.hover(mouse):
            returnButton.color = green
            returnButton.draw()
            if event.type == pygame.MOUSEBUTTONDOWN:
                self.stage = "optionsMenu"
Exemplo n.º 8
0
winWidht = 800
winHeight = 700

PongButtonColor = (0, 255, 255)
ExitButtonColor = (255, 0, 0)

win = pygame.display.set_mode((winWidht, winHeight))
pygame.display.set_caption('MainMenu')

#PongButton
startPong = False
SBx = winWidht / 2
SBy = winHeight / 3
SBtext = "Pong"
StartButton = button(PongButtonColor, 150, 60, SBx, SBy)

#ExitButton
exitGame = False
SBx = winWidht / 2
SBy = winHeight / 2
EBtext = "Exit"
ExitButton = button(ExitButtonColor, 150, 60, SBx, SBy)

all_sprites_list = pygame.sprite.Group()
all_sprites_list.add(StartButton)
all_sprites_list.add(ExitButton)

run = True

Exemplo n.º 9
0
        # text for the problem
        if Original_BOARD[col][row] != 0:
            textsurface[col][row] = myfont.render(str(Original_BOARD[col][row]), False, Index.Black)
            body_canvas.blit(textsurface[col][row], (RectX + Index.blockLenghtX/4, RectY))
        else:
            textsurface[col][row] = myfont.render("", False, Index.White)


#\ bar
# start button
start_button = button(Index.start_button_Color,
                        Index.start_button_positionX,
                        Index.start_button_positionY,
                        Index.start_buttonW,
                        Index.start_buttonH,
                        "START",
                        Index.start_button_TextColor,
                        Index.button_text_size
                    )

# end button
end_button = button(Index.end_button_Color,
                        Index.end_button_positionX,
                        Index.end_button_positionY,
                        Index.end_buttonW,
                        Index.end_buttonH,
                        "END",
                        Index.end_button_TextColor,
                        Index.button_text_size
                    )