{"id":887705,"student_id":1444,"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 + score // 10\n s.x -= speed\n \n if s.x \u003c= -150:\n s.x = s.x + 1500\n s.y = random() * 900\n s.costume_id = randrange(4) * 4\n s.turbo = random() \u003c 0.3\n if s.turbo:\n s.x += s.x - 300\n s.y += s.y - 600\n \n if s.x \u003c= 300:\n s.y += 5\n else:\n scale = (s.y - 600) / (s.x - 300)\n s.y -= scale * speed\n if s.turbo:\n s.x -= speed\n s.y -= scale * speed\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 = score % 10\n n2.costume_id = score // 10 % 10\n n3.costume_id = score // 100\n \nforever(loop)\n","created_at":"2024-11-16T15:16:47.202+08:00","updated_at":"2024-11-16T17:28:35.474+08:00","name":"3_氣球任務_預設版 副本","language":"python","screenshot":{"url":"https://cdn2.koding.school/uploads/project/screenshot/887705/50fe648aa6bc0842e6ad56e534b5ef62.jpg"},"parent_id":830003,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":8,"hashid":"6rpsrk4vw","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":34534424,"file_name":"bgm.mp3","project_id":887705,"asset_id":771798,"created_at":"2024-11-16T15:16:47.209+08:00","updated_at":"2024-11-16T15:16:47.209+08:00"},{"id":34534425,"file_name":"pick.mp3","project_id":887705,"asset_id":771799,"created_at":"2024-11-16T15:16:47.210+08:00","updated_at":"2024-11-16T15:16:47.210+08:00"},{"id":34534426,"file_name":"p_1.png","project_id":887705,"asset_id":771800,"created_at":"2024-11-16T15:16:47.211+08:00","updated_at":"2024-11-16T15:16:47.211+08:00"},{"id":34534427,"file_name":"p_2.png","project_id":887705,"asset_id":771801,"created_at":"2024-11-16T15:16:47.212+08:00","updated_at":"2024-11-16T15:16:47.212+08:00"},{"id":34534428,"file_name":"4.png","project_id":887705,"asset_id":771802,"created_at":"2024-11-16T15:16:47.213+08:00","updated_at":"2024-11-16T15:16:47.213+08:00"},{"id":34534429,"file_name":"5.png","project_id":887705,"asset_id":771803,"created_at":"2024-11-16T15:16:47.214+08:00","updated_at":"2024-11-16T15:16:47.214+08:00"},{"id":34534430,"file_name":"g_11.png","project_id":887705,"asset_id":771804,"created_at":"2024-11-16T15:16:47.215+08:00","updated_at":"2024-11-16T15:16:47.215+08:00"},{"id":34534431,"file_name":"g_12.png","project_id":887705,"asset_id":771805,"created_at":"2024-11-16T15:16:47.217+08:00","updated_at":"2024-11-16T15:16:47.217+08:00"},{"id":34534432,"file_name":"bg.png","project_id":887705,"asset_id":771806,"created_at":"2024-11-16T15:16:47.218+08:00","updated_at":"2024-11-16T15:16:47.218+08:00"},{"id":34534433,"file_name":"g_0.png","project_id":887705,"asset_id":771807,"created_at":"2024-11-16T15:16:47.219+08:00","updated_at":"2024-11-16T15:16:47.219+08:00"},{"id":34534434,"file_name":"2.png","project_id":887705,"asset_id":771808,"created_at":"2024-11-16T15:16:47.219+08:00","updated_at":"2024-11-16T15:16:47.219+08:00"},{"id":34534435,"file_name":"3.png","project_id":887705,"asset_id":771809,"created_at":"2024-11-16T15:16:47.222+08:00","updated_at":"2024-11-16T15:16:47.222+08:00"},{"id":34534436,"file_name":"g_13.png","project_id":887705,"asset_id":771810,"created_at":"2024-11-16T15:16:47.223+08:00","updated_at":"2024-11-16T15:16:47.223+08:00"},{"id":34534437,"file_name":"g_14.png","project_id":887705,"asset_id":771811,"created_at":"2024-11-16T15:16:47.224+08:00","updated_at":"2024-11-16T15:16:47.224+08:00"},{"id":34534438,"file_name":"all.png","project_id":887705,"asset_id":771812,"created_at":"2024-11-16T15:16:47.225+08:00","updated_at":"2024-11-16T15:16:47.225+08:00"},{"id":34534439,"file_name":"balloons.png","project_id":887705,"asset_id":771813,"created_at":"2024-11-16T15:16:47.226+08:00","updated_at":"2024-11-16T15:16:47.226+08:00"},{"id":34534440,"file_name":"g_3.png","project_id":887705,"asset_id":771814,"created_at":"2024-11-16T15:16:47.227+08:00","updated_at":"2024-11-16T15:16:47.227+08:00"},{"id":34534441,"file_name":"g_4.png","project_id":887705,"asset_id":771815,"created_at":"2024-11-16T15:16:47.228+08:00","updated_at":"2024-11-16T15:16:47.228+08:00"},{"id":34534442,"file_name":"g_5.png","project_id":887705,"asset_id":771816,"created_at":"2024-11-16T15:16:47.229+08:00","updated_at":"2024-11-16T15:16:47.229+08:00"},{"id":34534443,"file_name":"g_6.png","project_id":887705,"asset_id":771817,"created_at":"2024-11-16T15:16:47.230+08:00","updated_at":"2024-11-16T15:16:47.230+08:00"},{"id":34534444,"file_name":"0.png","project_id":887705,"asset_id":771818,"created_at":"2024-11-16T15:16:47.231+08:00","updated_at":"2024-11-16T15:16:47.231+08:00"},{"id":34534445,"file_name":"1.png","project_id":887705,"asset_id":771819,"created_at":"2024-11-16T15:16:47.232+08:00","updated_at":"2024-11-16T15:16:47.232+08:00"},{"id":34534446,"file_name":"g_7.png","project_id":887705,"asset_id":771820,"created_at":"2024-11-16T15:16:47.233+08:00","updated_at":"2024-11-16T15:16:47.233+08:00"},{"id":34534447,"file_name":"g_8.png","project_id":887705,"asset_id":771821,"created_at":"2024-11-16T15:16:47.234+08:00","updated_at":"2024-11-16T15:16:47.234+08:00"},{"id":34534448,"file_name":"g_9.png","project_id":887705,"asset_id":771822,"created_at":"2024-11-16T15:16:47.235+08:00","updated_at":"2024-11-16T15:16:47.235+08:00"},{"id":34534449,"file_name":"g_10.png","project_id":887705,"asset_id":771823,"created_at":"2024-11-16T15:16:47.236+08:00","updated_at":"2024-11-16T15:16:47.236+08:00"},{"id":34534450,"file_name":"8.png","project_id":887705,"asset_id":771824,"created_at":"2024-11-16T15:16:47.237+08:00","updated_at":"2024-11-16T15:16:47.237+08:00"},{"id":34534451,"file_name":"9.png","project_id":887705,"asset_id":771825,"created_at":"2024-11-16T15:16:47.238+08:00","updated_at":"2024-11-16T15:16:47.238+08:00"},{"id":34534452,"file_name":"g_15.png","project_id":887705,"asset_id":771826,"created_at":"2024-11-16T15:16:47.239+08:00","updated_at":"2024-11-16T15:16:47.239+08:00"},{"id":34534453,"file_name":"p_0.png","project_id":887705,"asset_id":771827,"created_at":"2024-11-16T15:16:47.240+08:00","updated_at":"2024-11-16T15:16:47.240+08:00"},{"id":34534454,"file_name":"g_1.png","project_id":887705,"asset_id":771828,"created_at":"2024-11-16T15:16:47.241+08:00","updated_at":"2024-11-16T15:16:47.241+08:00"},{"id":34534455,"file_name":"g_2.png","project_id":887705,"asset_id":771829,"created_at":"2024-11-16T15:16:47.242+08:00","updated_at":"2024-11-16T15:16:47.242+08:00"},{"id":34534456,"file_name":"p_3.png","project_id":887705,"asset_id":771830,"created_at":"2024-11-16T15:16:47.243+08:00","updated_at":"2024-11-16T15:16:47.243+08:00"},{"id":34534457,"file_name":"p_4.png","project_id":887705,"asset_id":771831,"created_at":"2024-11-16T15:16:47.244+08:00","updated_at":"2024-11-16T15:16:47.244+08:00"},{"id":34534458,"file_name":"p_5.png","project_id":887705,"asset_id":771832,"created_at":"2024-11-16T15:16:47.245+08:00","updated_at":"2024-11-16T15:16:47.245+08:00"},{"id":34534459,"file_name":"rules.png","project_id":887705,"asset_id":771833,"created_at":"2024-11-16T15:16:47.246+08:00","updated_at":"2024-11-16T15:16:47.246+08:00"},{"id":34534460,"file_name":"6.png","project_id":887705,"asset_id":771834,"created_at":"2024-11-16T15:16:47.247+08:00","updated_at":"2024-11-16T15:16:47.247+08:00"},{"id":34534461,"file_name":"7.png","project_id":887705,"asset_id":771835,"created_at":"2024-11-16T15:16:47.248+08:00","updated_at":"2024-11-16T15:16:47.248+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦