{"id":857577,"student_id":2589,"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') #遊戲說明\nbgm = create_sound('bgm.mp3', True) #背景音樂\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 = 20 #分數\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 = 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 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-10-07T12:04:43.420+08:00","updated_at":"2024-10-07T12:04:52.247+08:00","name":"5_氣球任務_完整版","language":"python","screenshot":{"url":null},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":5,"hashid":"2pdspmez2","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":18806298,"file_name":"bgm.mp3","project_id":857577,"asset_id":781625,"created_at":"2024-10-07T12:04:52.028+08:00","updated_at":"2024-10-07T12:04:52.028+08:00"},{"id":18806299,"file_name":"pick.mp3","project_id":857577,"asset_id":781626,"created_at":"2024-10-07T12:04:52.036+08:00","updated_at":"2024-10-07T12:04:52.036+08:00"},{"id":18806300,"file_name":"p_1.png","project_id":857577,"asset_id":781627,"created_at":"2024-10-07T12:04:52.042+08:00","updated_at":"2024-10-07T12:04:52.042+08:00"},{"id":18806301,"file_name":"p_2.png","project_id":857577,"asset_id":781628,"created_at":"2024-10-07T12:04:52.047+08:00","updated_at":"2024-10-07T12:04:52.047+08:00"},{"id":18806302,"file_name":"4.png","project_id":857577,"asset_id":781629,"created_at":"2024-10-07T12:04:52.052+08:00","updated_at":"2024-10-07T12:04:52.052+08:00"},{"id":18806303,"file_name":"5.png","project_id":857577,"asset_id":781630,"created_at":"2024-10-07T12:04:52.056+08:00","updated_at":"2024-10-07T12:04:52.056+08:00"},{"id":18806304,"file_name":"g_11.png","project_id":857577,"asset_id":781631,"created_at":"2024-10-07T12:04:52.061+08:00","updated_at":"2024-10-07T12:04:52.061+08:00"},{"id":18806305,"file_name":"g_12.png","project_id":857577,"asset_id":781632,"created_at":"2024-10-07T12:04:52.066+08:00","updated_at":"2024-10-07T12:04:52.066+08:00"},{"id":18806306,"file_name":"bg.png","project_id":857577,"asset_id":781633,"created_at":"2024-10-07T12:04:52.074+08:00","updated_at":"2024-10-07T12:04:52.074+08:00"},{"id":18806307,"file_name":"g_0.png","project_id":857577,"asset_id":781634,"created_at":"2024-10-07T12:04:52.080+08:00","updated_at":"2024-10-07T12:04:52.080+08:00"},{"id":18806308,"file_name":"2.png","project_id":857577,"asset_id":781635,"created_at":"2024-10-07T12:04:52.084+08:00","updated_at":"2024-10-07T12:04:52.084+08:00"},{"id":18806309,"file_name":"3.png","project_id":857577,"asset_id":781636,"created_at":"2024-10-07T12:04:52.089+08:00","updated_at":"2024-10-07T12:04:52.089+08:00"},{"id":18806310,"file_name":"g_13.png","project_id":857577,"asset_id":781637,"created_at":"2024-10-07T12:04:52.093+08:00","updated_at":"2024-10-07T12:04:52.093+08:00"},{"id":18806311,"file_name":"g_14.png","project_id":857577,"asset_id":781638,"created_at":"2024-10-07T12:04:52.098+08:00","updated_at":"2024-10-07T12:04:52.098+08:00"},{"id":18806312,"file_name":"all.png","project_id":857577,"asset_id":781639,"created_at":"2024-10-07T12:04:52.104+08:00","updated_at":"2024-10-07T12:04:52.104+08:00"},{"id":18806313,"file_name":"balloons.png","project_id":857577,"asset_id":781640,"created_at":"2024-10-07T12:04:52.109+08:00","updated_at":"2024-10-07T12:04:52.109+08:00"},{"id":18806314,"file_name":"g_3.png","project_id":857577,"asset_id":781641,"created_at":"2024-10-07T12:04:52.114+08:00","updated_at":"2024-10-07T12:04:52.114+08:00"},{"id":18806315,"file_name":"g_4.png","project_id":857577,"asset_id":781642,"created_at":"2024-10-07T12:04:52.119+08:00","updated_at":"2024-10-07T12:04:52.119+08:00"},{"id":18806316,"file_name":"g_5.png","project_id":857577,"asset_id":781643,"created_at":"2024-10-07T12:04:52.124+08:00","updated_at":"2024-10-07T12:04:52.124+08:00"},{"id":18806317,"file_name":"g_6.png","project_id":857577,"asset_id":781644,"created_at":"2024-10-07T12:04:52.128+08:00","updated_at":"2024-10-07T12:04:52.128+08:00"},{"id":18806318,"file_name":"0.png","project_id":857577,"asset_id":781645,"created_at":"2024-10-07T12:04:52.133+08:00","updated_at":"2024-10-07T12:04:52.133+08:00"},{"id":18806319,"file_name":"1.png","project_id":857577,"asset_id":781646,"created_at":"2024-10-07T12:04:52.138+08:00","updated_at":"2024-10-07T12:04:52.138+08:00"},{"id":18806320,"file_name":"g_7.png","project_id":857577,"asset_id":781647,"created_at":"2024-10-07T12:04:52.161+08:00","updated_at":"2024-10-07T12:04:52.161+08:00"},{"id":18806321,"file_name":"g_8.png","project_id":857577,"asset_id":781648,"created_at":"2024-10-07T12:04:52.166+08:00","updated_at":"2024-10-07T12:04:52.166+08:00"},{"id":18806322,"file_name":"g_9.png","project_id":857577,"asset_id":781649,"created_at":"2024-10-07T12:04:52.171+08:00","updated_at":"2024-10-07T12:04:52.171+08:00"},{"id":18806323,"file_name":"g_10.png","project_id":857577,"asset_id":781650,"created_at":"2024-10-07T12:04:52.176+08:00","updated_at":"2024-10-07T12:04:52.176+08:00"},{"id":18806324,"file_name":"8.png","project_id":857577,"asset_id":781651,"created_at":"2024-10-07T12:04:52.181+08:00","updated_at":"2024-10-07T12:04:52.181+08:00"},{"id":18806325,"file_name":"9.png","project_id":857577,"asset_id":781652,"created_at":"2024-10-07T12:04:52.186+08:00","updated_at":"2024-10-07T12:04:52.186+08:00"},{"id":18806326,"file_name":"g_15.png","project_id":857577,"asset_id":781653,"created_at":"2024-10-07T12:04:52.200+08:00","updated_at":"2024-10-07T12:04:52.200+08:00"},{"id":18806327,"file_name":"p_0.png","project_id":857577,"asset_id":781654,"created_at":"2024-10-07T12:04:52.204+08:00","updated_at":"2024-10-07T12:04:52.204+08:00"},{"id":18806328,"file_name":"g_1.png","project_id":857577,"asset_id":781655,"created_at":"2024-10-07T12:04:52.209+08:00","updated_at":"2024-10-07T12:04:52.209+08:00"},{"id":18806329,"file_name":"g_2.png","project_id":857577,"asset_id":781656,"created_at":"2024-10-07T12:04:52.213+08:00","updated_at":"2024-10-07T12:04:52.213+08:00"},{"id":18806330,"file_name":"p_3.png","project_id":857577,"asset_id":781657,"created_at":"2024-10-07T12:04:52.218+08:00","updated_at":"2024-10-07T12:04:52.218+08:00"},{"id":18806331,"file_name":"p_4.png","project_id":857577,"asset_id":781658,"created_at":"2024-10-07T12:04:52.222+08:00","updated_at":"2024-10-07T12:04:52.222+08:00"},{"id":18806332,"file_name":"p_5.png","project_id":857577,"asset_id":781659,"created_at":"2024-10-07T12:04:52.231+08:00","updated_at":"2024-10-07T12:04:52.231+08:00"},{"id":18806333,"file_name":"rules.png","project_id":857577,"asset_id":781660,"created_at":"2024-10-07T12:04:52.238+08:00","updated_at":"2024-10-07T12:04:52.238+08:00"},{"id":18806334,"file_name":"6.png","project_id":857577,"asset_id":781661,"created_at":"2024-10-07T12:04:52.242+08:00","updated_at":"2024-10-07T12:04:52.242+08:00"},{"id":18806335,"file_name":"7.png","project_id":857577,"asset_id":781662,"created_at":"2024-10-07T12:04:52.246+08:00","updated_at":"2024-10-07T12:04:52.246+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦