{"id":194472,"student_id":2589,"content":"","created_at":"2020-10-06T18:20:59.369+08:00","updated_at":"2023-03-14T14:37:40.144+08:00","name":"小恐龍大爆走 - 開始後用滑鼠點擊舞台以啟用按鍵,重整畫面即可重新遊戲。","language":"python","screenshot":{"url":null},"parent_id":4,"plugin":"import game #載入遊戲套件\nimport random #載入隨機數套件\n\nground = game.create_sprite('ground.png') #道路街景\ndino = game.create_sprite('dino_0.png', 'dino_1.png') #恐龍\nb1 = game.create_sprite('0.png', '1.png', '2.png', '3.png', '4.png') #1號障礙物\nb2 = game.create_sprite('0.png', '1.png', '2.png', '3.png', '4.png') #2號障礙物\nb3 = game.create_sprite('0.png', '1.png', '2.png', '3.png', '4.png') #3號障礙物\nboard = game.create_sprite('board.png') #計分版\nhint = game.create_sprite('hint.png') #按鍵說明\n\ndino.y = 600\nb1.y = 600\nb2.y = 600\nb3.y = 600\n\ndino.x = 300\nb1.x = 2000\nb2.x = 2500\nb3.x = 3000\n\nvy = 0 #垂直速度\nvx = 10 #水平速度\nscore = 0 #分數\n\ngame.create_sound('bgm.mp3')\n\n#遊戲主迴圈\ndef loop():\n global vx, vy, score #存取函式外變數\n \n if hint.hidden:\n ground.x -= vx\n b1.x -= vx * 1.3\n b2.x -= vx * 1.3\n b3.x -= vx * 1.2\n dino.costume_id = int(score) % 2\n\n if ground.x \u003c= -1200:\n ground.x += 3000\n \n if b1.x \u003c -50:\n b1.x = b3.x + random.randrange(400, 1000) * vx / 10\n b1.costume_id = random.randrange(5)\n \n if b2.x \u003c -50:\n b2.x = b1.x + random.randrange(400, 1000) * vx / 10\n b2.costume_id = random.randrange(5)\n \n if b3.x \u003c -50:\n b3.x = b2.x + random.randrange(400, 1000) * vx / 10\n b3.costume_id = random.randrange(5)\n \n if key.space and dino.y == 600:\n vy = -30\n game.create_sound('jump.ogg')\n \n vy += 2\n dino.y += vy\n if dino.y \u003e 600: dino.y = 600 #恐龍下墜不超過 600 高度\n \n #碰到障礙物就結束遊戲\n if dino.touched(b1) or dino.touched(b2) or dino.touched(b3):\n hint.hidden = False\n \n if hint.hidden:\n score += 1/6\n vx = 10 + score/100\n \n #重新開始\n if key.enter:\n hint.hidden = True\n b1.x = 2000\n b2.x = 2500\n b3.x = 3000\n vx = 10\n score = 0\n \n #每經過 150 次遊戲迴圈就切換天空顏色\n if score % 300 \u003e 150: \n game.set_backdrop('sky_dark.png')\n else:\n game.set_backdrop('sky_light.png')\n\n game.draw_text(int(score), 30, 30, 'black', 60)\n\n\ngame.forever(loop) #重複不斷執行","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":250,"hashid":"882szzz9","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3330115,"file_name":"jump.ogg","project_id":194472,"asset_id":267869,"created_at":"2020-10-06T18:21:18.285+08:00","updated_at":"2020-10-06T18:21:18.285+08:00"},{"id":3330116,"file_name":"milestone.mp3","project_id":194472,"asset_id":267870,"created_at":"2020-10-06T18:21:18.289+08:00","updated_at":"2020-10-06T18:21:18.289+08:00"},{"id":3330117,"file_name":"bgm.mp3","project_id":194472,"asset_id":267871,"created_at":"2020-10-06T18:21:18.410+08:00","updated_at":"2020-10-06T18:21:18.410+08:00"},{"id":3330118,"file_name":"0.png","project_id":194472,"asset_id":267872,"created_at":"2020-10-06T18:21:18.415+08:00","updated_at":"2020-10-06T18:21:18.415+08:00"},{"id":3330119,"file_name":"2.png","project_id":194472,"asset_id":267873,"created_at":"2020-10-06T18:21:18.419+08:00","updated_at":"2020-10-06T18:21:18.419+08:00"},{"id":3330120,"file_name":"3.png","project_id":194472,"asset_id":267874,"created_at":"2020-10-06T18:21:18.422+08:00","updated_at":"2020-10-06T18:21:18.422+08:00"},{"id":3330121,"file_name":"4.png","project_id":194472,"asset_id":267875,"created_at":"2020-10-06T18:21:18.426+08:00","updated_at":"2020-10-06T18:21:18.426+08:00"},{"id":3330122,"file_name":"sky_dark.png","project_id":194472,"asset_id":267876,"created_at":"2020-10-06T18:21:18.430+08:00","updated_at":"2020-10-06T18:21:18.430+08:00"},{"id":3330123,"file_name":"board.png","project_id":194472,"asset_id":267877,"created_at":"2020-10-06T18:21:18.434+08:00","updated_at":"2020-10-06T18:21:18.434+08:00"},{"id":3330124,"file_name":"dino_0.png","project_id":194472,"asset_id":267878,"created_at":"2020-10-06T18:21:18.437+08:00","updated_at":"2020-10-06T18:21:18.437+08:00"},{"id":3330125,"file_name":"dino_1.png","project_id":194472,"asset_id":267879,"created_at":"2020-10-06T18:21:18.441+08:00","updated_at":"2020-10-06T18:21:18.441+08:00"},{"id":3330126,"file_name":"hint.png","project_id":194472,"asset_id":267880,"created_at":"2020-10-06T18:21:18.445+08:00","updated_at":"2020-10-06T18:21:18.445+08:00"},{"id":3330127,"file_name":"bg.png","project_id":194472,"asset_id":267881,"created_at":"2020-10-06T18:21:18.449+08:00","updated_at":"2020-10-06T18:21:18.449+08:00"},{"id":3330128,"file_name":"sky_light.png","project_id":194472,"asset_id":267882,"created_at":"2020-10-06T18:21:18.458+08:00","updated_at":"2020-10-06T18:21:18.458+08:00"},{"id":3330129,"file_name":"ground.png","project_id":194472,"asset_id":267883,"created_at":"2020-10-06T18:21:18.463+08:00","updated_at":"2020-10-06T18:21:18.463+08:00"},{"id":3330130,"file_name":"1.png","project_id":194472,"asset_id":267884,"created_at":"2020-10-06T18:21:18.468+08:00","updated_at":"2020-10-06T18:21:18.468+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦