LLL
LLL

Reputation: 13

Pygame doesn't draw line

import pygame
import sys
pygame.init()

width, height = 1000, 800

win = pygame.display.set_mode((width, height))
pygame.display.set_caption("Colonizer")
win.fill("white")
pygame.display.update() 
def draw():
    pygame.draw.line(win, ("black"), [width,height/2], [width*2,height/2], 5)  

while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()
    draw()
    pygame.display.update() 

I'm trying to make one simple line and for some reason pygame won't draw it, it just shows white screen.

Upvotes: 1

Views: 65

Answers (1)

Rabbid76
Rabbid76

Reputation: 210876

You cannot "see" the line because it is outside the window. The line starts to the right of the window and continues even further out to the right. Change the coordinates. e.g.:

pygame.draw.line(win, ("black"), [width,height/2], [width*2,height/2], 5)

pygame.draw.line(win, ("black"), [0, height//2], [width, height//2], 5) 

Upvotes: 1

Related Questions