
# sineLines.py
# Draw a sine curve using connected lines


import pygame, sys, math
from pygame.locals import *

BLACK = (   0,   0,   0)
WHITE = ( 255, 255, 255)


pygame.init()
screen = pygame.display.set_mode([640,480])
screen.fill(WHITE)
pygame.display.set_caption("Sine Curve Drawn with Lines")


coords = []
for x in range(0, 640):
    y = int(math.sin(x/640.0 * 4*math.pi) * 200 + 240)   # sine curve formula
    coords.append((x, y))    # make a list of points

pygame.draw.lines(screen, BLACK, False, coords, 1)    
       # plot the points, joined together


clock = pygame.time.Clock()

running = True
while running:
    clock.tick(30)

    # handle events
    for event in pygame.event.get():
        if event.type == QUIT:
            running = False

    # update game state (nothing yet)
    # redraw game
    pygame.display.update()

pygame.quit()
