{"id":812163,"student_id":10,"content":"from game import *\nfrom random import *\n\nbg = create_sprite('bg.png') #背景\nbucket = create_sprite('bucket_0.png') #籃子底層\nbucket_cover = create_sprite('bucket_1.png') #籃子上層\nplayer = create_sprite('p_0.png', 'p_1.png') #叩叮\nnumbers = [str(i) + '.png' for i in range(10)]\nn1 = create_sprite(numbers) #百位數\nn2 = create_sprite(numbers) #十位數\nn3 = create_sprite(numbers) #個位數\nrules = create_sprite('rules.png') #遊戲說明\n# create_sound('bgm.wav') #背景音樂\n\nbg.move_to(600, 900)\nplayer.move_to(600, 700 + 900)\nbucket.move_to(700, 700 + 900)\nbucket_cover.move_to(700, 700 + 900)\nn1.move_to(150, 70)\nn2.move_to(100, 70)\nn3.move_to(50, 70)\n\nbucket_cover.layer = 2\nplayer.layer = 3\nn1.layer = n2.layer = n3.layer = 3\nrules.layer = 4\n\nitems = [] #存放掉落物\nscore = 0 #分數\nspeed = 2 #速度\n\n# 初始化角色屬性\ndef reset(s):\n s.y = random() * 2000 - 2100\n s.x = random() * 1000 + 100\n s.direction = random() * 360\n s.costume_id = randrange(3)\n s.status = 0\n\n# 創造多個掉落物\nfor i in range(15):\n s = create_sprite('apple.png', 'orange.png', 'mushroom.png')\n reset(s)\n items.append(s)\n\n# 遊戲迴圈\ndef loop():\n global speed\n if key.space: rules.hidden = True #按下空白鍵隱藏遊戲說明\n if rules.hidden and bg.y \u003e 0: scroll() #如果遊戲說明隱藏就向下捲動\n if bg.y == 0: #如果背景已經降下來\n update_player() #更新玩家\n update_bucket() #更新籃子\n update_items() #更新水果\n update_scores() #更新分數\n speed += 0.0005\n\n# 捲動場景\ndef scroll():\n bg.y -= 2\n player.y -= 2\n bucket.y -= 2\n bucket_cover.y -= 2\n\n# 更新玩家\ndef update_player():\n if key.right: player.x += 10\n if key.left: player.x -= 10\n player.costume_id = (player.x // 100) % 2\n\n# 讓籃子跟著玩家移動\ndef update_bucket():\n bucket.x = player.x + 100\n bucket.y = player.y\n bucket_cover.x = player.x + 100\n bucket_cover.y = player.y\n \n# 更新掉落物\ndef update_items():\n global score\n for s in items:\n move_item(s) #移動掉落物\n player_collide(s) #頭部碰撞偵測\n bucket_collide(s) #籃子碰撞偵測\n if s.y \u003e 1000: reset(s)\n\n# 移動掉落物\ndef move_item(s):\n global score\n if s.status == 0:\n s.y += speed\n if s.status == 1:\n s.y += speed\n if s.status == 2:\n s.x = bucket.x\n s.y += speed / 2\n if s.y \u003e= 700: #完全進入籃子\n score += 1\n reset(s)\n if s.y \u003e= 650 and s.costume_id == 2: #進入一半且為蘑菇\n stop()\n\n# 頭部偵測碰撞\ndef player_collide(s):\n if abs(s.x - player.x) \u003c 100 and abs(s.y - player.y + 150) \u003c 50:\n s.status = 1\n\n# 籃子偵測碰撞\ndef bucket_collide(s):\n if abs(s.x - bucket.x) \u003c 100 and abs(s.y - bucket.y + 50) \u003c 50:\n s.status = 2\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\n","created_at":"2024-08-07T10:33:25.567+08:00","updated_at":"2024-08-29T18:17:58.280+08:00","name":"4_蘋果收割季_預設版","language":"python","screenshot":{"url":"https://cdn5.koding.school/uploads/project/screenshot/812163/6a03bc4f3cec06e5c10be4ecbd1c0a7c.jpg"},"parent_id":4,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":35,"hashid":"rdvsdvy5n","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":18269979,"file_name":"hit.mp3","project_id":812163,"asset_id":744875,"created_at":"2024-08-29T18:17:42.424+08:00","updated_at":"2024-08-29T18:17:42.424+08:00"},{"id":18269980,"file_name":"bgm.wav","project_id":812163,"asset_id":772361,"created_at":"2024-08-29T18:17:42.426+08:00","updated_at":"2024-08-29T18:17:42.426+08:00"},{"id":18269960,"file_name":"rules.png","project_id":812163,"asset_id":772362,"created_at":"2024-08-29T18:17:27.028+08:00","updated_at":"2024-08-29T18:17:27.028+08:00"},{"id":18269961,"file_name":"6.png","project_id":812163,"asset_id":772363,"created_at":"2024-08-29T18:17:27.032+08:00","updated_at":"2024-08-29T18:17:27.032+08:00"},{"id":18269962,"file_name":"7.png","project_id":812163,"asset_id":772364,"created_at":"2024-08-29T18:17:27.035+08:00","updated_at":"2024-08-29T18:17:27.035+08:00"},{"id":18269963,"file_name":"4.png","project_id":812163,"asset_id":772365,"created_at":"2024-08-29T18:17:27.039+08:00","updated_at":"2024-08-29T18:17:27.039+08:00"},{"id":18269964,"file_name":"5.png","project_id":812163,"asset_id":772366,"created_at":"2024-08-29T18:17:27.043+08:00","updated_at":"2024-08-29T18:17:27.043+08:00"},{"id":18269965,"file_name":"2.png","project_id":812163,"asset_id":772367,"created_at":"2024-08-29T18:17:27.047+08:00","updated_at":"2024-08-29T18:17:27.047+08:00"},{"id":18269966,"file_name":"3.png","project_id":812163,"asset_id":772368,"created_at":"2024-08-29T18:17:27.050+08:00","updated_at":"2024-08-29T18:17:27.050+08:00"},{"id":18269967,"file_name":"mushroom.png","project_id":812163,"asset_id":772369,"created_at":"2024-08-29T18:17:27.054+08:00","updated_at":"2024-08-29T18:17:27.054+08:00"},{"id":18269968,"file_name":"orange.png","project_id":812163,"asset_id":772370,"created_at":"2024-08-29T18:17:27.058+08:00","updated_at":"2024-08-29T18:17:27.058+08:00"},{"id":18269969,"file_name":"p_1.png","project_id":812163,"asset_id":772371,"created_at":"2024-08-29T18:17:27.062+08:00","updated_at":"2024-08-29T18:17:27.062+08:00"},{"id":18269970,"file_name":"8.png","project_id":812163,"asset_id":772372,"created_at":"2024-08-29T18:17:27.065+08:00","updated_at":"2024-08-29T18:17:27.065+08:00"},{"id":18269971,"file_name":"9.png","project_id":812163,"asset_id":772373,"created_at":"2024-08-29T18:17:27.069+08:00","updated_at":"2024-08-29T18:17:27.069+08:00"},{"id":18269972,"file_name":"0.png","project_id":812163,"asset_id":772374,"created_at":"2024-08-29T18:17:27.073+08:00","updated_at":"2024-08-29T18:17:27.073+08:00"},{"id":18269973,"file_name":"1.png","project_id":812163,"asset_id":772375,"created_at":"2024-08-29T18:17:27.076+08:00","updated_at":"2024-08-29T18:17:27.076+08:00"},{"id":18269974,"file_name":"p_0.png","project_id":812163,"asset_id":772376,"created_at":"2024-08-29T18:17:27.080+08:00","updated_at":"2024-08-29T18:17:27.080+08:00"},{"id":18269975,"file_name":"apple.png","project_id":812163,"asset_id":772377,"created_at":"2024-08-29T18:17:27.084+08:00","updated_at":"2024-08-29T18:17:27.084+08:00"},{"id":18269976,"file_name":"bg.png","project_id":812163,"asset_id":772378,"created_at":"2024-08-29T18:17:27.089+08:00","updated_at":"2024-08-29T18:17:27.089+08:00"},{"id":18269977,"file_name":"bucket_0.png","project_id":812163,"asset_id":772379,"created_at":"2024-08-29T18:17:27.093+08:00","updated_at":"2024-08-29T18:17:27.093+08:00"},{"id":18269978,"file_name":"bucket_1.png","project_id":812163,"asset_id":772380,"created_at":"2024-08-29T18:17:27.096+08:00","updated_at":"2024-08-29T18:17:27.096+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦