91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 19KB
    文件類型: .py
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2021-05-23
  • 語言: Python
  • 標(biāo)簽: python??2048??

資源簡(jiǎn)介

python3.5.2版本的2048小游戲,基于wxpython開發(fā)的GUI,解壓后有.exe執(zhí)行文件可以打開直接開始游戲,具體源代碼請(qǐng)進(jìn)我的主頁查找~

資源截圖

代碼片段和文件信息

#?-*-?coding:utf-8?-*-
import?wx
import?random
import?copy
import?math


class?Myframe(wx.frame):
????def?__init__(selfparent?id?title):#初始化,隨機(jī)產(chǎn)生兩個(gè)2
????????global?image
????????image=[i?for?i?in?range(16)]
????????tmp?=?wx.Image(“2048/0.png“wx.BITMAP_TYPE_PNG)
????????image[0]?=?tmp.ConvertToBitmap()
????????for?i?in?range(116):
????????????tmp?=?wx.Image(“2048/%s.png“%(2**i)wx.BITMAP_TYPE_PNG)
????????????image[i]=tmp.ConvertToBitmap()
????????global?scoremtr_stkscr_stkmaxfs
????????self.maxfs=2048
????????wx.frame.__init__(self?parentid?title??size=(8701030))
????????tmp?=?wx.Image(“2048/background.png“wx.BITMAP_TYPE_PNG)
????????bjtp=tmp.ConvertToBitmap()
????????self.bj=wx.StaticBitmap(parent=self?bitmap=bjtppos=(00)size=(8701030))
????????#self.panel=wx.Panel(selfpos=(00)size=(500700))
????????#a=wx.StaticText(parent=self.bjlabel=‘分?jǐn)?shù):‘pos=(610300))
????????self.fenshu=wx.StaticText(parent=self.bjlabel=‘0‘pos=(670257)style=wx.ALIGN_CENTRE)
????????self.fenshu.SetFont(?wx.Font(?20?70?90?90?False?“張海山草泥馬體“?)?)
????????self.okbtn=wx.Button(parent=self.bjlabel=‘開始‘pos=(95760))
????????self.okbtn.SetFont(?wx.Font(?12?70?90?90?False?“張海山草泥馬體“?)?)
????????self.okbtn.Bind(wx.EVT_BUTTONself.kaishi)
????????self.okbtn.Bind(wx.EVT_KEY_DOWNself.move)
????????self.fhbtn=wx.Button(parent=self.bjlabel=‘返回‘pos=(275760))
????????self.fhbtn.SetFont(?wx.Font(?12?70?90?90?False?“張海山草泥馬體“?)?)
????????self.fhbtn.Bind(wx.EVT_BUTTONself.fanhui)
????????self.fhbtn.Bind(wx.EVT_KEY_DOWNself.move)
????????self.bj.text?=?[[0?for?i?in?range(4)]?for?j?in?range(4)]#按鈕
????????self.bj.huaban?=?[[0?for?i?in?range(4)]?for?j?in?range(4)]#畫板
????????#self.guize=wx.Panel(parent=selfpos=(5000)size=(350700))
????????#tmp?=?wx.Image(“2048/rule.png“wx.BITMAP_TYPE_PNG)
????????#rule=tmp.ConvertToBitmap()
????????#wx.StaticBitmap(parent=self.guize?bitmap=rulepos=(00))
????????for?i?in?range(4):
????????????for?j?in?range(4):
????????????????self.bj.text[i][j]=wx.Button(parent=self.bjlabel=‘0‘pos=(111*i+25111*j+300)size=(109109))
????????????????self.bj.huaban[i][j]=wx.StaticBitmap(parent=self.bj.text[i][j]?bitmap=image[0])
????????????????self.bj.text[i][j].Bind(wx.EVT_KEY_DOWNself.move)
????????score=0
????????mtr_stk?=?[]??#?for?back
????????scr_stk?=?[]
????????scr_stk.append(0)
????????amp=[[0?for?i?in?range(4)]?for?j?in?range(4)]
????????ran_pos?=?random.sample(range(16)?2)

????????#a=wx.StaticBitmap(parent=self.panel.text[int(ran_pos[0]/4)][int(ran_pos[0]%4)]?bitmap=image[1])#加‘2’圖片
????????self.bj.huaban[int(ran_pos[0]/4)][int(ran_pos[0]%4)].SetBitmap(image[1])
????????#wx.StaticBitmap(parent=self.panel.text[int(ran_pos[1]/4)][int(ran_pos[1]%4)]?bitmap=image[1])#加‘2’圖片
????????self.bj.huaban[int(ran_pos[1]/4)][int(ran_pos[1]%4)].SetBitmap(image[1])
????????self.bj.text[int(ran_pos[0]/4)][int(ran_pos[0]%4)]?.SetLabel(‘2‘)
????????self.bj.text[int(ra

評(píng)論

共有 條評(píng)論