###################################################
#pygame facilitator
#goal : not giving a fuck about pygame
###################################################

###################################################
#dependency
###################################################
import pygame


#constant
###################################################
width = 1024
height = 512


#initialisation
###################################################
screen = pygame.display.set_mode((width, height))
clock = pygame.time.Clock()

up =  False
down =  False
left =  False
right = False

#function
###################################################

#main loop
def main():
	#activate write on global
	global left, right, up, down
	#user input event loop
	for event in pygame.event.get():
		if event.type==pygame.QUIT:
			return False
		elif event.type==pygame.KEYDOWN:
			if event.key == pygame.K_ESCAPE:
				return False
			elif event.key == pygame.K_UP:
				up = True
			elif event.key == pygame.K_DOWN:
				down = True
			elif event.key == pygame.K_LEFT:
				left = True
			elif event.key == pygame.K_RIGHT:
				right = True
		elif event.type==pygame.KEYUP:
			if event.key == pygame.K_ESCAPE:
				return False
			elif event.key == pygame.K_UP:
				up = False
			elif event.key == pygame.K_DOWN:
				down = False
			elif event.key == pygame.K_LEFT:
				left = False
			elif event.key == pygame.K_RIGHT:
				right = False
	#graphic refresh
	pygame.display.flip()
	screen.fill((255,255,255))
	#frame per second
	clock.tick(60)
	#return false if program terminated
	return True

def line(x1,y1,x2,y2,color=(245,245,0)):
	pygame.draw.line(screen,color,(int(x1),int(y1)),(int(x2),int(y2)))

def circle(x,y, r=2, color=(220,0,220)):
	pygame.draw.circle(screen, color, (int(x),int(y)), r)

def plot(x,y,color=(0,127,0)):
	screen.set_at((int(x),int(y)),color)


#testing code
###################################################
if __name__ == "__main__":
	while main():
		plot(width/2,height/2)
