コード例 #1
0
ファイル: game.py プロジェクト: afromanjohan/Zatacka
def drawStartscreen(numOfPlayers):
    window.fill(ct("Black"))
    for button in buttons:
        button.draw(window)
    participantText = Textblit(
        "There are currently " + str(numOfPlayers) + " participant(s)",
        WINDOW_WIDTH // 2, WINDOW_HEIGHT // 2, ct("Cyan"))
    participantText.blitText(window)
    drawWindow()
コード例 #2
0
 def __init__(self, x, y, width, height, color, text=""):
     self.x = x
     self.y = y
     self.width = width
     self.height = height
     self.color = ct(color)
     self.text = text
     self.active = True
コード例 #3
0
ファイル: game.py プロジェクト: afromanjohan/Zatacka
def drawScore():
    window.fill(ct("Black"))
    restartButton = Button(WINDOW_WIDTH // 2 - 150, WINDOW_HEIGHT // 2 - 37,
                           300, 75, "Red", "New round")
    restartButton.draw(window)
    for index, player in enumerate(playerList):
        textblit = Textblit(player.name + ": " + str(player.score), 500,
                            100 + index * 40, player.color, "calibri", 20)
        textblit.blitText(window)
    drawWindow()
    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
            elif event.type == pygame.MOUSEBUTTONDOWN:
                pos = pygame.mouse.get_pos()
                if restartButton.isOver(pos):
                    window.fill(ct("Black"))
                    gameLoop()
コード例 #4
0
 def draw(self, win):
     if self.active is False:
         return
     pygame.draw.rect(win, self.color,
                      (self.x, self.y, self.width, self.height))
     if self.text is not "":
         font = pygame.font.SysFont('calibri', 50)
         text = font.render(self.text, 1, ct("Black"))
         win.blit(text,
                  (self.x + (self.width / 2 - text.get_width() / 2),
                   self.y + (self.height / 2 - text.get_height() / 2)))
コード例 #5
0
 def __init__(self, score, left, right, width, height, name):
     self.x = random.randint(100, 1400)
     self.y = random.randint(100, 1100)
     self.color = ct(name)
     self.score = score
     self.alive = True
     self.left = left
     self.right = right
     self.path = []
     self.direction = random.randint(0, 360)
     self.path.append([self.x - 1, self.y - 1, False])
     self.originalDirection = self.direction
     self.xBound = width
     self.yBound = height
     self.name = name
コード例 #6
0
ファイル: game.py プロジェクト: afromanjohan/Zatacka
tickrate = 40
timedelay = 10
clock = pygame.time.Clock()

controllerList = [(pygame.K_LEFT, pygame.K_RIGHT), (pygame.K_q, pygame.K_a),
                  (pygame.K_z, pygame.K_x), (pygame.K_1, pygame.K_2),
                  (pygame.K_6, pygame.K_9), (pygame.K_v, pygame.K_b)]

remainingRounds = 5

#################################################################################################
# Initialize pygame window and required lists for game / gameloop                               #
#################################################################################################
pygame.init()
window = pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT))
window.fill(ct("Black"))
pygame.display.set_caption("Achtung die Kurve - Zatacka")
colors = ["White", "Red", "Cyan", "Yellow", "Pink", "Green", "Blue", "Orange"]
playerList = []
buttons = []

#################################################################################################
# Initialize the first player and add it to the playerlist                                      #
#################################################################################################
man = Player(0, controllerList[0][0], controllerList[0][1], WINDOW_WIDTH,
             WINDOW_HEIGHT, colors[0])
playerList.append(man)

startButton = Button(200, 1000, 200, 70, "Red", "Start")
morePlayersButton = Button(450, 1000, 200, 70, "Red", "+1 Player")
fewerPlayersButton = Button(700, 1000, 200, 70, "Red", "-1 Player")