{"id":863585,"student_id":1981,"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\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-10-15T16:12:13.669+08:00","updated_at":"2024-10-15T16:12:32.220+08:00","name":"4_蘋果收割季_預設版 副本","language":"python","screenshot":{"url":"https://cdn3.koding.school/uploads/project/screenshot/863585/6a03bc4f3cec06e5c10be4ecbd1c0a7c.jpg"},"parent_id":830323,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":3,"hashid":"5j3s86vv3","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":18911882,"file_name":"rules.png","project_id":863585,"asset_id":771998,"created_at":"2024-10-15T16:12:13.675+08:00","updated_at":"2024-10-15T16:12:13.675+08:00"},{"id":18911883,"file_name":"6.png","project_id":863585,"asset_id":771999,"created_at":"2024-10-15T16:12:13.676+08:00","updated_at":"2024-10-15T16:12:13.676+08:00"},{"id":18911884,"file_name":"7.png","project_id":863585,"asset_id":772000,"created_at":"2024-10-15T16:12:13.677+08:00","updated_at":"2024-10-15T16:12:13.677+08:00"},{"id":18911885,"file_name":"4.png","project_id":863585,"asset_id":772001,"created_at":"2024-10-15T16:12:13.678+08:00","updated_at":"2024-10-15T16:12:13.678+08:00"},{"id":18911886,"file_name":"5.png","project_id":863585,"asset_id":772002,"created_at":"2024-10-15T16:12:13.679+08:00","updated_at":"2024-10-15T16:12:13.679+08:00"},{"id":18911887,"file_name":"2.png","project_id":863585,"asset_id":772003,"created_at":"2024-10-15T16:12:13.680+08:00","updated_at":"2024-10-15T16:12:13.680+08:00"},{"id":18911888,"file_name":"3.png","project_id":863585,"asset_id":772004,"created_at":"2024-10-15T16:12:13.681+08:00","updated_at":"2024-10-15T16:12:13.681+08:00"},{"id":18911889,"file_name":"mushroom.png","project_id":863585,"asset_id":772005,"created_at":"2024-10-15T16:12:13.682+08:00","updated_at":"2024-10-15T16:12:13.682+08:00"},{"id":18911890,"file_name":"orange.png","project_id":863585,"asset_id":772006,"created_at":"2024-10-15T16:12:13.683+08:00","updated_at":"2024-10-15T16:12:13.683+08:00"},{"id":18911891,"file_name":"p_1.png","project_id":863585,"asset_id":772007,"created_at":"2024-10-15T16:12:13.684+08:00","updated_at":"2024-10-15T16:12:13.684+08:00"},{"id":18911892,"file_name":"8.png","project_id":863585,"asset_id":772008,"created_at":"2024-10-15T16:12:13.685+08:00","updated_at":"2024-10-15T16:12:13.685+08:00"},{"id":18911893,"file_name":"9.png","project_id":863585,"asset_id":772009,"created_at":"2024-10-15T16:12:13.686+08:00","updated_at":"2024-10-15T16:12:13.686+08:00"},{"id":18911894,"file_name":"0.png","project_id":863585,"asset_id":772010,"created_at":"2024-10-15T16:12:13.687+08:00","updated_at":"2024-10-15T16:12:13.687+08:00"},{"id":18911895,"file_name":"1.png","project_id":863585,"asset_id":772011,"created_at":"2024-10-15T16:12:13.688+08:00","updated_at":"2024-10-15T16:12:13.688+08:00"},{"id":18911896,"file_name":"p_0.png","project_id":863585,"asset_id":772012,"created_at":"2024-10-15T16:12:13.689+08:00","updated_at":"2024-10-15T16:12:13.689+08:00"},{"id":18911897,"file_name":"apple.png","project_id":863585,"asset_id":772013,"created_at":"2024-10-15T16:12:13.690+08:00","updated_at":"2024-10-15T16:12:13.690+08:00"},{"id":18911898,"file_name":"bg.png","project_id":863585,"asset_id":772014,"created_at":"2024-10-15T16:12:13.691+08:00","updated_at":"2024-10-15T16:12:13.691+08:00"},{"id":18911899,"file_name":"bucket_0.png","project_id":863585,"asset_id":772015,"created_at":"2024-10-15T16:12:13.692+08:00","updated_at":"2024-10-15T16:12:13.692+08:00"},{"id":18911900,"file_name":"bucket_1.png","project_id":863585,"asset_id":772016,"created_at":"2024-10-15T16:12:13.693+08:00","updated_at":"2024-10-15T16:12:13.693+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦