{"id":163278,"student_id":1404,"content":"import random\nimport time\nimport game\n\nbg_1 = createSprite('bg_1.png')\nbg_2 = createSprite('bg_2.png')\n# 建立準星\ntarget = game.create_sprite(\"target.png\") #創造角色\nreward = createSprite('r0.png','r1.png','r2.png','r3.png','r4.png','r5.png','r6.png','r7.png','r8.png','r9.png','r10.png')\nnumber = createSprite('n0.png','n1.png','n2.png','n3.png','n4.png','n5.png')\ncreateSound('bgm.mp3')\n\nnumber.opacity = 0.7\nbg_1.layer = 1\nnumber.layer = 2\ntarget.layer = 3\nreward.layer = 4\nreward.hidden = True\nnumber.hidden = True\ntarget.scale = 0.8\n\nballoons = []\nscores = 0\ncnt = 0 #計算以執行的迴圈個數\nstartTime = time.time()\nendTime = startTime + 30\n\ndef loop ():\n global balloons, target, scores, cnt, endTime\n\n # 準星跟著滑鼠\n target.x = cursor.x\n target.y = cursor.y\n \n # 建立氣球\n cnt = cnt + 1\n if cnt % 10 == 0:\n b = game.create_sprite('a.png', 'b.png', 'c.png', 'd.png',\n 'e.png', 'g.png', 'f.png') #創造角色\n b.costume_id = random.randint(0, 6)\n b.y = 1000\n b.x = random.randint(100, 1100)\n balloons.append(b)\n \n # 氣球上升\n for balloon in balloons:\n if balloon.costume_id == 0:\n balloon.y -= 3\n if balloon.costume_id == 1:\n balloon.y -= 5\n if balloon.costume_id == 2:\n balloon.y -= 7\n if balloon.costume_id == 3 or balloon.costume_id == 4:\n balloon.y -= 8\n if balloon.costume_id == 5: #炸彈\n balloon.y -= 7\n if balloon.costume_id == 6: #時間\n balloon.y -= 6\n # 射擊及計分\n if balloon.touched(target) and cursor.is_down:\n if balloon.costume_id == 0:\n scores += 1\n elif balloon.costume_id == 1:\n scores += 10\n elif balloon.costume_id == 2:\n scores += 5\n elif balloon.costume_id == 3:\n scores *= 2\n elif balloon.costume_id == 4:\n scores /= 2\n elif balloon.costume_id == 5: #時間\n endTime += 3\n elif balloon.costume_id == 6: #炸彈\n endTime = time.time()\n # print(\"------BOMB-------\")\n balloon.destroy()\n \n drawText(scores, 60, 20, 'white', 40)\n # 時間倒數\n leftTime = endTime - time.time()\n if leftTime \u003c 0:\n reward.hidden = False\n if scores \u003e 10000000000:\n reward.costume_id = 0\n elif scores \u003e 1000000000:\n reward.costume_id = 1\n elif scores \u003e 100000000:\n reward.costume_id = 2\n elif scores \u003e 10000000:\n reward.costume_id = 3\n elif scores \u003e 1000000:\n reward.costume_id = 4\n elif scores \u003e 100000:\n reward.costume_id = 5\n elif scores \u003e 10000:\n reward.costume_id = 6\n elif scores \u003e 1000:\n reward.costume_id = 7\n elif scores \u003e 100:\n reward.costume_id = 8\n elif scores \u003e 10:\n reward.costume_id = 9\n else:\n reward.costume_id = 10\n \n game.stop()\n # 遊玩結果\n \nforever(loop)\n\n\n# import random\n# import time\n\n# bg_1 = createSprite('bg_1.png')\n# bg_2 = createSprite('bg_2.png')\n# target = createSprite('target.png')\n# reward = createSprite('r0.png','r1.png','r2.png','r3.png','r4.png','r5.png','r6.png','r7.png','r8.png','r9.png','r10.png')\n# number = createSprite('n0.png','n1.png','n2.png','n3.png','n4.png','n5.png')\n# createSound('bgm.mp3')\n\n# number.opacity = 0.7\n# bg_1.layer = 1\n# number.layer = 2\n# target.layer = 3\n# reward.layer = 4\n# reward.hidden = True\n# number.hidden = True\n\n# clock = 0\n# scores = 0\n# balloons = []\n# endTime = time.time() + 60\n\n# def loop ():\n # global\n# global clock, scores, endTime\n\n # 準星跟著滑鼠\n# target.x = cursor.x\n# target.y = cursor.y\n\n# clock += 1\n# if clock%10 == 0:\n # 建立氣球\n# b = createSprite('a.png', 'b.png', 'c.png', 'd.png', 'e.png', 'g.png', 'f.png')\n# rand = random.randint(0, 6)\n# if rand == 0:\n# b.costumeId = 0\n# elif rand == 1:\n# b.costumeId = 1\n# elif rand == 2:\n# b.costumeId = 2\n# elif rand == 3:\n# b.costumeId = 3\n# elif rand == 4:\n# b.costumeId = 4\n# elif rand == 5:\n# b.costumeId = 5\n# else:\n# b.costumeId = 6\n# b.y = 1000\n# b.x = random.random()*1000 + 100\n# balloons.append(b)\n # 氣球上升\n# for b in balloons:\n# if b.costumeId == 0:\n# b.y -= 3\n# if b.costumeId == 1:\n# b.y -= 5\n# if b.costumeId == 2:\n# b.y -= 7\n# if b.costumeId == 3:\n# b.y -= 8\n# if b.costumeId == 4:\n# b.y -= 8\n# if b.costumeId == 5:\n# b.y -= 7\n# if b.costumeId == 6:\n# b.y -= 6\n # 射擊及計分\n# if cursor.isDown and b.touched(cursor):\n# if b.costumeId == 0:\n# scores += 1 \n# if b.costumeId == 1:\n# scores += 10 \n# if b.costumeId == 2:\n# scores += 5 \n# if b.costumeId == 3:\n# scores *= 2 \n# if b.costumeId == 4:\n# scores /= 2 \n# if b.costumeId == 5:\n# endTime += 3\n# if b.costumeId == 6:\n# endTime = time.time() \n# b.destroy()\n \n# sound.play('shot.mp3')\n \n# drawText(scores, 60, 20, 'white', 40)\n # 時間倒數\n# t = endTime - time.time()\n# if t \u003c= 5:\n# number.hidden = False\n# if t \u003c= 0:\n# number.costumeId = 0\n# elif t \u003c= 1:\n# number.costumeId = 1\n# elif t \u003c= 2:\n# number.costumeId = 2\n# elif t \u003c= 3:\n# number.costumeId = 3\n# elif t \u003c= 4:\n# number.costumeId = 4\n# elif t \u003c= 5:\n# number.costumeId = 5\n \n # 遊玩結果\n# if t \u003c -1:\n# reward.hidden = False\n# if scores \u003e 10000000000:\n# reward.costumeId = 0\n# elif scores \u003e 1000000000:\n# reward.costumeId = 1\n# elif scores \u003e 100000000:\n# reward.costumeId = 2\n# elif scores \u003e 10000000:\n# reward.costumeId = 3\n# elif scores \u003e 1000000:\n# reward.costumeId = 4\n# elif scores \u003e 100000:\n# reward.costumeId = 5\n# elif scores \u003e 10000:\n# reward.costumeId = 6\n# elif scores \u003e 1000:\n# reward.costumeId = 7\n# elif scores \u003e 100:\n# reward.costumeId = 8\n# elif scores \u003e 10:\n# reward.costumeId = 9\n# else:\n# reward.costumeId = 10\n# stop()\n \n# forever(loop)","created_at":"2020-07-09T11:28:47.255+08:00","updated_at":"2020-07-23T09:08:43.771+08:00","name":"射擊氣球_S 副本","language":"python","screenshot":{"url":"https://cdn5.koding.school/uploads/project/screenshot/163278/7614b30bd686c9e4f3eb1e4fdd630ce2.jpg"},"parent_id":162850,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":73,"hashid":"kdms5ew8","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":2836627,"file_name":"a.png","project_id":163278,"asset_id":199819,"created_at":"2020-07-09T11:28:47.261+08:00","updated_at":"2020-07-09T11:28:47.261+08:00"},{"id":2836628,"file_name":"b.png","project_id":163278,"asset_id":198394,"created_at":"2020-07-09T11:28:47.262+08:00","updated_at":"2020-07-09T11:28:47.262+08:00"},{"id":2836629,"file_name":"bg_1.png","project_id":163278,"asset_id":199814,"created_at":"2020-07-09T11:28:47.263+08:00","updated_at":"2020-07-09T11:28:47.263+08:00"},{"id":2836630,"file_name":"bg_2.png","project_id":163278,"asset_id":199815,"created_at":"2020-07-09T11:28:47.264+08:00","updated_at":"2020-07-09T11:28:47.264+08:00"},{"id":2836631,"file_name":"bgm.mp3","project_id":163278,"asset_id":113696,"created_at":"2020-07-09T11:28:47.265+08:00","updated_at":"2020-07-09T11:28:47.265+08:00"},{"id":2836632,"file_name":"c.png","project_id":163278,"asset_id":198397,"created_at":"2020-07-09T11:28:47.266+08:00","updated_at":"2020-07-09T11:28:47.266+08:00"},{"id":2836633,"file_name":"circle.png","project_id":163278,"asset_id":198061,"created_at":"2020-07-09T11:28:47.267+08:00","updated_at":"2020-07-09T11:28:47.267+08:00"},{"id":2836634,"file_name":"d.png","project_id":163278,"asset_id":199816,"created_at":"2020-07-09T11:28:47.268+08:00","updated_at":"2020-07-09T11:28:47.268+08:00"},{"id":2836635,"file_name":"e.png","project_id":163278,"asset_id":199817,"created_at":"2020-07-09T11:28:47.269+08:00","updated_at":"2020-07-09T11:28:47.269+08:00"},{"id":2836636,"file_name":"f.png","project_id":163278,"asset_id":199818,"created_at":"2020-07-09T11:28:47.270+08:00","updated_at":"2020-07-09T11:28:47.270+08:00"},{"id":2836637,"file_name":"g.png","project_id":163278,"asset_id":199810,"created_at":"2020-07-09T11:28:47.271+08:00","updated_at":"2020-07-09T11:28:47.271+08:00"},{"id":2836638,"file_name":"n0.png","project_id":163278,"asset_id":199872,"created_at":"2020-07-09T11:28:47.272+08:00","updated_at":"2020-07-09T11:28:47.272+08:00"},{"id":2836639,"file_name":"n1.png","project_id":163278,"asset_id":199873,"created_at":"2020-07-09T11:28:47.273+08:00","updated_at":"2020-07-09T11:28:47.273+08:00"},{"id":2836640,"file_name":"n2.png","project_id":163278,"asset_id":199874,"created_at":"2020-07-09T11:28:47.274+08:00","updated_at":"2020-07-09T11:28:47.274+08:00"},{"id":2836641,"file_name":"n3.png","project_id":163278,"asset_id":199875,"created_at":"2020-07-09T11:28:47.274+08:00","updated_at":"2020-07-09T11:28:47.274+08:00"},{"id":2836642,"file_name":"n4.png","project_id":163278,"asset_id":199876,"created_at":"2020-07-09T11:28:47.275+08:00","updated_at":"2020-07-09T11:28:47.275+08:00"},{"id":2836643,"file_name":"n5.png","project_id":163278,"asset_id":199877,"created_at":"2020-07-09T11:28:47.276+08:00","updated_at":"2020-07-09T11:28:47.276+08:00"},{"id":2836644,"file_name":"pointer.png","project_id":163278,"asset_id":198063,"created_at":"2020-07-09T11:28:47.277+08:00","updated_at":"2020-07-09T11:28:47.277+08:00"},{"id":2836645,"file_name":"r0.png","project_id":163278,"asset_id":199857,"created_at":"2020-07-09T11:28:47.278+08:00","updated_at":"2020-07-09T11:28:47.278+08:00"},{"id":2836646,"file_name":"r1.png","project_id":163278,"asset_id":199858,"created_at":"2020-07-09T11:28:47.279+08:00","updated_at":"2020-07-09T11:28:47.279+08:00"},{"id":2836647,"file_name":"r2.png","project_id":163278,"asset_id":199859,"created_at":"2020-07-09T11:28:47.280+08:00","updated_at":"2020-07-09T11:28:47.280+08:00"},{"id":2836648,"file_name":"r3.png","project_id":163278,"asset_id":199860,"created_at":"2020-07-09T11:28:47.281+08:00","updated_at":"2020-07-09T11:28:47.281+08:00"},{"id":2836649,"file_name":"r4.png","project_id":163278,"asset_id":199861,"created_at":"2020-07-09T11:28:47.282+08:00","updated_at":"2020-07-09T11:28:47.282+08:00"},{"id":2836650,"file_name":"r5.png","project_id":163278,"asset_id":199862,"created_at":"2020-07-09T11:28:47.283+08:00","updated_at":"2020-07-09T11:28:47.283+08:00"},{"id":2836651,"file_name":"r6.png","project_id":163278,"asset_id":199863,"created_at":"2020-07-09T11:28:47.284+08:00","updated_at":"2020-07-09T11:28:47.284+08:00"},{"id":2836652,"file_name":"r7.png","project_id":163278,"asset_id":199864,"created_at":"2020-07-09T11:28:47.284+08:00","updated_at":"2020-07-09T11:28:47.284+08:00"},{"id":2836653,"file_name":"r8.png","project_id":163278,"asset_id":199865,"created_at":"2020-07-09T11:28:47.286+08:00","updated_at":"2020-07-09T11:28:47.286+08:00"},{"id":2836654,"file_name":"r9.png","project_id":163278,"asset_id":199866,"created_at":"2020-07-09T11:28:47.286+08:00","updated_at":"2020-07-09T11:28:47.286+08:00"},{"id":2836655,"file_name":"r10.png","project_id":163278,"asset_id":199879,"created_at":"2020-07-09T11:28:47.287+08:00","updated_at":"2020-07-09T11:28:47.287+08:00"},{"id":2836656,"file_name":"shot.mp3","project_id":163278,"asset_id":172349,"created_at":"2020-07-09T11:28:47.288+08:00","updated_at":"2020-07-09T11:28:47.288+08:00"},{"id":2836657,"file_name":"target.png","project_id":163278,"asset_id":199868,"created_at":"2020-07-09T11:28:47.289+08:00","updated_at":"2020-07-09T11:28:47.289+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦