{"id":196929,"student_id":2589,"content":"","created_at":"2020-10-19T16:53:52.213+08:00","updated_at":"2023-03-14T14:38:15.068+08:00","name":"逃離洞窟 - 開始後用滑鼠點擊舞台以啟用按鍵,重整畫面即可重新遊戲。","language":"python","screenshot":{"url":"https://cdn4.koding.school/uploads/project/screenshot/196929/89edcce60b8890776f43b51e69f48ea4.jpg"},"parent_id":4,"plugin":"game.set({'width': 1200, 'height': 900})\n\nimport math #載入數學工具包\nimport game #載入遊戲框架\n\ngame.set_backdrop('bg.png') #設定背景圖\nmaze = game.create_sprite('1.png', '2.png', '3.png', '4.png', 'youwin.png') #遊戲關卡\nwheel = game.create_sprite('wheel.png') #轉盤\nt1 = game.create_sprite('t1.png') #紅色目標\nt2 = game.create_sprite('t2.png') #黃色目標\nt3 = game.create_sprite('t3.png') #藍色目標\nt4 = game.create_sprite('t4.png') #綠色目標\nplayer = game.create_sprite('player.png') #發光的小精靈\n\nactive = False #是否開始跟隨滑鼠\ncount = 0 #計時器\n\nt1.move_to(1200, 900) #右下角\nt2.move_to(0, 900) #左下角\nt3.move_to(1200, 0) #右上角\nt4.move_to(0, 0) #左上角\nplayer.move_to(50, 50)\n\ngame.create_sound('bgm.mp3', True) #不斷播放背景音樂\n\n# 遊戲迴圈\ndef loop ():\n global active, count\n\n wheel.direction = wheel.direction + 1\n t1.direction = t1.direction - 0.2\n t2.direction = t2.direction - 0.2\n t3.direction = t3.direction - 0.2\n t4.direction = t4.direction - 0.2\n\n #如果開始跟隨模式,就不斷設定玩家位置到滑鼠位置\n if active == True:\n player.x = game.cursor.x\n player.y = game.cursor.y\n count = count + 1 #移動中才會計時\n \n #如果玩家碰到滑鼠\n if player.touched(cursor) == True:\n active = True #開始跟隨滑鼠\n \n if player.touched(t1) == True:\n maze.costume_id = 1 #切換到第二關\n \n if player.touched(t2) == True:\n maze.costume_id = 2 #切換到第三關\n \n if player.touched(t3) == True:\n maze.costume_id = 3 #切換到第四關\n \n if player.touched(t4) == True and maze.costume_id == 3:\n maze.costume_id = 4 #切換到遊戲勝利\n wheel.hidden = True #隱藏轉盤\n game.stop() #停止遊戲\n \n # 如果玩家碰到地圖或者碰到中間轉盤就重置位置\n if player.touched(maze) == True or player.touched(wheel) == True:\n active = False #停止跟隨滑鼠\n if maze.costume_id == 0:\n player.move_to(50, 50)\n \n if maze.costume_id == 1:\n player.move_to(1150, 850)\n \n if maze.costume_id == 2:\n player.move_to(50, 850)\n \n if maze.costume_id == 3:\n player.move_to(1150, 50)\n \n game.create_sound('hit.ogg')\n \n game.drawText('花費時間' + str(count//60) + '秒', 500, 30, 'white', 30, 'Comic Sans MS')\n\n\ngame.forever(loop) #不斷重複執行遊戲迴圈\n","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":72,"hashid":"ej9s2d5rg","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3377937,"file_name":"3.png","project_id":196929,"asset_id":270848,"created_at":"2020-10-19T16:54:04.489+08:00","updated_at":"2020-10-19T16:54:04.489+08:00"},{"id":3377938,"file_name":"bgm.mp3","project_id":196929,"asset_id":270849,"created_at":"2020-10-19T16:54:04.508+08:00","updated_at":"2020-10-19T16:54:04.508+08:00"},{"id":3377939,"file_name":"hit.ogg","project_id":196929,"asset_id":270850,"created_at":"2020-10-19T16:54:04.513+08:00","updated_at":"2020-10-19T16:54:04.513+08:00"},{"id":3377940,"file_name":"youwin.png","project_id":196929,"asset_id":270851,"created_at":"2020-10-19T16:54:04.518+08:00","updated_at":"2020-10-19T16:54:04.518+08:00"},{"id":3377941,"file_name":"wheel.png","project_id":196929,"asset_id":270852,"created_at":"2020-10-19T16:54:04.522+08:00","updated_at":"2020-10-19T16:54:04.522+08:00"},{"id":3377942,"file_name":"t4.png","project_id":196929,"asset_id":270853,"created_at":"2020-10-19T16:54:04.526+08:00","updated_at":"2020-10-19T16:54:04.526+08:00"},{"id":3377943,"file_name":"t3.png","project_id":196929,"asset_id":270854,"created_at":"2020-10-19T16:54:04.530+08:00","updated_at":"2020-10-19T16:54:04.530+08:00"},{"id":3377944,"file_name":"t2.png","project_id":196929,"asset_id":270855,"created_at":"2020-10-19T16:54:04.534+08:00","updated_at":"2020-10-19T16:54:04.534+08:00"},{"id":3377945,"file_name":"t1.png","project_id":196929,"asset_id":270856,"created_at":"2020-10-19T16:54:04.540+08:00","updated_at":"2020-10-19T16:54:04.540+08:00"},{"id":3377946,"file_name":"player.png","project_id":196929,"asset_id":270857,"created_at":"2020-10-19T16:54:04.544+08:00","updated_at":"2020-10-19T16:54:04.544+08:00"},{"id":3377947,"file_name":"bg.png","project_id":196929,"asset_id":270858,"created_at":"2020-10-19T16:54:04.548+08:00","updated_at":"2020-10-19T16:54:04.548+08:00"},{"id":3377948,"file_name":"4.png","project_id":196929,"asset_id":270859,"created_at":"2020-10-19T16:54:04.553+08:00","updated_at":"2020-10-19T16:54:04.553+08:00"},{"id":3377949,"file_name":"2.png","project_id":196929,"asset_id":270860,"created_at":"2020-10-19T16:54:04.557+08:00","updated_at":"2020-10-19T16:54:04.557+08:00"},{"id":3377950,"file_name":"1.png","project_id":196929,"asset_id":270861,"created_at":"2020-10-19T16:54:04.562+08:00","updated_at":"2020-10-19T16:54:04.562+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦