############################################################################# #The main menu classes for pong # ############################################################################# import pygame, os, sys from pygame.locals import * class menu(): def __init__(self): #load all graphics before doing anything becuase J.R. said so# #setup the screen# self.screen = pygame.display.set_mode ((800,600)) pygame.display.set_caption ("!!!PONG!!!") #background image# self.BackGround = pygame.image.load (os.path.join ("Data","menubackground.jpeg")) self.BackGround = self.BackGround.convert() #ball image# self.Ball = pygame.image.load (os.path.join ("Data", "ball.jpeg")) self.Ball = self.Ball.convert() def DrawMenu(self): #blit image to screen# self.screen.blit(self.BackGround,(0,0)) def DrawBall(self): #setting possitional variables# self.BallX = 140 self.BallY = 140 #blit image# self.screen.blit(self.Ball,(self.BallX,self.BallY)) 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 == 200: 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"