#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
#  Pong.py



import pygame, sys
from pygame.locals import *

pygame.init()
fpsClock = pygame.time.Clock()

windowSurface = pygame.display.set_mode((800,600))
pygame.display.set_caption('Broken Pong')

greenColor = pygame.Color(0,255,0)
blackColor = pygame.Color(0,0,0)

ballx, bally = 400, 400
ballxv, ballyv = 4, 4

while True:
	windowSurface.fill(blackColor)
	
	pygame.draw.rect(windowSurface,greenColor,(ballx,bally, 10, 10))
	
	for event in pygame.event.get():
		if event.type == QUIT:
			pygame.quit()
			sys.exit()
		elif event.type == KEYDOWN:
			if event.key == K_ESCAPE:
				pygame.event.post(pygame.event.Event(QUIT))
	
	if ((ballx < 0) or (ballx > 790)) :
		ballxv = ballxv*-1
	if ((bally < 0) or (bally > 590)) :
		ballyv = ballyv*-1
		
	ballx = ballx + ballxv
	bally = bally + ballyv
		
	pygame.display.update()
	fpsClock.tick(30)
