{"id":772251,"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\n# bgm = create_sound('bgm.mp3', True) #播放背景音樂\n# bgm.setVolume(0.2) #捨定背景音量\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-06-21T16:33:58.707+08:00","updated_at":"2024-07-25T14:32:36.377+08:00","name":"氣球任務_完整版","language":"python","screenshot":{"url":"https://cdn7.koding.school/uploads/project/screenshot/772251/a514e1e70a2d5edcf5f4ebf0139fb199.jpg"},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":43,"hashid":"882snzv48","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":17745541,"file_name":"bgm.mp3","project_id":772251,"asset_id":758582,"created_at":"2024-07-25T13:59:11.900+08:00","updated_at":"2024-07-25T13:59:11.900+08:00"},{"id":17745542,"file_name":"pick.mp3","project_id":772251,"asset_id":758583,"created_at":"2024-07-25T13:59:11.906+08:00","updated_at":"2024-07-25T13:59:11.906+08:00"},{"id":17745543,"file_name":"p_1.png","project_id":772251,"asset_id":758584,"created_at":"2024-07-25T13:59:11.911+08:00","updated_at":"2024-07-25T13:59:11.911+08:00"},{"id":17745544,"file_name":"p_2.png","project_id":772251,"asset_id":758585,"created_at":"2024-07-25T13:59:11.916+08:00","updated_at":"2024-07-25T13:59:11.916+08:00"},{"id":17745545,"file_name":"4.png","project_id":772251,"asset_id":758586,"created_at":"2024-07-25T13:59:11.920+08:00","updated_at":"2024-07-25T13:59:11.920+08:00"},{"id":17745546,"file_name":"5.png","project_id":772251,"asset_id":758587,"created_at":"2024-07-25T13:59:11.924+08:00","updated_at":"2024-07-25T13:59:11.924+08:00"},{"id":17745547,"file_name":"g_11.png","project_id":772251,"asset_id":758588,"created_at":"2024-07-25T13:59:11.929+08:00","updated_at":"2024-07-25T13:59:11.929+08:00"},{"id":17745548,"file_name":"g_12.png","project_id":772251,"asset_id":758589,"created_at":"2024-07-25T13:59:11.933+08:00","updated_at":"2024-07-25T13:59:11.933+08:00"},{"id":17745549,"file_name":"bg.png","project_id":772251,"asset_id":758590,"created_at":"2024-07-25T13:59:11.939+08:00","updated_at":"2024-07-25T13:59:11.939+08:00"},{"id":17745550,"file_name":"g_0.png","project_id":772251,"asset_id":758591,"created_at":"2024-07-25T13:59:11.943+08:00","updated_at":"2024-07-25T13:59:11.943+08:00"},{"id":17745551,"file_name":"2.png","project_id":772251,"asset_id":758592,"created_at":"2024-07-25T13:59:11.947+08:00","updated_at":"2024-07-25T13:59:11.947+08:00"},{"id":17745552,"file_name":"3.png","project_id":772251,"asset_id":758593,"created_at":"2024-07-25T13:59:11.952+08:00","updated_at":"2024-07-25T13:59:11.952+08:00"},{"id":17745553,"file_name":"g_13.png","project_id":772251,"asset_id":758594,"created_at":"2024-07-25T13:59:11.957+08:00","updated_at":"2024-07-25T13:59:11.957+08:00"},{"id":17745554,"file_name":"g_14.png","project_id":772251,"asset_id":758595,"created_at":"2024-07-25T13:59:11.962+08:00","updated_at":"2024-07-25T13:59:11.962+08:00"},{"id":17745555,"file_name":"all.png","project_id":772251,"asset_id":758596,"created_at":"2024-07-25T13:59:11.968+08:00","updated_at":"2024-07-25T13:59:11.968+08:00"},{"id":17745556,"file_name":"balloons.png","project_id":772251,"asset_id":758597,"created_at":"2024-07-25T13:59:11.973+08:00","updated_at":"2024-07-25T13:59:11.973+08:00"},{"id":17745557,"file_name":"g_3.png","project_id":772251,"asset_id":758598,"created_at":"2024-07-25T13:59:11.978+08:00","updated_at":"2024-07-25T13:59:11.978+08:00"},{"id":17745558,"file_name":"g_4.png","project_id":772251,"asset_id":758599,"created_at":"2024-07-25T13:59:11.982+08:00","updated_at":"2024-07-25T13:59:11.982+08:00"},{"id":17745559,"file_name":"g_5.png","project_id":772251,"asset_id":758600,"created_at":"2024-07-25T13:59:11.986+08:00","updated_at":"2024-07-25T13:59:11.986+08:00"},{"id":17745560,"file_name":"g_6.png","project_id":772251,"asset_id":758601,"created_at":"2024-07-25T13:59:11.991+08:00","updated_at":"2024-07-25T13:59:11.991+08:00"},{"id":17745561,"file_name":"0.png","project_id":772251,"asset_id":758602,"created_at":"2024-07-25T13:59:12.010+08:00","updated_at":"2024-07-25T13:59:12.010+08:00"},{"id":17745562,"file_name":"1.png","project_id":772251,"asset_id":758603,"created_at":"2024-07-25T13:59:12.014+08:00","updated_at":"2024-07-25T13:59:12.014+08:00"},{"id":17745563,"file_name":"g_7.png","project_id":772251,"asset_id":758604,"created_at":"2024-07-25T13:59:12.018+08:00","updated_at":"2024-07-25T13:59:12.018+08:00"},{"id":17745564,"file_name":"g_8.png","project_id":772251,"asset_id":758605,"created_at":"2024-07-25T13:59:12.023+08:00","updated_at":"2024-07-25T13:59:12.023+08:00"},{"id":17745565,"file_name":"g_9.png","project_id":772251,"asset_id":758606,"created_at":"2024-07-25T13:59:12.027+08:00","updated_at":"2024-07-25T13:59:12.027+08:00"},{"id":17745566,"file_name":"g_10.png","project_id":772251,"asset_id":758607,"created_at":"2024-07-25T13:59:12.032+08:00","updated_at":"2024-07-25T13:59:12.032+08:00"},{"id":17745567,"file_name":"8.png","project_id":772251,"asset_id":758608,"created_at":"2024-07-25T13:59:12.036+08:00","updated_at":"2024-07-25T13:59:12.036+08:00"},{"id":17745568,"file_name":"9.png","project_id":772251,"asset_id":758609,"created_at":"2024-07-25T13:59:12.040+08:00","updated_at":"2024-07-25T13:59:12.040+08:00"},{"id":17745569,"file_name":"g_15.png","project_id":772251,"asset_id":758610,"created_at":"2024-07-25T13:59:12.044+08:00","updated_at":"2024-07-25T13:59:12.044+08:00"},{"id":17745570,"file_name":"p_0.png","project_id":772251,"asset_id":758611,"created_at":"2024-07-25T13:59:12.049+08:00","updated_at":"2024-07-25T13:59:12.049+08:00"},{"id":17745571,"file_name":"g_1.png","project_id":772251,"asset_id":758612,"created_at":"2024-07-25T13:59:12.053+08:00","updated_at":"2024-07-25T13:59:12.053+08:00"},{"id":17745572,"file_name":"g_2.png","project_id":772251,"asset_id":758613,"created_at":"2024-07-25T13:59:12.058+08:00","updated_at":"2024-07-25T13:59:12.058+08:00"},{"id":17745573,"file_name":"p_3.png","project_id":772251,"asset_id":758614,"created_at":"2024-07-25T13:59:12.062+08:00","updated_at":"2024-07-25T13:59:12.062+08:00"},{"id":17745574,"file_name":"p_4.png","project_id":772251,"asset_id":758615,"created_at":"2024-07-25T13:59:12.067+08:00","updated_at":"2024-07-25T13:59:12.067+08:00"},{"id":17745575,"file_name":"p_5.png","project_id":772251,"asset_id":758616,"created_at":"2024-07-25T13:59:12.071+08:00","updated_at":"2024-07-25T13:59:12.071+08:00"},{"id":17745576,"file_name":"rules.png","project_id":772251,"asset_id":758617,"created_at":"2024-07-25T13:59:12.077+08:00","updated_at":"2024-07-25T13:59:12.077+08:00"},{"id":17745577,"file_name":"6.png","project_id":772251,"asset_id":758618,"created_at":"2024-07-25T13:59:12.082+08:00","updated_at":"2024-07-25T13:59:12.082+08:00"},{"id":17745578,"file_name":"7.png","project_id":772251,"asset_id":758619,"created_at":"2024-07-25T13:59:12.086+08:00","updated_at":"2024-07-25T13:59:12.086+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦