当前位置: 首页 > news >正文

网站制作要多少钱seo基本概念

网站制作要多少钱,seo基本概念,网络营销工具和方法,网页设计基础读书笔记10. 拼图游戏继续升级——多关卡拼图 初始化列表Photos用来储存拼图文件名,Photo_ID用来统计当下是第几张拼图,Squares储存当下拼图的24张小拼图的文件名,Gird储存当下窗口上显示的24个小拼图及坐标。 Photos["girl_","boy_…

10. 拼图游戏继续升级——多关卡拼图

  • 初始化列表Photos用来储存拼图文件名,Photo_ID用来统计当下是第几张拼图,Squares储存当下拼图的24张小拼图的文件名,Gird储存当下窗口上显示的24个小拼图及坐标。
Photos=["girl_","boy_","cat_"]
Photo_ID=0
Squares=[]
Gird=[]
  • 建立change_Photo()函数通过Photo_ID来初始化新一轮的拼图
def change_Photo():global Photo_IDSquares.clear()Gird.clear()for i in range(1,25):# 初始化最新图片的文件名if i<10:s=Photos[Photo_ID]+'0'+str(i)else:s=Photos[Photo_ID]+str(i)Squares.append(Actor(s))# 略 Squares、Gird的初始化
  • 设定图片切换方法:上一张拼图胜利后按下空格键切换下一张拼图,再次将Is_Win设定为False
  • 修改游戏胜利条件:Photo_ID等于Photos的长度且Is_Win为True时才能迎来最终的胜利
def on_key_down(key):global Photo_ID,Is_Win,Win_musicif key == keys.SPACE:Photo_ID += 1if Photo_ID < len(Photos):Is_Win = FalseWin_music = 0change_Photo()
  • 修改时间的更新条件
def update():global newTime,startTime,Photo_IDif (not Is_Win) or (Photo_ID!=len(Photos)):endTime = datetime.datetime.now()newTime=(endTime-startTime).seconds
  • 再窗口上增加当下是第几张拼图的提示
def draw():# 略screen.draw.text("第" + str(Photo_ID+1)+"张图", (WIDTH-100, 10),\fontsize=20, fontname='s', color="blue")
  • 当最后一张拼图完成增加提示
def draw():# 略if Is_Win:# 略if Photo_ID == len(Photos) :screen.draw.text("已是最后一张图了!", (WIDTH / 2 - 170, HEIGHT / 2 + 50), \fontsize=50, fontname='s', color="blue")

执行效果如下图所示:

完整代码如下:

import pgzrun
import random
import time
import datetimetry:txtFile=open("rank.txt",'r')score=txtFile.readline()
except:txtFile=open("rank.txt",'w')score = "您是第一个玩家"txtFile.write(score)
txtFile.close()startTime=datetime.datetime.now()
oldTime=int(score) if score.isdigit() else 9999
newTime=0TITLE="pgzrun 拼图游戏"
Square_size=125
WIDTH=Square_size*4
HEIGHT=Square_size*6click_time=0
clickID_1=clickID_2=-1
Is_Win=False
Win_music=0sounds.bg_music.play(-1)Photos=["girl_","boy_","cat_"]
Photo_ID=0
Squares=[]
Gird=[]def swap_Square(i,j):  # 两个拼图的位置互换sounds.chick.play()temp_pos=Gird[i].posGird[i].pos=Gird[j].posGird[j].pos=temp_posdef change_Photo():global Photo_IDSquares.clear()Gird.clear()for i in range(1,25):if i<10:s=Photos[Photo_ID]+'0'+str(i)else:s=Photos[Photo_ID]+str(i)Squares.append(Actor(s))for i in range(6):for j in range(4):Square=Squares[i*4+j]Square.left=Square_size*jSquare.top=Square_size*iGird.append(Square)for k in range(10):  # 随机抽取10组拼图 进行位置互换i = random.randint(0, 23)j = random.randint(0, 23)swap_Square(i, j)change_Photo()def on_mouse_down(pos,button): # 当鼠标被点击时global click_time ,clickID_1 , clickID_2,Is_Win,Win_musicfor i in range(24):if Gird[i].collidepoint(pos): # 拼图对象被点击breakif click_time%2==0 :clickID_1=ielse:clickID_2=iswap_Square(clickID_1,clickID_2)click_time += 1# 成功判断is_win = Truefor i in range(6):for j in range(4):Square = Squares[i * 4 + j]if not (Square.left == Square_size * j and Square.top == Square_size * i) :is_win = Falsebreakif is_win:if Win_music==0:sounds.win_music.play()Win_music=1Is_Win=Trueif newTime<oldTime:txtFile=open("rank.txt",'w')txtFile.write(str(newTime))txtFile.close()def draw():screen.clear()for Square in Gird:Square.draw()screen.draw.text("游戏最佳记录: "+str(oldTime), (10, 10), fontsize=20, fontname='s', color="blue")screen.draw.text("第" + str(Photo_ID+1)+"张图", (WIDTH-100, 10), fontsize=20, fontname='s', color="blue")screen.draw.text("游戏运行时间: " + str(newTime), (10, 30), fontsize=20, fontname='s', color="blue")if Is_Win:screen.draw.text("游戏胜利!",(WIDTH/2-100,HEIGHT/2-50),fontsize=50,fontname='s',color="blue")if Photo_ID == len(Photos) :screen.draw.text("已是最后一张图了!", (WIDTH / 2 - 170, HEIGHT / 2 + 50), fontsize=50, fontname='s', color="blue")else :for i in range(5):screen.draw.line((i*Square_size,0),(i*Square_size,HEIGHT),"black")for i in range(7):screen.draw.line((0,i*Square_size),(WIDTH,i*Square_size),"black")if clickID_1!=-1:screen.draw.rect(Rect((Gird[clickID_1].left,Gird[clickID_1].top),(Square_size,Square_size)),"red")def update():global newTime,startTime,Photo_IDif (not Is_Win) or (Photo_ID!=len(Photos)):endTime = datetime.datetime.now()newTime=(endTime-startTime).secondsdef on_key_down(key):global Photo_ID,Is_Win,Win_musicif key == keys.SPACE:Photo_ID += 1if Photo_ID < len(Photos):Is_Win = FalseWin_music = 0change_Photo()pgzrun.go()

pgzrun拼图游戏素材包下载

http://www.laogonggong.com/news/86124.html

相关文章:

  • 厦门网站做的比较好python自学视频教程
  • 猎头建设网站旅游类网站建设教案
  • 网站后台如何管理手机访问网站 自动缩放
  • 做网页专题 应该关注哪些网站网站可以增加关键词吗
  • 普洱专业企业网站建设wordpress主题免费
  • 专业的扬州网站建设wordpress 高级选项
  • 在天极网做网站有效果吗工程公司注册需要什么
  • 做彩票网站网址抖音的商业营销手段
  • 开发网站私活西地那非副作用太强了
  • 做茶歇的网站建网站建网站
  • 西安网吧hyein seo
  • 盐城网站建设兼职公司注册网上查询
  • 雄安优秀网站建设哪家好wordpress伪静态 加速
  • 辽宁省建设工程造价管理协会网站怎么查看网站访问速度
  • 可以做ppt的网站有哪些方面wordpress项目管理插件
  • python合适做网站吗母婴 网站 策划
  • 科技部网站公布首批创新型县(市)建设名单如何制作ppt视频教程
  • 个人网站设计过程做网站有哪些项目
  • 玻璃钢产品哪个网站做推广好wordpress文章id排序
  • 做erp系统的网站seon是什么意思
  • 红色大气企业网站邢台网站建设58
  • 海外网站建设直通车怎么开
  • 营销型手机网站网页设计制作个人简历代码
  • 网站建设杭州最便宜wordpress 苏醒 cosy
  • 印刷网络商城网站建设建设网站个人简介范文
  • 快速建企业网站wordpress安装在linux
  • 网站开发营业执照申请校园网络平台建设方案
  • 宁波网站建设公司哪家口碑好oa软件公司排名
  • 架设网站开发环境网站维护的工作内容步骤
  • 云南网站建设百度官方什么是网站html静态化