{"id":150220,"student_id":10,"content":"import math\nimport random\nimport datetime\n\n\nsetBackdrop('black')\n\nceiling = createSprite('ceiling.png')\nceiling.x = 320\nceiling.y = 8\nceiling.layer = 1\n\nleft_wall = createSprite('wall.png')\nright_wall = createSprite('wall.png')\nleft_wall.x = 130\nright_wall.x = 510\n\nplayer = createSprite(['player_1.png', 'player_2.png', 'player_3.png', 'player_4.png', 'player_5.png'])\nplayer.y = 50\n\ncreateSound('bgm.mp3', True)\n\n# 初始化變數\nlife = 10\nfloor = 0\nstairs = []\nvy = 0\ntouchOn = None\ntime = 0\nlastTime = 0\nhit = None\nclock = 0\n\n#init stairs\n# 1-3,1-4\nfor i in range(8):\n stair = createSprite(['conveyor_left.png', 'conveyor_right.png', 'normal.png', 'nails.png', 'trampoline.png', 'fake.png'])\n stair.costumeId = random.randrange(6)\n stair.x = random.random()*250 + 200\n stair.y = i*80 + 550\n stair.idx = i\n stairs.append(stair)\n\n\ndef loop ():\n global clock, hit, life, floor, touchOn, time, lastTime, clock\n \n if life \u003e 0 and player.y \u003c 480:\n setBackdrop('black')\n updatePlayer()\n updateStairs()\n updateCostume()\n checkTouchedCeiling()\n flashBackground()\n\n else:\n setBackdrop('red')\n stop()\n createSound('gg.mp3')\n \n drawText('分數:' + str(floor), 10, 10, 'white', 20)\n drawText('生命:' + str(life), 10, 40, 'while', 20)\n\n\ndef updatePlayer():\n global clock, hit, life, floor, touchOn, time, lastTime, clock, vy \n \n # 1-1\n if key.left and not player.touched(left_wall):\n player.x -= 3\n \n if key.right and not player.touched(right_wall):\n player.x += 3\n \n # 1-2\n vy += 0.1\n player.y += vy\n\n\n# 1-5\ndef updateStairs():\n global clock, hit, life, floor, touchOn, time, lastTime, clock, vy\n \n for i in range(len(stairs)):\n stairs[i].y -= 2\n # 1-6\n if stairs[i].y \u003c -10:\n stairs[i].costumeId = random.randrange(6)\n stairs[i].y += 640\n floor += 1\n stairs[i].hidden = False\n\n \n\n# 2-3\ndef checkTouchedCeiling():\n global clock, hit, life, floor, touchOn, time, lastTime, clock, vy\n \n time = datetime.datetime.now()\n\n if player.touched(ceiling) and time - lastTime \u003e 3000:\n life -= 3\n vy = 0\n lastTime = time\n hit = True\n\n# 2-4\ndef flashBackground():\n global clock, hit, life, floor, touchOn, time, lastTime, clock, vy\n \n if hit:\n setBackdrop('red')\n hit = False\n createSound('flash.mp3')\n \n\n# 2-6,2-7\ndef updateCostume():\n global clock, hit, life, floor, touchOn, time, lastTime, clock, vy\n \n clock += 1\n if clock%6 == 0:\n if key.right:\n if player.costumeId == 1:\n player.costumeId = 2\n else:\n player.costumeId = 1\n \n if key.left:\n if player.costumeId == 3:\n player.costumeId = 4\n else:\n player.costumeId = 3\n\n if key.right == False and key.left == False:\n player.costumeId = 0\n \n\n# 1-7\ndef onStair(s):\n global clock, hit, life, floor, touchOn, time, lastTime, clock, vy\n \n vy = 0\n player.y = s.y - 20\n\n # 2-1,2-2\n if s.costumeId == 0:\n player.x -= 2\n \n if s.costumeId == 1:\n player.x += 2\n \n if s.costumeId == 4:\n vy = -6\n createSound('jump.mp3')\n \n if s.costumeId == 2 and s.idx != touchOn:\n life += 1\n \n if s.costumeId == 3 and s.idx != touchOn:\n life -= 3\n hit = True\n \n if s.costumeId == 5 and s.idx != touchOn:\n s.hidden = True\n\n touchOn = s.idx\n\n\nplayer.when('touch', stairs, onStair)\nforever(loop)","created_at":"2020-05-22T11:33:41.876+08:00","updated_at":"2020-05-25T11:20:31.342+08:00","name":"小朋友下樓梯","language":"python","screenshot":{"url":"https://cdn4.koding.school/uploads/project/screenshot/150220/c16e5d9d6615a491704f1f993c713b87.jpg"},"parent_id":4,"plugin":"game.set({'width': 640, 'height': 480})","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":247,"hashid":"d5mse94g","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":2607081,"file_name":"conveyor_left.png","project_id":150220,"asset_id":23069,"created_at":"2020-05-22T11:33:57.400+08:00","updated_at":"2020-05-22T11:33:57.400+08:00"},{"id":2607082,"file_name":"conveyor_right.png","project_id":150220,"asset_id":23070,"created_at":"2020-05-22T11:33:57.402+08:00","updated_at":"2020-05-22T11:33:57.402+08:00"},{"id":2607087,"file_name":"nails.png","project_id":150220,"asset_id":23074,"created_at":"2020-05-22T11:33:58.100+08:00","updated_at":"2020-05-22T11:33:58.100+08:00"},{"id":2607088,"file_name":"normal.png","project_id":150220,"asset_id":23072,"created_at":"2020-05-22T11:33:58.102+08:00","updated_at":"2020-05-22T11:33:58.102+08:00"},{"id":2607093,"file_name":"player_5.png","project_id":150220,"asset_id":33496,"created_at":"2020-05-22T11:33:58.741+08:00","updated_at":"2020-05-22T11:33:58.741+08:00"},{"id":2607094,"file_name":"trampoline.png","project_id":150220,"asset_id":23073,"created_at":"2020-05-22T11:33:58.743+08:00","updated_at":"2020-05-22T11:33:58.743+08:00"},{"id":2607079,"file_name":"bgm.mp3","project_id":150220,"asset_id":36477,"created_at":"2020-05-22T11:33:57.153+08:00","updated_at":"2020-05-22T11:33:57.153+08:00"},{"id":2607080,"file_name":"ceiling.png","project_id":150220,"asset_id":23076,"created_at":"2020-05-22T11:33:57.155+08:00","updated_at":"2020-05-22T11:33:57.155+08:00"},{"id":2607095,"file_name":"wall.png","project_id":150220,"asset_id":23626,"created_at":"2020-05-22T11:33:58.996+08:00","updated_at":"2020-05-22T11:33:58.996+08:00"},{"id":2607089,"file_name":"player_1.png","project_id":150220,"asset_id":23075,"created_at":"2020-05-22T11:33:58.316+08:00","updated_at":"2020-05-22T11:33:58.316+08:00"},{"id":2607090,"file_name":"player_2.png","project_id":150220,"asset_id":33495,"created_at":"2020-05-22T11:33:58.318+08:00","updated_at":"2020-05-22T11:33:58.318+08:00"},{"id":2607083,"file_name":"fake.png","project_id":150220,"asset_id":23620,"created_at":"2020-05-22T11:33:57.643+08:00","updated_at":"2020-05-22T11:33:57.643+08:00"},{"id":2607084,"file_name":"flash.mp3","project_id":150220,"asset_id":36476,"created_at":"2020-05-22T11:33:57.645+08:00","updated_at":"2020-05-22T11:33:57.645+08:00"},{"id":2607085,"file_name":"gg.mp3","project_id":150220,"asset_id":36479,"created_at":"2020-05-22T11:33:57.889+08:00","updated_at":"2020-05-22T11:33:57.889+08:00"},{"id":2607086,"file_name":"jump.mp3","project_id":150220,"asset_id":36478,"created_at":"2020-05-22T11:33:57.890+08:00","updated_at":"2020-05-22T11:33:57.890+08:00"},{"id":2607091,"file_name":"player_3.png","project_id":150220,"asset_id":33493,"created_at":"2020-05-22T11:33:58.529+08:00","updated_at":"2020-05-22T11:33:58.529+08:00"},{"id":2607092,"file_name":"player_4.png","project_id":150220,"asset_id":33494,"created_at":"2020-05-22T11:33:58.532+08:00","updated_at":"2020-05-22T11:33:58.532+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦