{"id":787520,"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', 'p_2.png')\nrules = create_sprite('rules.png')\nnumbers = ['0.png', '1.png', '2.png', '3.png', '4.png', '5.png', '6.png', '7.png', '8.png', '9.png']\nn1 = create_sprite(numbers) #百位數\nn2 = create_sprite(numbers) #十位數\nn3 = create_sprite(numbers) #個位數\n\nbg.move_to(600, 900)\nplayer.move_to(600, 700 + 900)\nbucket.move_to(710, 700 + 900)\nbucket_cover.move_to(710, 700 + 900)\nn1.move_to(200, 70)\nn2.move_to(125, 70)\nn3.move_to(50, 70)\n\nbg.layer = -2\nplayer.layer = 1\nbucket.layer = -1\nbucket_cover.layer = 2\nrules.layer = 3\n\nfruits = [] #存放水果角色\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 s.vy = 0\n s.vx = 0\n s.combo = 0\n \n# 創造多個水果\nfor i in range(15):\n s = create_sprite('apple.png', 'orange.png', 'mushroom.png')\n reset(s)\n fruits.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 speed += 0.0005\n update_player()\n update_fruit()\n update_scores()\n\n# 捲動背景 \ndef scroll():\n bg.y -= 3\n player.y -= 3\n bucket.y -= 3\n bucket_cover.y -= 3\n\n# 更新水果\ndef update_fruit():\n global score\n for s in fruits:\n move(s)\n touched_head(s)\n touched_bucket(s)\n if s.y \u003e 1000: reset(s)\n\n# 移動水果 \ndef move(s):\n global score\n if s.status == 0:\n s.y += speed\n if s.status == 1:\n s.y += s.vy\n s.vy += 1\n s.x += s.vx\n s.direction += s.vx\n if s.status == 2:\n s.x = bucket.x\n s.y += speed / 2\n if s.y \u003e= 700:\n score += 1 + s.combo\n reset(s)\n \n# 偵測頭部碰撞\ndef touched_head(s):\n if abs(s.x - player.x) \u003c 100 and abs(s.y - player.y + 150) \u003c 50:\n s.status = 1\n s.vy = -15\n s.vx = (s.x - player.x) / 20\n s.combo += 1\n\n# 偵測籃子碰撞\ndef touched_bucket(s):\n if abs(s.x - bucket.x) \u003c 100 and abs(s.y - bucket.y + 50) \u003c 50:\n s.status = 2\n if s.costume_id == 2: stop()\n \n# 更新玩家\ndef update_player():\n if key.right:\n player.x += 10\n bucket.x += 10\n bucket_cover.x += 10\n if key.left:\n player.x -= 10\n bucket.x -= 10\n bucket_cover.x -= 10\n player.costume_id = (player.x // 100) % 2 + 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\n","created_at":"2024-07-08T10:39:57.177+08:00","updated_at":"2024-07-08T16:01:19.226+08:00","name":"採收蘋果_完整版","language":"python","screenshot":{"url":"https://cdn9.koding.school/uploads/project/screenshot/787520/4de88c5aa8c0bf7481d2e39178cbb25e.jpg"},"parent_id":783083,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":58,"hashid":"wdksm4v2q","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":17512799,"file_name":"apple.png","project_id":787520,"asset_id":752512,"created_at":"2024-07-08T10:39:57.183+08:00","updated_at":"2024-07-08T10:39:57.183+08:00"},{"id":17512800,"file_name":"bg.png","project_id":787520,"asset_id":752513,"created_at":"2024-07-08T10:39:57.185+08:00","updated_at":"2024-07-08T10:39:57.185+08:00"},{"id":17512801,"file_name":"bucket_0.png","project_id":787520,"asset_id":752514,"created_at":"2024-07-08T10:39:57.187+08:00","updated_at":"2024-07-08T10:39:57.187+08:00"},{"id":17512802,"file_name":"bucket_1.png","project_id":787520,"asset_id":752515,"created_at":"2024-07-08T10:39:57.188+08:00","updated_at":"2024-07-08T10:39:57.188+08:00"},{"id":17512803,"file_name":"mushroom.png","project_id":787520,"asset_id":752516,"created_at":"2024-07-08T10:39:57.188+08:00","updated_at":"2024-07-08T10:39:57.188+08:00"},{"id":17512804,"file_name":"orange.png","project_id":787520,"asset_id":752517,"created_at":"2024-07-08T10:39:57.189+08:00","updated_at":"2024-07-08T10:39:57.189+08:00"},{"id":17512805,"file_name":"4.png","project_id":787520,"asset_id":750586,"created_at":"2024-07-08T10:39:57.190+08:00","updated_at":"2024-07-08T10:39:57.190+08:00"},{"id":17512806,"file_name":"5.png","project_id":787520,"asset_id":750587,"created_at":"2024-07-08T10:39:57.192+08:00","updated_at":"2024-07-08T10:39:57.192+08:00"},{"id":17512807,"file_name":"p_0.png","project_id":787520,"asset_id":752518,"created_at":"2024-07-08T10:39:57.192+08:00","updated_at":"2024-07-08T10:39:57.192+08:00"},{"id":17512808,"file_name":"p_1.png","project_id":787520,"asset_id":752519,"created_at":"2024-07-08T10:39:57.194+08:00","updated_at":"2024-07-08T10:39:57.194+08:00"},{"id":17512809,"file_name":"p_2.png","project_id":787520,"asset_id":752520,"created_at":"2024-07-08T10:39:57.195+08:00","updated_at":"2024-07-08T10:39:57.195+08:00"},{"id":17512810,"file_name":"rules.png","project_id":787520,"asset_id":752521,"created_at":"2024-07-08T10:39:57.195+08:00","updated_at":"2024-07-08T10:39:57.195+08:00"},{"id":17512811,"file_name":"6.png","project_id":787520,"asset_id":750588,"created_at":"2024-07-08T10:39:57.196+08:00","updated_at":"2024-07-08T10:39:57.196+08:00"},{"id":17512812,"file_name":"7.png","project_id":787520,"asset_id":750589,"created_at":"2024-07-08T10:39:57.197+08:00","updated_at":"2024-07-08T10:39:57.197+08:00"},{"id":17512813,"file_name":"8.png","project_id":787520,"asset_id":750590,"created_at":"2024-07-08T10:39:57.198+08:00","updated_at":"2024-07-08T10:39:57.198+08:00"},{"id":17512814,"file_name":"9.png","project_id":787520,"asset_id":750591,"created_at":"2024-07-08T10:39:57.199+08:00","updated_at":"2024-07-08T10:39:57.199+08:00"},{"id":17512815,"file_name":"0.png","project_id":787520,"asset_id":750582,"created_at":"2024-07-08T10:39:57.200+08:00","updated_at":"2024-07-08T10:39:57.200+08:00"},{"id":17512816,"file_name":"1.png","project_id":787520,"asset_id":750583,"created_at":"2024-07-08T10:39:57.201+08:00","updated_at":"2024-07-08T10:39:57.201+08:00"},{"id":17512817,"file_name":"2.png","project_id":787520,"asset_id":750584,"created_at":"2024-07-08T10:39:57.202+08:00","updated_at":"2024-07-08T10:39:57.202+08:00"},{"id":17512818,"file_name":"3.png","project_id":787520,"asset_id":750585,"created_at":"2024-07-08T10:39:57.203+08:00","updated_at":"2024-07-08T10:39:57.203+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦