Python pygame 模块,K_EQUALS 实例源码

我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用pygame.K_EQUALS

项目:Heap-Project-1    作者:stacompsoc    | 项目源码 | 文件源码
def keyboard(self, key):
        """
        Handle keyboard events.

        :key: key pressed
        """
        global SCALE_FACTOR, MIN_MASS
        if key == pygame.K_SPACE:
            self.pause = not self.pause
        elif key == pygame.K_UP:
            self.pos_shift[1] -= int(self.height / 10)
        elif key == pygame.K_DOWN:
            self.pos_shift[1] += int(self.height / 10)
        elif key == pygame.K_LEFT:
            self.pos_shift[0] -= int(self.width / 10)
        elif key == pygame.K_RIGHT:
            self.pos_shift[0] += int(self.width / 10)
        elif key == pygame.K_EQUALS:
            SCALE_FACTOR /= 1.05
        elif key == pygame.K_MINUS:
            SCALE_FACTOR *= 1.05
        MIN_MASS = SCALE_FACTOR ** 3
项目:pygame-event-calendar-and-pianobar    作者:scottpcrawford    | 项目源码 | 文件源码
def __init__(self, screen):
        self.done = False
        self.screen = screen
        self.clock = pg.time.Clock()
        self.fps = 60
        self.RADIO_STATION = '39' # or 1591330390268116913
        self.BACKGROUND_IMG = 'img/bg/day_tree.png'
        self.SCREEN_WIDTH = SCREEN_WIDTH
        self.SCREEN_HEIGHT = SCREEN_HEIGHT
        self.RADIO_RUNNING = False
        self.RESTING = False
        self.SHOWGOALS = False
        self.grass = 'img/bg/day_grass.png'
        self.day_clouds = pg.sprite.RenderUpdates()
        self.night_clouds = pg.sprite.RenderUpdates()
        self.all_sprites_list = pg.sprite.RenderUpdates()
        self.quote_list = return_list('quotes.txt')
        self.contributions = return_list('contributions.txt')
        self.goals = return_list('goals.txt')
        self.weather = Weather()
        self.weather_observation = {}
        self.phrase = random.choice(self.quote_list)
        #self.cwd = os.getcwd() #windows
        self.cwd = '/home/pi/.config/pianobar' # linux
        ## DAIYE COLORS ###
        self.HEADER_COLOR = pg.Color('black')
        self.CONTENT_COLOR = pg.Color('indianred4')
        self.BG_COLOR = pg.Color('skyblue')
        self.current_events = []
        self.upcoming_events = []

        # User events:
        self.UPDATECALENDAR = pg.USEREVENT + 1
        self.UPDATEQUOTE = pg.USEREVENT + 2
        self.NIGHTRADIO = pg.USEREVENT + 3
        self.CHANGESTATE = pg.USEREVENT + 4
        self.UPDATEWEATHER = pg.USEREVENT + 5
        #self.SHOWGOALS = pg.USEREVENT + 6
        pg.time.set_timer(self.UPDATECALENDAR, 60000) #update calendar every 60 seconds     
        pg.time.set_timer(self.UPDATEQUOTE, 20000) #update quote every 20 seconds
        pg.time.set_timer(self.NIGHTRADIO,300000) # check for relaxation radio time
        pg.time.set_timer(self.UPDATEWEATHER, 600000)
        pg.time.set_timer(self.CHANGESTATE, 300000)
        #pg.time.set_timer(self.SHOWGOALS, 6000)

        self.DAYGFX = load_gfx(os.path.join("img", "clouds", "day"))
        self.NTGFX = load_gfx(os.path.join("img", "clouds", "night"))
        self.BGIMG  = load_gfx(os.path.join('img', 'bg'))
        self.keymap_dict = {pg.K_n: 'n', pg.K_PLUS: '+', pg.K_KP_PLUS: '+', pg.K_EQUALS: '+', pg.K_MINUS: '-', pg.K_KP_MINUS: '-', 
                            pg.K_p: 'p', pg.K_SPACE: 'p', pg.K_q: 'q', pg.K_r: 'r', pg.K_s: 's', pg.K_1: 's6\n', pg.K_2: 's4\n', 
                            pg.K_3: 's15\n', pg.K_4: 's25\n', pg.K_5: 's48\n', pg.K_6: 's37\n', pg.K_7: 's52\n', pg.K_8: 's16\n'}