You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
#-*- coding:utf-8 -*-
|
|
|
|
|
|
|
|
|
|
import pygame, sys
|
|
|
|
|
from pygame.locals import *
|
|
|
|
|
from map_show import *
|
|
|
|
|
from button_event import *
|
|
|
|
|
from ai2048 import *
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def run():
|
|
|
|
|
game_init()
|
|
|
|
|
start_base_game()
|
|
|
|
|
while True:
|
|
|
|
|
#固定代码段,实现点击"X"号退出界面的功能,几乎所有的pygame都会使用该段代码
|
|
|
|
|
game_drawing()
|
|
|
|
|
if ai2048.game_state == 0:
|
|
|
|
|
base_game_going()
|
|
|
|
|
elif ai2048.game_state == 1:
|
|
|
|
|
ai_2048_game_going(map_game.ai_delay_time)
|
|
|
|
|
#ai_2048_game_going(1)
|
|
|
|
|
elif ai2048.game_state == 2:
|
|
|
|
|
reshow_mode(map_game.ai_delay_time)#用和AI相同的速度进行回放
|
|
|
|
|
#事件判断
|
|
|
|
|
for event in pygame.event.get():
|
|
|
|
|
if event.type == QUIT:
|
|
|
|
|
pygame.quit()
|
|
|
|
|
sys.exit()
|
|
|
|
|
#绘制屏幕内容
|
|
|
|
|
pygame.display.update()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
run() # 开始游戏
|