Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.6 kB
1
Indexable
Never
font = pygame.font.Font('RubikWetPaint-Regular.ttf', 32)

text_img = font.render('0', False, (255, 0, 0) )
text = text_img.get_rect()
text.x = 100
text.y = 550

text2_img = font.render('0', False, (0, 0, 255) )
text2 = text2_img.get_rect()
text2.x = 600
text2.y = 550

running = True
while running == True:
    screen.fill( (89, 179, 66) ) #RGB

    for event in pygame.event.get():
        if event.type == QUIT:
            running = False
        if event.type == KEYDOWN:
            if event.key == K_LEFT:
                player.x -= 10
            if event.key == K_RIGHT:
                player.x += 10
            if event.key == K_UP:
                player.y -= 10
            if event.key == K_DOWN:
                player.y += 10

            if event.key == K_a:
                player2.x -= 10
            if event.key == K_d:
                player2.x += 10
            if event.key == K_w:
                player2.y -= 10
            if event.key == K_s:
                player2.y += 10

    if player.colliderect(cookie):
        cookie.x = random.randint(0, 800 - 256)
        cookie.y = random.randint(0, 600 - 256)
        player_points += 1
        text_img = font.render( str(player_points), False, (255,0,0))

    if player2.colliderect(cookie):
        cookie.x = random.randint(0, 800 - 256)
        cookie.y = random.randint(0, 600 - 256)
        player2_points += 1
        text2_img = font.render( str(player2_points), False, (0,0,255))

    screen.blit(player_img, player)
    screen.blit(player2_img, player2)
    screen.blit(cookie_img, cookie)
    screen.blit(text_img, text)
    screen.blit(text2_img, text2)