コード例 #1
0
    def __init__(self, window, rank, suit, value):

        self.window = window
        self.rank = rank
        self.suit = suit
        self.value = value

        self.nameOfCard = str(value) + ' of ' + suit

        if value == 1:
            self.nameOfCard = 'Ace of ' + suit
        if value == 11:
            self.nameOfCard = 'Jack of ' + suit
        if value == 12:
            self.nameOfCard = 'Queen of ' + suit
        if value == 13:
            self.nameOfCard = 'King of ' + suit

        #print('ImageName is .....' + self.nameOfCard)
        self.imageName = 'images/' + self.nameOfCard + '.png'

        self.cardImage = pygwidgets.Image(window, (85, 300), self.imageName)
        self.backOfCardImage = pygwidgets.Image(window, (85, 300),
                                                'images/BackOfCard.png')

        self.concealorRevealState = 0
コード例 #2
0
    def __init__(self, window):
        self.window = window

        self.backgroundImage = pygwidgets.Image(self.window,
                                                (0, 0), 'images/splashBackground.jpg')
        self.dodgerImage = pygwidgets.Image(self.window,
                                                (150, 30), 'images/dodger.png')
        
        self.startButton = pygwidgets.CustomButton(self.window, (250, 500),
                                                up='images/startNormal.png',
                                                down='images/startDown.png',
                                                over='images/startOver.png',
                                                disabled='images/startDisabled.png',
                                                enterToActivate=True)

        self.quitButton = pygwidgets.CustomButton(self.window, (30, 650),
                                                up='images/quitNormal.png',
                                                down='images/quitDown.png',
                                                over='images/quitOver.png',
                                                disabled='images/quitDisabled.png')

        self.highScoresButton = pygwidgets.CustomButton(self.window, (360, 650),
                                                up='images/gotoHighScoresNormal.png',
                                                down='images/gotoHighScoresDown.png',
                                                over='images/gotoHighScoresOver.png',
                                                disabled='images/gotoHighScoresDisabled.png')
コード例 #3
0
    def __init__(self, window):
        # Save window in instance variables
        self.window = window

        self.backgroundImage = pygwidgets.Image(self.window, (0, 0),
                                                "images/gridBG.png")
        self.dialogImage = pygwidgets.Image(self.window, (150, 30),
                                            "images/score.jpg")

        self.quitButton = pygwidgets.TextButton(self.window, (270, 420),
                                                'Quit')
        self.restartButton = pygwidgets.TextButton(self.window, (570, 420),
                                                   'Restart')

        self.clicksField = pygwidgets.DisplayText(self.window, (500, 223),
                                                  '',
                                                  fontSize=30)
        self.hitsField = pygwidgets.DisplayText(self.window, (500, 250),
                                                '',
                                                fontSize=30)
        self.missesField = pygwidgets.DisplayText(self.window, (500, 278),
                                                  '',
                                                  fontSize=30)
        self.missedTargetsField = pygwidgets.DisplayText(self.window,
                                                         (500, 306),
                                                         '',
                                                         fontSize=30)
        self.scoreField = pygwidgets.DisplayText(self.window, (500, 362),
                                                 '',
                                                 fontSize=30)
コード例 #4
0
    def __init__(self, window):
        # Save window in instance variable
        self.window = window

        self.backgroundImage = pygwidgets.Image(self.window, (0, 0),
                                                "images/gridBG.png")
        self.dialogImage = pygwidgets.Image(self.window, (150, 30),
                                            "images/splash.jpg")

        self.startButton = pygwidgets.TextButton(self.window, (430, 380),
                                                 'Start')
コード例 #5
0
 def __init__(self, window, id):
     self.window = window
     self.id = id
     # Load pictures Left to Right and Right to Left
     self.pictureLR = pygwidgets.Image(self.window, (0, 0),
                                       'images/bugLR.png')
     self.pictureRL = pygwidgets.Image(self.window, (0, 0),
                                       'images/bugRL.png')
     bugRect = self.pictureLR.getRect()
     self.width = bugRect[2]  # element 2 is the width
     self.setSpeed(1)
     self.resetLoc()
コード例 #6
0
    def __init__(self, window, sceneKey):
        # Save window and sceneKey in instance variables
        self.window = window
        self.sceneKey = sceneKey

        self.messageField = pygwidgets.DisplayText(self.window, (15, 25), 'Welcome to Turtle-Hare Race!', \
                                              fontSize=50, textColor=Constants.GRAYA, width=610, justified='center')
        self.oEnterButton = pygwidgets.TextButton(self.window, (250, 100), 'Enter')
        
        self.hare = pygwidgets.Image(window, (150, 100), 'images/hare.gif')
        self.turtle = pygwidgets.Image(window, (390, 100), 'images/turtle.gif')
        
        self.oRace = RaceWidgets.Racing
コード例 #7
0
ファイル: Game.py プロジェクト: gargsand/HigherorLowerGame
 def __init__(self, window, rank, suit, value):
     # must add code here to save away parameters in instance variables
     # and create two Image objects, one for the current card, one for the backOfCard
     # you can remove this line when you add your own
     self.window = window
     self.rank = rank
     self.CardName = suit
     self.value = value
     self.image = pygwidgets.Image(
         window, (0, 0),
         'images/' + self.rank + ' of ' + self.CardName + '.png')
     self.backOfImage = pygwidgets.Image(window, (0, 0),
                                         'images/BackOfCard.png')
     self.cardImage = self.image
     self.loc = ''
コード例 #8
0
ファイル: ScenePlay.py プロジェクト: katelaw91/Goblin
    def __init__(self, window, sceneKey):
        # Save window and sceneKey in instance variables
        self.window = window
        self.sceneKey = sceneKey
        self.playBackground = pygwidgets.Image(self.window, (0, 0), IMAGE_LEVEL_1)
        self.atmosphere = pygwidgets.Image(self.window, (0,0), ATMOSPHERE)
        self.glow = pygwidgets.Image(self.window, (0, 0), GLOW_LEVEL_1)
        self.levelState = GOBLIN_LOWER

        #instantiate objects
        self.oVillagersMgr = VillagersMgr(self.window)
        self.oGoblinMgr = GoblinMgr(self.window)
        self.oPlayer = Player(self.window)

        self.deathCount = 0
        self.backgroundMusic = True
コード例 #9
0
ファイル: SceneHighScores.py プロジェクト: IrvKalb/pyghelpers
def showCustomAnswerDialog(theWindow, theText):
    oDialogBackground = pygwidgets.Image(theWindow, (35, 450),
                                         'images/dialog.png')
    oPromptDisplayText = pygwidgets.DisplayText(theWindow, (0, 480),
                                                theText,
                                                width=WINDOW_WIDTH,
                                                justified='center',
                                                fontSize=36)
    oUserInputText = pygwidgets.InputText(theWindow, (200, 550),
                                          '',
                                          fontSize=36,
                                          initialFocus=True)
    oNoButton = pygwidgets.CustomButton(theWindow, (65, 595),
                                        'images/noThanksNormal.png',
                                        over='images/noThanksOver.png',
                                        down='images/noThanksDown.png',
                                        disabled='images/noThanksDisabled.png')
    oYesButton = pygwidgets.CustomButton(theWindow, (330, 595),
                                         'images/addNormal.png',
                                         over='images/addOver.png',
                                         down='images/addDown.png',
                                         disabled='images/addDisabled.png')
    userAnswer = pyghelpers.customAnswerDialog(theWindow, oDialogBackground,
                                               oPromptDisplayText,
                                               oUserInputText, oYesButton,
                                               oNoButton)
    return userAnswer
コード例 #10
0
    def __init__(self, window, sceneKey):
        # Save window and sceneKey in instance variables
        self.window = window
        self.sceneKey = sceneKey

        self.backgroundImage = pygwidgets.Image(self.window, (0, 0), "images/GameOverBackground.jpg")

        # The following will create a list of lists
        # Either by building a blank one from scratch, or by reading from a text file
        # The result will look like:
        # [[name, score], [name, score], [name, score] ...]
        # and will always be kept in order of the score (highest to lowest)
        if not SceneManager.fileExists(SceneGameOver.DATA_FILE_PATH):
            self.setEmptyGameOver()
        else:
            data = SceneManager.readFile(SceneGameOver.DATA_FILE_PATH)
            # read in all the data in json format, converts to a list of lists
            self.scoresList = json.loads(data)

        self.scoresField = pygwidgets.DisplayText(self.window, (25, 84), '', \
                                fontSize=48, textColor=BLACK, width=175, justified='right')
        self.namesField = pygwidgets.DisplayText(self.window, (260, 84), '', \
                                fontSize=48, textColor=BLACK, width=300, justified='left')

        self.quitButton = pygwidgets.TextButton(self.window, (30, 650), 'Quit')
        self.resetScoresButton = pygwidgets.TextButton(self.window, (240, 650), 'Reset high scores')
        self.startNewGameButton = pygwidgets.TextButton(self.window, (450, 650), 'Start new game')

        self.showGameOver()
コード例 #11
0
    def __init__(self, window):
        '''
        This method is called when the scene is created
        Create and/or load any assets (images, buttons, sounds)
        that you need for this scene
        :param window:
        '''
        # Save window in instance variable
        self.window = window

        # 4 - Load assets: image(s), sounds,  etc.
        self.oGrid = Grid(window)
        self.oPlayer = Player(window)
        self.oBackground = pygwidgets.Image(window, (0, 0), 'images/background.jpg')
        self.oLevelDisplay = pygwidgets.DisplayText(window, (20, 15), '', fontSize=28)
        self.oLivesDisplay = pygwidgets.DisplayText(window, (120, 15), '', fontSize=28)
        self.oScoreDisplay = pygwidgets.DisplayText(window, (220, 15), '', fontSize=28)
        self.oBonusDisplay = pygwidgets.DisplayText(window, (350, 15), '', fontSize=28, textColor=(0, 153, 0))

        self.dingSound = pygame.mixer.Sound('sounds/ding.wav')
        self.winSound = pygame.mixer.Sound('sounds/win.wav')
        self.upSound = pygame.mixer.Sound('sounds/plus.wav')
        self.downSound = pygame.mixer.Sound('sounds/minus.wav')
        self.bonusSound = pygame.mixer.Sound('sounds/bonus.wav')
        self.splatSound = pygame.mixer.Sound('sounds/splat.wav')
        self.loseSound = pygame.mixer.Sound('sounds/lose.wav')
        self.state = ScenePlay.STATE_PLAYING
        self.oTimer = pyghelpers.Timer(.75, callBack=self.startNextRound) # wait 3/5 sec between rounds

        self.reset()
コード例 #12
0
 def __init__(self, window):
     self.window = window
     self.image = pygwidgets.Image(window, (-100, -100),
                                   'images/player.png')
     playerRect = self.image.getRect()
     self.maxX = WINDOW_WIDTH - playerRect.width
     self.maxY = GAME_HEIGHT - playerRect.height
コード例 #13
0
ファイル: SceneGameOver.py プロジェクト: katelaw91/Goblin
    def __init__(self, window, sceneKey):
        # Save window and sceneKey in instance variables
        self.window = window
        self.sceneKey = sceneKey

        # Set background
        self.backgroundImage = pygwidgets.Image(
            self.window, (0, 0), "images/GameOverBackground.jpg")

        # Read/load game data
        if not SceneManager.fileExists(SceneGameOver.DATA_FILE_PATH):
            pass
        else:
            data = SceneManager.readFile(SceneGameOver.DATA_FILE_PATH)
            # read in all the data in json format, converts to a list of lists
            self.scoresList = json.loads(data)


        self.deathCount = pygwidgets.DisplayText(self.window, (25, 84), 'Deaths: ', \
                                fontSize=48, textColor=DARKVIOLET, width=175, justified='right')
        # + str(nameScoreList[1]),\
        self.deathMessage = pygwidgets.DisplayText(self.window, (260, 84), 'YOU DIED', \
                                fontSize=48, textColor=DARKVIOLET, width=300, justified='left')

        self.quitButton = pygwidgets.TextButton(self.window, (30, 650), 'Quit')
        self.startNewGameButton = pygwidgets.TextButton(
            self.window, (450, 650), 'Try Again')
コード例 #14
0
    def __init__(
        self,
        window,
        windowWidth,
        windowHeight,
    ):
        self.window = window  # remember the window, so we can draw later
        self.windowWidth = windowWidth
        self.windowHeight = windowHeight
        self.image = pygwidgets.Image(window, (0, 0), 'images/basket.png')

        # A rect is made up of [x, y, width, height]
        startingRect = self.image.getRect()
        self.width = startingRect[2]  # width
        self.height = startingRect[3]  # height

        self.halfHeight = self.height / 2
        self.halfWidth = self.width / 2

        self.x = self.windowWidth / 2
        self.y = windowHeight - self.height - 20
        self.maxX = self.windowWidth - self.width
        self.image.setLoc((self.x, self.y))

        # Choose speed in the x direction
        self.xSpeed = 12
コード例 #15
0
    def __init__(self, window, sceneKey):
        # Save window and sceneKey in instance variables
        self.window = window
        self.sceneKey = sceneKey

        pygame.mixer.music.load(MUSIC_SPLASH)
        pygame.mixer.music.play(-1)
        pygame.mixer.music.set_volume(1)

        self.backgroundImage = pygwidgets.Image(self.window, (0, 0), BG_SPLASH)
        self.logo = pygwidgets.Image(self.window, (WINDOW_WIDTH/2 - 250, SPLASH_WINDOW_HEIGHT/2 - 200), LOGO)
        self.startButton = pygwidgets.TextButton(self.window, (WINDOW_WIDTH/2 -50, SPLASH_WINDOW_HEIGHT/2 - 50), 'Start', \
                                                 upColor=DUSTYPURPLE, downColor=DARKVIOLET, textColor=WHITE, fontName = FONT_NAME, enterToActivate=True)
        self.quitButton = pygwidgets.TextButton(self.window, (WINDOW_WIDTH/2 -50, SPLASH_WINDOW_HEIGHT/2 + 50), 'Quit', \
                                                upColor=DUSTYPURPLE, downColor=DARKVIOLET, textColor=WHITE, fontName = FONT_NAME, )
        self.controlsButton = pygwidgets.TextButton(self.window, (WINDOW_WIDTH/2 -50, SPLASH_WINDOW_HEIGHT/2), 'Controls', \
                                                    upColor=DUSTYPURPLE, downColor=DARKVIOLET, textColor=WHITE, fontName = FONT_NAME,)
コード例 #16
0
 def __init__(self, window, loc):
     self.image = pygwidgets.Image(window, loc, 'images/Star.png')
     self.startX = loc[0]
     self.startY = loc[1]
     self.x = self.startX
     self.y = self.startY
     self.rect = self.image.getRect()
     self.moving = False
コード例 #17
0
    def __init__(self, window, rank, suit, value):
        # must add code here to save away parameters in instance variables
        # and create two Image objects, one for the current card, one for the backOfCard
        self.window = window
        self.rank = rank
        self.suit = suit
        self.value = value

        # create an image object
        self.cardImage = pygwidgets.Image(window, (100, 200),
                                          'images/BackOfCard.png')
コード例 #18
0
    def __init__(self, window):
        self.window = window
        self.oBlueGem = pygwidgets.Image(self.window, (0, 0),
                                         'images/gem-blue.png')
        self.oOrangeGem = pygwidgets.Image(self.window, (0, 0),
                                           'images/gem-green.png')
        self.oGreenGem = pygwidgets.Image(self.window, (0, 0),
                                          'images/gem-orange.png')
        self.oStar = pygwidgets.Image(self.window, (0, 0),
                                      'images/gem-black.png')
        self.oHeart = pygwidgets.Image(self.window, (0, 0), 'images/Heart.png')


        self.grid = [[NOTHING, NOTHING, NOTHING, NOTHING, NOTHING],\
                     [NOTHING, NOTHING, NOTHING, NOTHING, NOTHING], \
                     [NOTHING, NOTHING, NOTHING, NOTHING, NOTHING], \
                     [NOTHING, NOTHING, NOTHING, NOTHING, NOTHING], \
                     [NOTHING, NOTHING, NOTHING, NOTHING, NOTHING], \
                     [NOTHING, NOTHING, NOTHING, NOTHING, NOTHING]]
        self.newRound(1)
コード例 #19
0
def showCustomAlertDialog(theWindow, theText):
    oDialogBackground = pygwidgets.Image(theWindow, (60, 120), 'images/dialog.png')
    oPromptDisplayText = pygwidgets.DisplayText(theWindow, (0, 170), theText, \
                                width=WINDOW_WIDTH, justified='center', fontSize=36)
    oOKButton = pygwidgets.CustomButton(theWindow, (355, 265), \
                                        'images/okNormal.png',\
                                        over='images/okOver.png',\
                                        down='images/okDown.png',\
                                        disabled='images/okDisabled.png')
    userAnswer = pyghelpers.customYesNoDialog(theWindow, oDialogBackground, \
                                    oPromptDisplayText, oOKButton, None)
    return userAnswer
コード例 #20
0
ファイル: Baddies.py プロジェクト: IrvKalb/pyghelpers
    def __init__(self, window):
        self.window = window
        # Create the image object
        size = random.randrange(Baddie.MIN_SIZE, Baddie.MAX_SIZE + 1)
        self.x = random.randrange(0, WINDOW_WIDTH - size)
        self.y = 0 - size  # start above the window
        self.image = pygwidgets.Image(self.window, (self.x, self.y),
                                      Baddie.BADDIE_IMAGE)

        # Scale it
        percent = (size * 100) / Baddie.MAX_SIZE
        self.image.scale(percent, False)
        self.speed = random.randrange(Baddie.MIN_SPEED, Baddie.MAX_SPEED + 1)
コード例 #21
0
    def __init__(self, window, maxWidth, maxHeight, beginTime, maxSeconds):
        myX = random.randrange(0, maxWidth - TARGET_WIDTH_HEIGHT)
        myY = random.randrange(0, maxHeight - TARGET_WIDTH_HEIGHT)

        self.image = pygwidgets.Image(window, (myX, myY), "images/target.png")

        self.startTime = beginTime + random.randrange(maxSeconds - TOTAL_SHOW_TIME) + \
                         (random.randrange(0, 100) / 100.)  # add some fractional time
        self.endTime = self.startTime + TOTAL_SHOW_TIME  # Add 3 seconds
        self.state = HIDDEN
        self.showingState = NOT_SHOWN
        self.image.hide()
        self.percent = 0
        self.image.scale(self.percent)
コード例 #22
0
    def __init__(self, window):
        # Save window  in instance variable
        self.window = window

        return  # temporary, until I build out the high scores scene

        self.backgroundImage = pygwidgets.Image(
            self.window, (0, 0), "images/highScoresBackground.jpg")

        # The following will create a list of lists
        # Either by building a blank one from scratch, or by reading from a text file
        # The result will look like:
        # [[name, score], [name, score], [name, score] ...]
        # and will always be kept in order of the score (highest to lowest)
        if not pyghelpers.fileExists(SceneHighScores.DATA_FILE_PATH):
            self.setEmptyHighScores()
        else:
            data = pyghelpers.readFile(SceneHighScores.DATA_FILE_PATH)
            # read in all the data in json format, converts to a list of lists
            self.scoresList = json.loads(data)

        self.scoresField = pygwidgets.DisplayText(self.window, (25, 84), '', \
                                fontSize=48, textColor=BLACK, width=175, justified='right')
        self.namesField = pygwidgets.DisplayText(self.window, (260, 84), '', \
                                fontSize=48, textColor=BLACK, width=300, justified='left')

        self.quitButton = pygwidgets.CustomButton(self.window, (30, 650), \
                                                   up='images/quitNormal.png',\
                                                   down='images/quitDown.png',\
                                                   over='images/quitOver.png',\
                                                   disabled='images/quitDisabled.png')

        #self.resetScoresButton = pygwidgets.TextButton(self.window, (240, 650), 'Reset high scores')

        self.resetScoresButton = pygwidgets.CustomButton(self.window, (240, 650), \
                                                   up='images/resetNormal.png',\
                                                   down='images/resetDown.png',\
                                                   over='images/resetOver.png',\
                                                   disabled='images/resetDisabled.png')
        #self.startNewGameButton = pygwidgets.TextButton(self.window, (450, 650), 'Start new game')
        self.startNewGameButton = pygwidgets.CustomButton(self.window, (450, 650), \
                                                   up='images/startNewNormal.png',\
                                                   down='images/startNewDown.png',\
                                                   over='images/startNewOver.png',\
                                                   disabled='images/startNewDisabled.png')

        self.showHighScores()
コード例 #23
0
ファイル: Fruit.py プロジェクト: hvaltchev/UCSC
    def __init__(self, window, windowWidth, windowHeight, fruitType):
        self.window = window  # remember the window, so we can draw later
        self.windowWidth = windowWidth
        self.windowHeight = windowHeight
        self.fruitType = fruitType
        self.image = pygwidgets.Image(window, (0, 0),
                                      'images/' + fruitType + '.png')
        self.points = 15
        # A rect is made up of [x, y, width, height]
        startingRect = self.image.getRect()
        self.width = startingRect[2]
        self.height = startingRect[3]

        # Choose a random speed in the y direction
        self.ySpeed = random.randrange(5, 9)
        self.maxX = self.windowWidth - self.width
        self.reset()
コード例 #24
0
def showCustomResetDialog(theWindow, theText):
    oDialogBackground = pygwidgets.Image(theWindow, (35, 450),
                                         'images/dialog.png')
    oPromptDisplayText = pygwidgets.DisplayText(theWindow, (0, 480), theText, \
                                width=WINDOW_WIDTH, justified='center', fontSize=36)
    oNoButton = pygwidgets.CustomButton(theWindow, (65, 595), \
                                        'images/cancelNormal.png',\
                                        over='images/cancelOver.png',\
                                        down='images/cancelDown.png',\
                                        disabled='images/cancelDisabled.png')
    oYesButton = pygwidgets.CustomButton(theWindow, (330, 595), \
                                        'images/okNormal.png',\
                                        over='images/okOver.png',\
                                        down='images/okDown.png',\
                                        disabled='images/okDisabled.png')
    choiceAsBoolean = pyghelpers.customYesNoDialog(theWindow, oDialogBackground, \
                                    oPromptDisplayText, oYesButton, oNoButton)
    return choiceAsBoolean
コード例 #25
0
def showCustomAnswerDialog(theWindow, theText):
    oDialogBackground = pygwidgets.Image(theWindow, (60, 120), 'images/dialog.png')
    oPromptDisplayText = pygwidgets.DisplayText(theWindow, (0, 170), theText, \
                                width=WINDOW_WIDTH, justified='center', fontSize=36)
    oUserInputText = pygwidgets.InputText(theWindow, (225, 220), '',
                                            fontSize=36, initialFocus=True)
    oNoButton = pygwidgets.CustomButton(theWindow, (105, 265), \
                                        'images/cancelNormal.png',\
                                        over='images/cancelOver.png',\
                                        down='images/cancelDown.png',\
                                        disabled='images/cancelDisabled.png')
    oYesButton = pygwidgets.CustomButton(theWindow, (375, 265), \
                                        'images/okNormal.png',\
                                        over='images/okOver.png',\
                                        down='images/okDown.png',\
                                        disabled='images/okDisabled.png')
    choiceAsBoolean, userAnswer = pyghelpers.customAnswerDialog(theWindow, oDialogBackground, \
                                    oPromptDisplayText, oUserInputText, oYesButton, oNoButton)
    return choiceAsBoolean, userAnswer
コード例 #26
0
ファイル: SceneHighScores.py プロジェクト: IrvKalb/pyghelpers
    def __init__(self, window):
        self.window = window
        self.oHighScoresData = HighScoresData()

        self.backgroundImage = pygwidgets.Image(
            self.window, (0, 0), 'images/highScoresBackground.jpg')

        self.namesField = pygwidgets.DisplayText(self.window, (260, 84),
                                                 '',
                                                 fontSize=48,
                                                 textColor=BLACK,
                                                 width=300,
                                                 justified='left')
        self.scoresField = pygwidgets.DisplayText(self.window, (25, 84),
                                                  '',
                                                  fontSize=48,
                                                  textColor=BLACK,
                                                  width=175,
                                                  justified='right')

        self.quitButton = pygwidgets.CustomButton(
            self.window, (30, 650),
            up='images/quitNormal.png',
            down='images/quitDown.png',
            over='images/quitOver.png',
            disabled='images/quitDisabled.png')

        self.backButton = pygwidgets.CustomButton(
            self.window, (240, 650),
            up='images/backNormal.png',
            down='images/backDown.png',
            over='images/backOver.png',
            disabled='images/backDisabled.png')

        self.resetScoresButton = pygwidgets.CustomButton(
            self.window, (450, 650),
            up='images/resetNormal.png',
            down='images/resetDown.png',
            over='images/resetOver.png',
            disabled='images/resetDisabled.png')

        self.showHighScores()
コード例 #27
0
    def __init__(self, window, sceneKey):
        # Save window and sceneKey in instance variables
        self.window = window
        self.sceneKey = sceneKey

        self.backgroundImage = pygwidgets.Image(self.window, (0, 0), BG_SPLASH)
        self.backButton = pygwidgets.TextButton(self.window, (WINDOW_WIDTH/2 - 50, SPLASH_WINDOW_HEIGHT/2 - 150), 'Back', \
                                                upColor=DUSTYPURPLE, downColor=DARKVIOLET, textColor=WHITE,fontName=FONT_NAME, enterToActivate=True)

        self.moveKeys = pygwidgets.DisplayText(self.window, (WINDOW_WIDTH/2 - 70, SPLASH_WINDOW_HEIGHT/2 - 50), 'Move: Arrow Keys', \
                                fontSize=16, fontName = FONT_NAME,textColor=CONTROL_FONT_COLOR, justified='left')

        self.jumpKeys = pygwidgets.DisplayText(self.window, (WINDOW_WIDTH/2 - 70, SPLASH_WINDOW_HEIGHT/2), 'Jump: Spacebar', \
                                fontSize=16, fontName = FONT_NAME,textColor=CONTROL_FONT_COLOR, justified='left')

        self.interactKeys = pygwidgets.DisplayText(self.window, (WINDOW_WIDTH/2 - 70, SPLASH_WINDOW_HEIGHT/2 + 50), 'Interact: Enter', \
                                fontSize=16, fontName = FONT_NAME,textColor=CONTROL_FONT_COLOR, justified='left')

        self.attackKeys = pygwidgets.DisplayText(self.window, (WINDOW_WIDTH/2 - 70, SPLASH_WINDOW_HEIGHT /2 + 100), 'Attack: Mouse Left', \
                                                 fontName=FONT_NAME,fontSize=16, textColor=CONTROL_FONT_COLOR, justified='left')
コード例 #28
0
ファイル: Goodies.py プロジェクト: IrvKalb/pyghelpers
    def __init__(self, window):
        self.window = window
        size = random.randrange(Goodie.MIN_SIZE, Goodie.MAX_SIZE + 1)
        self.y = random.randrange(0, GAME_HEIGHT - size)

        self.direction = random.choice([Goodie.LEFT, Goodie.RIGHT])
        if self.direction == Goodie.LEFT:  # start on right side of the window
            self.x = WINDOW_WIDTH
            self.speed = - random.randrange(Goodie.MIN_SPEED,
                                                            Goodie.MAX_SPEED + 1)
            self.minLeft = - size
        else:  # start on left side of the window
            self.x = 0 - size
            self.speed = random.randrange(Goodie.MIN_SPEED,
                                                          Goodie.MAX_SPEED + 1)

        self.image = pygwidgets.Image(self.window,
                                                     (self.x, self.y), Goodie.GOODIE_IMAGE)
        percent = int((size * 100) / Goodie.MAX_SIZE)
        self.image.scale(percent, False)
コード例 #29
0
                                        fontSize=28,
                                        width=70,
                                        justified='right')
oOutOfDisplay = pygwidgets.DisplayText(window, (390, 460),
                                       'out of',
                                       fontName='monospaces',
                                       fontSize=28)

oMaxRoundsInput = pygwidgets.InputText(window, (454, 460),
                                       str(nRoundsToRun),
                                       fontName='monospaces',
                                       fontSize=28,
                                       width=70,
                                       initialFocus=True)

oDiceImage = pygwidgets.Image(window, (28, 15), 'images/twoDice.png')
imagesDict = {
    1: 'images/dice1.png',
    2: 'images/dice2.png',
    3: 'images/dice3.png',
    4: 'images/dice4.png',
    5: 'images/dice5.png',
    6: 'images/dice6.png'
}
oDie1 = pygwidgets.ImageCollection(window, (630, 15), imagesDict, 1)
oDie2 = pygwidgets.ImageCollection(window, (715, 15), imagesDict, 1)

binsList = []
for diceTotalForBin in range(0, (SIDES_PER_DIE + SIDES_PER_DIE + 1)):
    oBin = Bin(window, diceTotalForBin, nRoundsToRun)
    binsList.append(oBin)
コード例 #30
0
ファイル: Car.py プロジェクト: hvaltchev/UCSC
 def __init__(self, window, loc):
     self.image = pygwidgets.Image(window, loc, 'images/car.png')
     self.rect = self.image.getRect()
     self.animate = False
     self.size = 100