ive been following a tutorial to learn pygame. the code below is to make a window (640 by 400) that s green. The program is also exposed to draw a red line across the screen. so far i have not been sucessfull in having the line appear. any suggestions?
#! /usr/bin/env python import pygame screen = pygame.display.set_mode((640, 400)) running = 1 green = 0, 255, 0 red = 255, 0, 0 point1 = 639, 479 point2 = 0, 0 while running: event = pygame.event.poll() if event.type == pygame.QUIT: running = 0 screen.fill(green) pygame.display.flip() pygame.draw.line(screen, red, point1, point2)
You need to call draw.line before the display.flip(), as it is now you are copying the data from the buffer to the display before the lines is drawn.