Public feed
#888646
#############################################################################
#The main menu classes for pong #
#############################################################################
import pygame, os, sys
from pygame.locals import *
class menu():
def DrawMenu(self):
#setup the screen#
self.screen = pygame.display.set_mode ((800,600))
pygame.display.set_caption ("pong")
#set image variables and load background#
self.BackGround = pygame.image.load (os.path.join ("Data","menubackground.jpeg"))
self.BackGround = self.BackGround.convert()
#blit image to screen#
self.screen.blit(self.BackGround,(0,0))
def DrawBall(self):
#setting possitional variables#
self.BallX = 140
self.BallY = 140
#get the graphic#
self.Ball = pygame.image.load (os.path.join ("Data", "ball.jpeg"))
self.Ball = self.Ball.convert()
#blit image#
self.screen.blit(self.Ball,(self.BallX,self.BallY))
#menu selct variable and loop#
def BallSel(self):
self.redraw = menu()
self.MenuSel = "none"
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
#lets use use the escape key to exit game#
if event.key == K_ESCAPE:
exit()
#moves ball to bottom choice and checks to see if its there,and exits game
if event.key == K_DOWN and self.BallY != 200:
self.BallY = self.BallY + 60
self.redraw.DrawMenu()
self.screen.blit(self.Ball,(self.BallX,self.BallY))
if event.key == K_RETURN and self.BallY == 100:
exit()
#moves ball to top choice and checks to see if its there,and exits loop
if event.key == K_UP and self.BallY != 140:
self.BallY = self.BallY - 60
self.redraw.DrawMenu()
self.screen.blit(self.Ball,(self.BallX,self.BallY))
if event.key == K_RETURN and self.BallY == 140:
self.MenuSel = "enterpong"