{"id":345229,"student_id":10,"content":"import random #載入產生隨機數的套件\nfrom game import (\n set_backdrop, #設定背景\n create_sprite, #創造角色\n create_sound, #創造音效\n draw_text, #繪製文字\n key, #鍵盤狀態\n forever, #重複不斷執行\n stop, #遊戲結束\n)\n\nset_backdrop('bg_grid.jpg') #設定背景圖\nfood = create_sprite('apple.png', 'orange.png') #食物\nhead = create_sprite('head.png') #蛇頭\nhint = create_sprite('hint.png') #遊戲開始示意圖\ngameover = create_sprite('gameover.png') #遊戲結束示意圖\n\n# 設定蛇頭、食物、遊戲結束示意圖的圖層順序\nfood.layer = 1\nhead.layer = 2\ngameover.layer = 3\n\ngameover.hidden = True #預設隱藏遊戲結束示意圖\nhint.hidden = True #預設隱藏遊戲示意圖\n\nclock = 0 #紀錄遊戲迴圈次數\nnext_direction = 90 #蛇下次移動的方向\nbodies = [] # 用來存放蛇的身體\nis_start = False #是否開始遊戲\nlevel = 0 #分數等級用來計算移動速度\n\n# 遊戲主迴圈\ndef loop ():\n global clock, next_direction, is_start, level, bodies\n \n\nforever(loop) #不斷執行遊戲迴圈\n\n\n#更新蛇的造型\ndef update_bodies_costume():\n \n diff = next_direction - head.direction\n \n if diff == 0: #蛇向前移動\n bodies[0].costume_id = 0\n \n if diff == -90 or diff == 270: #蛇左轉移動\n bodies[0].costume_id = 1\n \n if diff == 90 or diff == -270: #蛇右轉移動\n bodies[0].costume_id = 2\n \n bodies[0].direction = next_direction #旋轉更新的身體\n \n bodies[-1].costume_id = 3 # 蛇身體最後的部分設為尾巴\n\n\n\n","created_at":"2022-02-15T11:31:50.122+08:00","updated_at":"2022-02-15T11:31:50.122+08:00","name":"貪食蛇(預設版). 副本","language":"python","screenshot":{"url":null},"parent_id":345148,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":151,"hashid":"qmds8y9qe","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":7433075,"file_name":"body_right.png","project_id":345229,"asset_id":475110,"created_at":"2022-02-15T11:31:50.127+08:00","updated_at":"2022-02-15T11:31:50.127+08:00"},{"id":7433076,"file_name":"bgm.mp3","project_id":345229,"asset_id":475109,"created_at":"2022-02-15T11:31:50.128+08:00","updated_at":"2022-02-15T11:31:50.128+08:00"},{"id":7433077,"file_name":"bling.ogg","project_id":345229,"asset_id":475108,"created_at":"2022-02-15T11:31:50.129+08:00","updated_at":"2022-02-15T11:31:50.129+08:00"},{"id":7433078,"file_name":"orange.png","project_id":345229,"asset_id":475107,"created_at":"2022-02-15T11:31:50.129+08:00","updated_at":"2022-02-15T11:31:50.129+08:00"},{"id":7433079,"file_name":"tail.png","project_id":345229,"asset_id":475106,"created_at":"2022-02-15T11:31:50.130+08:00","updated_at":"2022-02-15T11:31:50.130+08:00"},{"id":7433080,"file_name":"hint.png","project_id":345229,"asset_id":475105,"created_at":"2022-02-15T11:31:50.131+08:00","updated_at":"2022-02-15T11:31:50.131+08:00"},{"id":7433081,"file_name":"head.png","project_id":345229,"asset_id":475104,"created_at":"2022-02-15T11:31:50.132+08:00","updated_at":"2022-02-15T11:31:50.132+08:00"},{"id":7433082,"file_name":"gameover.png","project_id":345229,"asset_id":475103,"created_at":"2022-02-15T11:31:50.133+08:00","updated_at":"2022-02-15T11:31:50.133+08:00"},{"id":7433083,"file_name":"apple.png","project_id":345229,"asset_id":475102,"created_at":"2022-02-15T11:31:50.133+08:00","updated_at":"2022-02-15T11:31:50.133+08:00"},{"id":7433084,"file_name":"body.png","project_id":345229,"asset_id":475101,"created_at":"2022-02-15T11:31:50.134+08:00","updated_at":"2022-02-15T11:31:50.134+08:00"},{"id":7433085,"file_name":"body_left.png","project_id":345229,"asset_id":475100,"created_at":"2022-02-15T11:31:50.135+08:00","updated_at":"2022-02-15T11:31:50.135+08:00"},{"id":7433086,"file_name":"bg.jpg","project_id":345229,"asset_id":475099,"created_at":"2022-02-15T11:31:50.136+08:00","updated_at":"2022-02-15T11:31:50.136+08:00"},{"id":7433087,"file_name":"bg_grid.jpg","project_id":345229,"asset_id":475098,"created_at":"2022-02-15T11:31:50.137+08:00","updated_at":"2022-02-15T11:31:50.137+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦