源码及注释:
import pygame
from sys import exit
from random import randint
import time
import os
# 定义窗口分辨率
SCREEN_WIDTH = 700
SCREEN_HEIGHT = 600
current_path = os.path.abspath(os.path.dirname(__file__))
root_path = current_path[:current_path.find("monkey-picking-peach\\") + len("monkey-picking-peach\\")] \
+ "resource\\images\\"
# 图片
BACKGROUND_IMAGE_PATH = root_path + "background.jpg"
MONKEY_IMAGE_PATH = root_path + "monkey.png"
APPLE_IMAGE_PATH = root_path + "apple.png"
JUMP_STATUS = False
OVER_FLAG = False
START_TIME = None
offset = {pygame.K_LEFT: 0, pygame.K_RIGHT: 0, pygame.K_UP: 0, pygame.K_DOWN: 0}
# 定义画面帧率
FRAME_RATE = 60
# 定义动画周期(帧