當前位置:首頁 » 操作系統 » 自動切片源碼

自動切片源碼

發布時間: 2023-08-07 00:28:21

1. 如何製作淘寶源代碼

源代碼,是指html代碼,如果你不懂得話一般是沒法編輯的。

公告欄,你在店鋪管理中直接編輯就可以了,不會源代碼的話就用那個直接編輯的模式,跟一般論壇的發帖子差不多的格式。

如果是商品裝修的話,簡單點就是貼幾張圖美化一下寶貝就可以。建議你喊仔旅看看巴巴變,他家有免費寶貝描述模板,不用自己費心了,直接用就可以首先用ps軟體設計好界面。然後切割導出web格式。在用dw(製作網站的軟體)來排版、

排版時注意把那些切片上傳到qq空間、圖片要戚掘用網路鄭凳鏈接不能用本地的路徑。

都完成之後你就可以放到自定義模塊去了。

2. 用PS切片工具做好的網鏈圖片怎麼上傳到淘寶

1、首先,在Potoshop中打開一張製作好的網頁,如圖。

3. python小游戲2048,上班摸魚必備(附源碼

話不多說,直接上菜

為了方便大家,我就不分段解釋了

import turtle, random

# 定義一個類,用來畫除了數字方塊之外的圖形

class BackGround(turtle.Turtle):

    def __init__(self):

        super().__init__()

        self.penup()

        self.ht()

    def draw_block(self):

        self.shape('bg.gif')  # 畫出背景方塊

        for i in allpos:

            self.goto(i)

            self.stamp()

        self.color('white', 'white')  # 畫出其他背景

        self.goto(-215, 120)

        self.begin_fill()

        self.goto(215, 120)

        self.goto(215, 110)

        self.goto(-215, 110)

        self.end_fill()

        self.shape('title.gif')

        self.goto(-125, 210)

        self.stamp()

        self.shape('score.gif')

        self.goto(125, 245)

        self.stamp()

        self.shape('top_score.gif')

        self.goto(125, 170)

        self.stamp()

    # 游戲失敗及達成2048的提示文字

    def judge(self):

        global flag_win, flag_win_lose_text

        self.color('blue')

        judge = 0  # 判斷是否還有位置可以移動

        for i in block_dic.values():

            for j in block_dic.values():

                if i.num == 0 or i.num == j.num and i.distance(j) == 100:

                    judge += 1

        if judge == 0:  # 無位置可移動,游戲失敗

            self.write('    GAME OVER\n重新開始請按空格鍵', align='center', font=('黑體', 30, 'bold'))

            flag_win_lose_text = False

        if flag_win is True:  # 此條件讓2048達成的判斷只能進行一次

            for k in block_dic.values():

                if k.num == 2048:  # 游戲達成

                    flag_win = False

                    self.write('    達成2048\n繼續游戲請按回車鍵', align='center', font=('黑體', 30, 'bold'))

                    flag_win_lose_text = False

    def win_lose_clear(self):

        global flag_win_lose_text

        self.clear()

        flag_win_lose_text = True

    def show_score(self):  # 分值的顯示

        global score, top_score

        if score > top_score:

            top_score = score

            with open('.\\score.txt', 'w') as f:

                f.write(f'{top_score}')

        self.color('white')

        self.goto(125, 210)

        self.clear()

        self.write(f'{score}', align='center', font=('Arial', 20, 'bold'))

        self.goto(125, 135)

        self.write(f'{top_score}', align='center', font=('Arial', 20, 'bold'))

# 數字方塊類

class Block(turtle.Turtle):

    def __init__(self):

        super().__init__()

        self.ht()

        self.penup()

        self.num = 0

    def draw(self):

        self.clear()

        dic_draw = {2: '#eee6db', 4: '#efe0cd', 8: '#f5af7b',

                    16: '#fb9660', 32: '#f57d5a', 64: '#f95c3d',

                    128: '#eccc75', 256: '#eece61', 512: '#efc853',

                    1024: '#ebc53c', 2048: '#eec430', 4096: '#aeb879',

                    8192: '#aab767', 16384: '#a6b74f'}

        if self.num > 0:  # 數字大於0,畫出方塊

            self.color(f'{dic_draw[self.num]}')  # 選擇顏色

            self.begin_fill()

            self.goto(self.xcor()+48, self.ycor()+48)

            self.goto(self.xcor()-96, self.ycor())

            self.goto(self.xcor(), self.ycor()-96)

            self.goto(self.xcor()+96, self.ycor())

            self.goto(self.xcor(), self.ycor()+96)

            self.end_fill()

            self.goto(self.xcor()-48, self.ycor()-68)

            if self.num > 4:  # 按照數字選擇數字的顏色

                self.color('white')

            else:

                self.color('#6d6058')

            self.write(f'{self.num}', align='center', font=('Arial', 27, 'bold'))

            self.goto(self.xcor(), self.ycor()+20)

class Game():

    def init(self):

        back = BackGround()  # 實例畫出遊戲的背景

        back.draw_block()

        for i in allpos:  # 畫出16個海龜對應16個數字塊

            block = Block()

            block.goto(i)

            block_dic[i] = block

        game.grow()

    def restart(self):  # 重開游戲的方法

        global score, flag_win_lose_text

        score = 0

        for i in block_dic.values():

            i.num = 0

            i.clear()

        win_lose_text.clear()

        game.grow()

        flag_win_lose_text = True  # 此flag為游戲達成或失敗出現提示語後的判斷,要提示語被clear後才能繼續move

    def grow(self):  # 隨機出現一個2或4的數字塊

        block_list = []

        for i in allpos:

            if block_dic[i].num == 0:

                block_list.append(block_dic[i])  # 挑出空白方塊的海龜

        turtle_choice = random.choice(block_list)  # 隨機選中其中一個海龜

        turtle_choice.num = random.choice([2, 2, 2, 2, 4])  # 賦屬性num=2/4

        turtle_choice.draw()

        win_lose_text.judge()

        show_score_text.show_score()

        ms.update()

    def move_up(self):

        allpos1 = allpos[::4]  # 切片為四列

        allpos2 = allpos[1::4]

        allpos3 = allpos[2::4]

        allpos4 = allpos[3::4]

        self.move_move(allpos1, allpos2, allpos3, allpos4)

    def move_down(self):

        allpos1 = allpos[-4::-4]

        allpos2 = allpos[-3::-4]

        allpos3 = allpos[-2::-4]

        allpos4 = allpos[-1::-4]

        self.move_move(allpos1, allpos2, allpos3, allpos4)

    def move_left(self):

        allpos1 = allpos[:4]

        allpos2 = allpos[4:8]

        allpos3 = allpos[8:12]

        allpos4 = allpos[12:16]

        self.move_move(allpos1, allpos2, allpos3, allpos4)

    def move_right(self):

        allpos1 = allpos[-1:-5:-1]

        allpos2 = allpos[-5:-9:-1]

        allpos3 = allpos[-9:-13:-1]

        allpos4 = allpos[-13:-17:-1]

        self.move_move(allpos1, allpos2, allpos3, allpos4)

    def move_move(self, allpos1, allpos2, allpos3, allpos4):

        if flag_win_lose_text is True:

            count1 = self.move(allpos1)  # 四列或四行依次移動

            count2 = self.move(allpos2)

            count3 = self.move(allpos3)

            count4 = self.move(allpos4)

            if count1 or count2 or count3 or count4:  # 判斷是否有方塊移動,有才能繼續出現新的數字塊

                self.grow()

    def move(self, pos_list):

        num_list = []  # 為某一列或行的數字塊海龜的坐標

        for i in pos_list:

            num_list.append(block_dic[i].num)  #  把這些海龜的NUM形成list

        new_num_list, count = self.list_oper(num_list)  #  只是list_oper的方法形成新的list

        for j in range(len(new_num_list)):  # 把新的list依次賦值給對應的海龜.num屬性並調用draw()方法

            block_dic[pos_list[j]].num = new_num_list[j]

            block_dic[pos_list[j]].draw()

        return count

    def list_oper(self, num_list):  # num_list的操作,假設其為【2,0,2,2】

        global score

        count = True

        temp = []

        new_temp = []

        for j in num_list:

            if j != 0:

                temp.append(j)  # temp=[2,2,2]

        flag = True

        for k in range(len(temp)):

            if flag:

                if k < len(temp)-1 and temp[k] == temp[k+1]:

                    new_temp.append(temp[k]*2)

                    flag = False

                    score += temp[k]

                else:

                    new_temp.append(temp[k])  # new_temp=[4,2]

            else:

                flag = True

        for m in range(len(num_list)-len(new_temp)):

            new_temp.append(0)  # new_temp=[4,2,0,0]

        if new_temp == num_list:

            count = False  # 此變數判斷num_list沒有變化,數字塊無移動

        return(new_temp, count)

if __name__ == '__main__':

    ms = turtle.Screen()  # 主窗口的設置

    ms.setup(430, 630, 400, 50)

    ms.bgcolor('gray')

    ms.title('2048')

    ms.tracer(0)

    ms.register_shape('bg.gif')

    ms.register_shape('title.gif')

    ms.register_shape('score.gif')

    ms.register_shape('top_score.gif')

    block_dic = {}  # 放數字方塊海龜的字典,位置坐標為key,對應海龜為value

    allpos = [(-150, 50), (-50, 50), (50, 50), (150, 50),

              (-150, -50), (-50, -50), (50, -50), (150, -50),

              (-150, -150), (-50, -150), (50, -150), (150, -150),

              (-150, -250), (-50, -250), (50, -250), (150, -250)]

    flag_win = True  # 達成2048的判斷,讓達成的文字僅出現一次

    flag_win_lose_text = True  # 用來判斷失敗或成功的提示文字是否有被清除,不清除不能繼續移動方塊

    score = 0

    with open('.\\score.txt', 'r') as f:

        top_score = int(f.read())  #  讀取score中的數據

    show_score_text = BackGround()

    win_lose_text = BackGround()

    game = Game()

    game.init()

    ms.listen()

    ms.onkey(game.move_up, 'Up')

    ms.onkey(game.move_down, 'Down')

    ms.onkey(game.move_left, 'Left')

    ms.onkey(game.move_right, 'Right')

    ms.onkey(win_lose_text.win_lose_clear, 'Return')

    ms.onkey(game.restart, 'space')

    ms.mainloop()

這是游戲界面:

歡迎挑戰最高分。

要運行出來,必須本地要有這些文件:bg.gif,score.gif,title.gif,top_score.gif,score.txt

我把這些文件放在了群里,還有一些學習的資料,群號642109462,歡迎對python感興趣的進群討論。

支持作者的,可以關注和點贊。感謝你們!

熱點內容
愛加密漏洞 發布:2025-03-12 20:09:43 瀏覽:868
高斯速演算法 發布:2025-03-12 20:09:33 瀏覽:30
sqlserver2008安裝程序 發布:2025-03-12 20:07:18 瀏覽:51
鋼鐵俠3兄弟們快速緩存 發布:2025-03-12 20:07:12 瀏覽:767
qq啟動腳本 發布:2025-03-12 19:59:00 瀏覽:893
電腦配置有ssd是什麼意思 發布:2025-03-12 19:57:50 瀏覽:730
米思齊編譯失敗怎麼看 發布:2025-03-12 19:26:27 瀏覽:848
sql語句notexists 發布:2025-03-12 19:16:11 瀏覽:60
快手安卓版如何玩 發布:2025-03-12 19:15:26 瀏覽:36
scott資料庫 發布:2025-03-12 19:15:19 瀏覽:873