{"id":776559,"student_id":10,"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') #遊戲說明\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)\n\nbgm = create_sound('bgm.mp3', True)\nbgm.setVolume(0.2)\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.y = random() * 900\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 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 #如果玩家切換驚訝表情,就讓氣球向上飄\n if player.costume_id \u003e= 3: balloons.y -= 2\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 += 1500\n s.costume_id = randrange(4) * 4\n s.y = random() * 900\n s.turbo = random() \u003c 0.2\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 ratio = (s.y - 600) / (s.x - 300)\n s.y -= speed * ratio\n if s.turbo:\n s.x -= speed\n s.y -= speed * ratio\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 // 1 % 10 #個位數\n n2.costume_id = score // 10 % 10 #十位數\n n3.costume_id = score // 100 % 10 #百位數\n \nforever(loop)\n","created_at":"2024-06-24T15:30:01.345+08:00","updated_at":"2024-06-27T19:57:00.355+08:00","name":"氣球任務_完整版","language":"python","screenshot":{"url":"https://cdn7.koding.school/uploads/project/screenshot/776559/aad0d09da8a4b7b783f2461a3e0d3ed8.jpg"},"parent_id":772251,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":35,"hashid":"yeysge98z","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":17320270,"file_name":"bgm.mp3","project_id":776559,"asset_id":750721,"created_at":"2024-06-27T19:57:00.153+08:00","updated_at":"2024-06-27T19:57:00.153+08:00"},{"id":17320271,"file_name":"pick.mp3","project_id":776559,"asset_id":750722,"created_at":"2024-06-27T19:57:00.159+08:00","updated_at":"2024-06-27T19:57:00.159+08:00"},{"id":17320272,"file_name":"p_1.png","project_id":776559,"asset_id":750723,"created_at":"2024-06-27T19:57:00.164+08:00","updated_at":"2024-06-27T19:57:00.164+08:00"},{"id":17320273,"file_name":"p_2.png","project_id":776559,"asset_id":750724,"created_at":"2024-06-27T19:57:00.168+08:00","updated_at":"2024-06-27T19:57:00.168+08:00"},{"id":17320274,"file_name":"4.png","project_id":776559,"asset_id":750725,"created_at":"2024-06-27T19:57:00.172+08:00","updated_at":"2024-06-27T19:57:00.172+08:00"},{"id":17320275,"file_name":"5.png","project_id":776559,"asset_id":750726,"created_at":"2024-06-27T19:57:00.176+08:00","updated_at":"2024-06-27T19:57:00.176+08:00"},{"id":17320276,"file_name":"g_11.png","project_id":776559,"asset_id":750727,"created_at":"2024-06-27T19:57:00.180+08:00","updated_at":"2024-06-27T19:57:00.180+08:00"},{"id":17320277,"file_name":"g_12.png","project_id":776559,"asset_id":750728,"created_at":"2024-06-27T19:57:00.185+08:00","updated_at":"2024-06-27T19:57:00.185+08:00"},{"id":17320278,"file_name":"bg.png","project_id":776559,"asset_id":750729,"created_at":"2024-06-27T19:57:00.191+08:00","updated_at":"2024-06-27T19:57:00.191+08:00"},{"id":17320279,"file_name":"g_0.png","project_id":776559,"asset_id":750730,"created_at":"2024-06-27T19:57:00.195+08:00","updated_at":"2024-06-27T19:57:00.195+08:00"},{"id":17320280,"file_name":"2.png","project_id":776559,"asset_id":750731,"created_at":"2024-06-27T19:57:00.199+08:00","updated_at":"2024-06-27T19:57:00.199+08:00"},{"id":17320281,"file_name":"3.png","project_id":776559,"asset_id":750732,"created_at":"2024-06-27T19:57:00.203+08:00","updated_at":"2024-06-27T19:57:00.203+08:00"},{"id":17320282,"file_name":"g_13.png","project_id":776559,"asset_id":750733,"created_at":"2024-06-27T19:57:00.207+08:00","updated_at":"2024-06-27T19:57:00.207+08:00"},{"id":17320283,"file_name":"g_14.png","project_id":776559,"asset_id":750734,"created_at":"2024-06-27T19:57:00.211+08:00","updated_at":"2024-06-27T19:57:00.211+08:00"},{"id":17320284,"file_name":"all.png","project_id":776559,"asset_id":750735,"created_at":"2024-06-27T19:57:00.224+08:00","updated_at":"2024-06-27T19:57:00.224+08:00"},{"id":17320285,"file_name":"balloons.png","project_id":776559,"asset_id":750736,"created_at":"2024-06-27T19:57:00.228+08:00","updated_at":"2024-06-27T19:57:00.228+08:00"},{"id":17320286,"file_name":"g_3.png","project_id":776559,"asset_id":750737,"created_at":"2024-06-27T19:57:00.231+08:00","updated_at":"2024-06-27T19:57:00.231+08:00"},{"id":17320287,"file_name":"g_4.png","project_id":776559,"asset_id":750738,"created_at":"2024-06-27T19:57:00.235+08:00","updated_at":"2024-06-27T19:57:00.235+08:00"},{"id":17320288,"file_name":"g_5.png","project_id":776559,"asset_id":750739,"created_at":"2024-06-27T19:57:00.239+08:00","updated_at":"2024-06-27T19:57:00.239+08:00"},{"id":17320289,"file_name":"g_6.png","project_id":776559,"asset_id":750740,"created_at":"2024-06-27T19:57:00.242+08:00","updated_at":"2024-06-27T19:57:00.242+08:00"},{"id":17320290,"file_name":"0.png","project_id":776559,"asset_id":750741,"created_at":"2024-06-27T19:57:00.246+08:00","updated_at":"2024-06-27T19:57:00.246+08:00"},{"id":17320291,"file_name":"1.png","project_id":776559,"asset_id":750742,"created_at":"2024-06-27T19:57:00.250+08:00","updated_at":"2024-06-27T19:57:00.250+08:00"},{"id":17320292,"file_name":"g_7.png","project_id":776559,"asset_id":750743,"created_at":"2024-06-27T19:57:00.254+08:00","updated_at":"2024-06-27T19:57:00.254+08:00"},{"id":17320293,"file_name":"g_8.png","project_id":776559,"asset_id":750744,"created_at":"2024-06-27T19:57:00.289+08:00","updated_at":"2024-06-27T19:57:00.289+08:00"},{"id":17320294,"file_name":"g_9.png","project_id":776559,"asset_id":750745,"created_at":"2024-06-27T19:57:00.294+08:00","updated_at":"2024-06-27T19:57:00.294+08:00"},{"id":17320295,"file_name":"g_10.png","project_id":776559,"asset_id":750746,"created_at":"2024-06-27T19:57:00.298+08:00","updated_at":"2024-06-27T19:57:00.298+08:00"},{"id":17320296,"file_name":"8.png","project_id":776559,"asset_id":750747,"created_at":"2024-06-27T19:57:00.302+08:00","updated_at":"2024-06-27T19:57:00.302+08:00"},{"id":17320297,"file_name":"9.png","project_id":776559,"asset_id":750748,"created_at":"2024-06-27T19:57:00.305+08:00","updated_at":"2024-06-27T19:57:00.305+08:00"},{"id":17320298,"file_name":"g_15.png","project_id":776559,"asset_id":750749,"created_at":"2024-06-27T19:57:00.309+08:00","updated_at":"2024-06-27T19:57:00.309+08:00"},{"id":17320299,"file_name":"p_0.png","project_id":776559,"asset_id":750750,"created_at":"2024-06-27T19:57:00.314+08:00","updated_at":"2024-06-27T19:57:00.314+08:00"},{"id":17320300,"file_name":"g_1.png","project_id":776559,"asset_id":750751,"created_at":"2024-06-27T19:57:00.317+08:00","updated_at":"2024-06-27T19:57:00.317+08:00"},{"id":17320301,"file_name":"g_2.png","project_id":776559,"asset_id":750752,"created_at":"2024-06-27T19:57:00.322+08:00","updated_at":"2024-06-27T19:57:00.322+08:00"},{"id":17320302,"file_name":"p_3.png","project_id":776559,"asset_id":750753,"created_at":"2024-06-27T19:57:00.325+08:00","updated_at":"2024-06-27T19:57:00.325+08:00"},{"id":17320303,"file_name":"p_4.png","project_id":776559,"asset_id":750754,"created_at":"2024-06-27T19:57:00.336+08:00","updated_at":"2024-06-27T19:57:00.336+08:00"},{"id":17320304,"file_name":"p_5.png","project_id":776559,"asset_id":750755,"created_at":"2024-06-27T19:57:00.340+08:00","updated_at":"2024-06-27T19:57:00.340+08:00"},{"id":17320305,"file_name":"rules.png","project_id":776559,"asset_id":750756,"created_at":"2024-06-27T19:57:00.346+08:00","updated_at":"2024-06-27T19:57:00.346+08:00"},{"id":17320306,"file_name":"6.png","project_id":776559,"asset_id":750757,"created_at":"2024-06-27T19:57:00.349+08:00","updated_at":"2024-06-27T19:57:00.349+08:00"},{"id":17320307,"file_name":"7.png","project_id":776559,"asset_id":750758,"created_at":"2024-06-27T19:57:00.353+08:00","updated_at":"2024-06-27T19:57:00.353+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦