{"id":863576,"student_id":1981,"content":"from game import set_backdrop, create_sprite, create_sound, forever\nfrom random import random, randrange\n\nset_backdrop('bg.png') #設定背景\nnumbers = ['0.png', '1.png', '2.png', '3.png', '4.png', '5.png', '6.png', '7.png', '8.png', '9.png']\nplayer = create_sprite('p_0.png', 'p_1.png', 'p_2.png', 'p_3.png', 'p_4.png', 'p_5.png') #玩家\nballoons = create_sprite('balloons.png') #一束氣球\nn1 = game.create_sprite(numbers) #百位數\nn2 = game.create_sprite(numbers) #十位數\nn3 = game.create_sprite(numbers) #個位數\nrules = create_sprite('rules.png') #遊戲說明\n# bgm = create_sound('bgm.mp3') #背景音樂\nplayer.move_to(200, 600)\nballoons.move_to(200, 600)\nn1.move_to(200, 50)\nn2.move_to(125, 50)\nn3.move_to(50, 50)\nrules.layer = 1\n\nscore = 0 #分數\nvisitors = [] #存放遊客角色\n\n#創造 5 個遊客角色\nfor i in range(5):\n s = create_sprite(\n 'g_0.png', 'g_1.png', 'g_2.png', 'g_3.png',\n 'g_4.png', 'g_5.png', 'g_6.png', 'g_7.png',\n 'g_8.png', 'g_9.png', 'g_10.png', 'g_11.png',\n 'g_12.png', 'g_13.png', 'g_14.png', 'g_15.png'\n )\n s.x = i * 300 + 1200 #遊客之間間隔為 300\n s.y = 600\n s.costume_id = randrange(4) * 4\n s.turbo = False #加速模式關閉\n visitors.append(s)\n\n# 遊戲迴圈\ndef loop():\n if key.space: rules.hidden = True #空白鍵隱藏說明圖\n if player.costume_id \u003c 3:\n if key.right: player.costume_id = 1 #右鍵切換拿小氣球\n if key.left: player.costume_id = 2 #左鍵切換拿大氣球\n \n #如果玩家切換驚訝表情,就讓氣球向上飄\n if player.costume_id \u003e= 3: balloons.y -= 2\n \n # 如果說明圖隱藏,而且玩家沒有切換至驚訝表情,才移動遊客角色\n if rules.hidden and player.costume_id \u003c 3:\n for s in visitors:\n update_position(s) #更新遊客位置\n update_costume(s) #切換遊客走路圖\n exchange_balloon(s) #交換氣球\n \n update_scores() #更新分數\n\n# 更新遊客的位置\ndef update_position(s):\n \n speed = 3\n s.x = s.x - speed\n \n if s.x \u003c= -150:\n s.x = s.x + 1500\n s.y = 600\n s.costume_id = randrange(4) * 4\n \n if s.x \u003c= 300:\n s.y += 5\n\n# 偵測是否到達終點,並將玩家手上的氣球轉給遊客\ndef exchange_balloon(s):\n global score\n if s.x \u003c= 300 and s.costume_id % 4 \u003c 2:\n if player.costume_id == 1 and s.costume_id \u003c 8:\n s.costume_id += 2 #遊客切換拿氣球圖\n player.costume_id = 0 #玩家切換空手圖\n score += 1\n # create_sound('pick.mp3') #音效\n elif player.costume_id == 2 and s.costume_id \u003e 7:\n s.costume_id += 2 #遊客切換拿氣球圖\n player.costume_id = 0 #玩家切換空手圖\n score += 1\n # create_sound('pick.mp3') #音效\n else:\n player.costume_id += 3 #切換驚訝表情\n # bgm.pause() #停止背景音樂\n \n# 切換遊客的走路動畫\ndef update_costume(s):\n i = (s.x // 50) % 2 #每移動 50 距離切換走路圖\n if s.costume_id % 2 == 0 and i == 1: s.costume_id += 1\n if s.costume_id % 2 == 1 and i == 0: s.costume_id -= 1\n\n# 更新分數\ndef update_scores():\n n1.costume_id = 0\n n2.costume_id = 0\n n3.costume_id = 0\n \nforever(loop)\n","created_at":"2024-10-15T16:10:42.742+08:00","updated_at":"2024-10-15T16:10:52.287+08:00","name":"5_氣球任務_預設版 副本","language":"python","screenshot":{"url":"https://cdn4.koding.school/uploads/project/screenshot/863576/a514e1e70a2d5edcf5f4ebf0139fb199.jpg"},"parent_id":830003,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":3,"hashid":"882sjmejk","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":18911599,"file_name":"bgm.mp3","project_id":863576,"asset_id":771798,"created_at":"2024-10-15T16:10:42.749+08:00","updated_at":"2024-10-15T16:10:42.749+08:00"},{"id":18911600,"file_name":"pick.mp3","project_id":863576,"asset_id":771799,"created_at":"2024-10-15T16:10:42.751+08:00","updated_at":"2024-10-15T16:10:42.751+08:00"},{"id":18911601,"file_name":"p_1.png","project_id":863576,"asset_id":771800,"created_at":"2024-10-15T16:10:42.752+08:00","updated_at":"2024-10-15T16:10:42.752+08:00"},{"id":18911602,"file_name":"p_2.png","project_id":863576,"asset_id":771801,"created_at":"2024-10-15T16:10:42.753+08:00","updated_at":"2024-10-15T16:10:42.753+08:00"},{"id":18911603,"file_name":"4.png","project_id":863576,"asset_id":771802,"created_at":"2024-10-15T16:10:42.754+08:00","updated_at":"2024-10-15T16:10:42.754+08:00"},{"id":18911604,"file_name":"5.png","project_id":863576,"asset_id":771803,"created_at":"2024-10-15T16:10:42.755+08:00","updated_at":"2024-10-15T16:10:42.755+08:00"},{"id":18911605,"file_name":"g_11.png","project_id":863576,"asset_id":771804,"created_at":"2024-10-15T16:10:42.757+08:00","updated_at":"2024-10-15T16:10:42.757+08:00"},{"id":18911606,"file_name":"g_12.png","project_id":863576,"asset_id":771805,"created_at":"2024-10-15T16:10:42.758+08:00","updated_at":"2024-10-15T16:10:42.758+08:00"},{"id":18911607,"file_name":"bg.png","project_id":863576,"asset_id":771806,"created_at":"2024-10-15T16:10:42.759+08:00","updated_at":"2024-10-15T16:10:42.759+08:00"},{"id":18911608,"file_name":"g_0.png","project_id":863576,"asset_id":771807,"created_at":"2024-10-15T16:10:42.760+08:00","updated_at":"2024-10-15T16:10:42.760+08:00"},{"id":18911609,"file_name":"2.png","project_id":863576,"asset_id":771808,"created_at":"2024-10-15T16:10:42.761+08:00","updated_at":"2024-10-15T16:10:42.761+08:00"},{"id":18911610,"file_name":"3.png","project_id":863576,"asset_id":771809,"created_at":"2024-10-15T16:10:42.762+08:00","updated_at":"2024-10-15T16:10:42.762+08:00"},{"id":18911611,"file_name":"g_13.png","project_id":863576,"asset_id":771810,"created_at":"2024-10-15T16:10:42.763+08:00","updated_at":"2024-10-15T16:10:42.763+08:00"},{"id":18911612,"file_name":"g_14.png","project_id":863576,"asset_id":771811,"created_at":"2024-10-15T16:10:42.764+08:00","updated_at":"2024-10-15T16:10:42.764+08:00"},{"id":18911613,"file_name":"all.png","project_id":863576,"asset_id":771812,"created_at":"2024-10-15T16:10:42.765+08:00","updated_at":"2024-10-15T16:10:42.765+08:00"},{"id":18911614,"file_name":"balloons.png","project_id":863576,"asset_id":771813,"created_at":"2024-10-15T16:10:42.766+08:00","updated_at":"2024-10-15T16:10:42.766+08:00"},{"id":18911615,"file_name":"g_3.png","project_id":863576,"asset_id":771814,"created_at":"2024-10-15T16:10:42.768+08:00","updated_at":"2024-10-15T16:10:42.768+08:00"},{"id":18911616,"file_name":"g_4.png","project_id":863576,"asset_id":771815,"created_at":"2024-10-15T16:10:42.769+08:00","updated_at":"2024-10-15T16:10:42.769+08:00"},{"id":18911617,"file_name":"g_5.png","project_id":863576,"asset_id":771816,"created_at":"2024-10-15T16:10:42.770+08:00","updated_at":"2024-10-15T16:10:42.770+08:00"},{"id":18911618,"file_name":"g_6.png","project_id":863576,"asset_id":771817,"created_at":"2024-10-15T16:10:42.771+08:00","updated_at":"2024-10-15T16:10:42.771+08:00"},{"id":18911619,"file_name":"0.png","project_id":863576,"asset_id":771818,"created_at":"2024-10-15T16:10:42.772+08:00","updated_at":"2024-10-15T16:10:42.772+08:00"},{"id":18911620,"file_name":"1.png","project_id":863576,"asset_id":771819,"created_at":"2024-10-15T16:10:42.773+08:00","updated_at":"2024-10-15T16:10:42.773+08:00"},{"id":18911621,"file_name":"g_7.png","project_id":863576,"asset_id":771820,"created_at":"2024-10-15T16:10:42.774+08:00","updated_at":"2024-10-15T16:10:42.774+08:00"},{"id":18911622,"file_name":"g_8.png","project_id":863576,"asset_id":771821,"created_at":"2024-10-15T16:10:42.775+08:00","updated_at":"2024-10-15T16:10:42.775+08:00"},{"id":18911623,"file_name":"g_9.png","project_id":863576,"asset_id":771822,"created_at":"2024-10-15T16:10:42.776+08:00","updated_at":"2024-10-15T16:10:42.776+08:00"},{"id":18911624,"file_name":"g_10.png","project_id":863576,"asset_id":771823,"created_at":"2024-10-15T16:10:42.778+08:00","updated_at":"2024-10-15T16:10:42.778+08:00"},{"id":18911625,"file_name":"8.png","project_id":863576,"asset_id":771824,"created_at":"2024-10-15T16:10:42.779+08:00","updated_at":"2024-10-15T16:10:42.779+08:00"},{"id":18911626,"file_name":"9.png","project_id":863576,"asset_id":771825,"created_at":"2024-10-15T16:10:42.780+08:00","updated_at":"2024-10-15T16:10:42.780+08:00"},{"id":18911627,"file_name":"g_15.png","project_id":863576,"asset_id":771826,"created_at":"2024-10-15T16:10:42.781+08:00","updated_at":"2024-10-15T16:10:42.781+08:00"},{"id":18911628,"file_name":"p_0.png","project_id":863576,"asset_id":771827,"created_at":"2024-10-15T16:10:42.783+08:00","updated_at":"2024-10-15T16:10:42.783+08:00"},{"id":18911629,"file_name":"g_1.png","project_id":863576,"asset_id":771828,"created_at":"2024-10-15T16:10:42.784+08:00","updated_at":"2024-10-15T16:10:42.784+08:00"},{"id":18911630,"file_name":"g_2.png","project_id":863576,"asset_id":771829,"created_at":"2024-10-15T16:10:42.785+08:00","updated_at":"2024-10-15T16:10:42.785+08:00"},{"id":18911631,"file_name":"p_3.png","project_id":863576,"asset_id":771830,"created_at":"2024-10-15T16:10:42.786+08:00","updated_at":"2024-10-15T16:10:42.786+08:00"},{"id":18911632,"file_name":"p_4.png","project_id":863576,"asset_id":771831,"created_at":"2024-10-15T16:10:42.787+08:00","updated_at":"2024-10-15T16:10:42.787+08:00"},{"id":18911633,"file_name":"p_5.png","project_id":863576,"asset_id":771832,"created_at":"2024-10-15T16:10:42.788+08:00","updated_at":"2024-10-15T16:10:42.788+08:00"},{"id":18911634,"file_name":"rules.png","project_id":863576,"asset_id":771833,"created_at":"2024-10-15T16:10:42.789+08:00","updated_at":"2024-10-15T16:10:42.789+08:00"},{"id":18911635,"file_name":"6.png","project_id":863576,"asset_id":771834,"created_at":"2024-10-15T16:10:42.790+08:00","updated_at":"2024-10-15T16:10:42.790+08:00"},{"id":18911636,"file_name":"7.png","project_id":863576,"asset_id":771835,"created_at":"2024-10-15T16:10:42.791+08:00","updated_at":"2024-10-15T16:10:42.791+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦