# coding:utf-8 import pygame, sys, random, time, easygui from pygame.locals import * # 初始化pygame环境 pygame.init() # 创建窗口 canvas = pygame.display.set_mode((1000, 600)) # 加载图片 bg = pygame.image.load("imgs/bg.jpg") win = pygame.image.load("imgs/win.png") # 设置标题 pygame.display.set_caption("连连看") # 图片位置数组 p = [[60, 120], [170, 120], [280, 120], [390, 120], [500, 120], [610, 120], [720, 120], [830, 120], [60, 230], [170, 230], [280, 230], [390, 230], [500, 230], [610, 230], [720, 230], [830, 230], [60, 340], [170, 340], [280, 340], [390, 340], [500, 340], [610, 340], [720, 340], [830, 340], [60, 450], [170, 450], [280, 450], [390, 450], [500, 450], [610, 450], [720, 450], [830, 450]] # 定义变量存储点击的卡片信息 first_num = 0 first_x = 0 first_y = 0 # 创建handleEvent方法 def handleEvent(): # 全局变量 global first_num, first_x, first_y for event in pygame.event.get(): if event.type == pygame.QUIT or event.type == KEYDOWN and event.key == K_ESCAPE: sys.exit()
Python实现连连看
最新推荐文章于 2025-06-16 12:52:51 发布