{"id":168940,"student_id":3232,"content":"import game\nimport random #載入產生隨機數的套件\n\ngame.create_sprite('bg_0.png') #背景圖1\nc1 = game.create_sprite(\"cloud_1.png\") #創造角色\nc2 = game.create_sprite(\"cloud_2.png\")\nc3 = game.create_sprite(\"cloud_3.png\")\nc1.x = 700\nc1.y = 300\nc2.x = 200\nc2.y = 150\nc3.x = 1100\nc3.y = 50\n# 建立雲朵\n\ngame.create_sprite('bg_1.png') #背景圖2\n# 建立牛仔\np1 = game.create_sprite(\"p1_0.png\", \"p1_1.png\", \"p1_2.png\", \"p1_3.png\")\np2 = game.create_sprite(\"p2_0.png\", \"p2_1.png\", \"p2_2.png\", \"p2_3.png\")\ninfo = game.create_sprite(\"info.png\") #創造角色\np1.hidden = True\np2.hidden = True\n\n\n# 建立遊戲說明\n\nsteps = -1#移動的剩餘步數\ngame_over = True #遊戲狀態\nbgm = game.create_sound('bgm.mp3')\nshot = game.create_sound('shot.wav')\nshot.mute(True)\na = 0\n# 角色初始化\n\ndef start():\n global steps, game_over\n \n if game_over == True:\n bgm.mute(False)\n p1.x = 600\n p1.y = 700\n p2.x = 600\n p2.y = 700\n p1.costume_id = 0\n p2.costume_id = 0\n steps = random.randint(100, 500)\n info.hidden = True\n p1.hidden = False\n p2.hidden = False\n game_over = False\n \n\n \n# 遊戲主迴圈\n\n\ndef loop ():\n global steps, game_over\n \n if c1.x \u003c -200:\n c1.x += 1500\n else:\n c1.x -= 0.3\n if c2.x \u003c -200:\n c2.x += 1500\n else:\n c2.x -= 0.5\n if c3.x \u003c -200:\n c3.x += 1500\n else:\n c3.x -= 0.7 \n# 牛仔向左右移動\n if steps \u003e 0:\n p1.step_forward(-1)\n p2.step_forward(1)\n steps -= 1\n elif steps == 0:\n p1.costume_id = 1\n p2.costume_id = 1\n steps = -1\n bgm.mute(True)\n# 牛仔射擊\n if key.space and p1.costume_id == 1:\n shot = game.create_sound('shot.wav')\n shot.mute(False)\n p1.costume_id = 2\n p2.costume_id = 3\n game_over = True\n if key.ent and p2.costume_id == 1:\n shot = game.create_sound('shot.wav')\n shot.mute(False)\n p1.costume_id = 3\n p2.costume_id = 2\n game_over = True\n# 遊戲開始、重新開始\n\n# 雲朵移動\n\n\n\ngame.forever(loop) #不斷執行遊戲迴圈\ngame.on(\"keydown\", \"r\", start)","created_at":"2020-07-21T10:47:53.610+08:00","updated_at":"2020-07-21T14:38:39.322+08:00","name":"牛仔大對決_S 副本","language":"python","screenshot":{"url":"https://cdn1.koding.school/uploads/project/screenshot/168940/78a193c3fc46fabc4daa54f721327297.jpg"},"parent_id":162840,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":43,"hashid":"882s8eqg","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":2922548,"file_name":"bg_0.png","project_id":168940,"asset_id":192575,"created_at":"2020-07-21T10:47:53.615+08:00","updated_at":"2020-07-21T10:47:53.615+08:00"},{"id":2922549,"file_name":"bg_1.png","project_id":168940,"asset_id":192574,"created_at":"2020-07-21T10:47:53.616+08:00","updated_at":"2020-07-21T10:47:53.616+08:00"},{"id":2922550,"file_name":"bgm.mp3","project_id":168940,"asset_id":172549,"created_at":"2020-07-21T10:47:53.617+08:00","updated_at":"2020-07-21T10:47:53.617+08:00"},{"id":2922551,"file_name":"cloud_1.png","project_id":168940,"asset_id":192679,"created_at":"2020-07-21T10:47:53.618+08:00","updated_at":"2020-07-21T10:47:53.618+08:00"},{"id":2922552,"file_name":"cloud_2.png","project_id":168940,"asset_id":192577,"created_at":"2020-07-21T10:47:53.619+08:00","updated_at":"2020-07-21T10:47:53.619+08:00"},{"id":2922553,"file_name":"cloud_3.png","project_id":168940,"asset_id":192578,"created_at":"2020-07-21T10:47:53.620+08:00","updated_at":"2020-07-21T10:47:53.620+08:00"},{"id":2922554,"file_name":"info.png","project_id":168940,"asset_id":192685,"created_at":"2020-07-21T10:47:53.621+08:00","updated_at":"2020-07-21T10:47:53.621+08:00"},{"id":2922555,"file_name":"p1_0.png","project_id":168940,"asset_id":192671,"created_at":"2020-07-21T10:47:53.622+08:00","updated_at":"2020-07-21T10:47:53.622+08:00"},{"id":2922556,"file_name":"p1_1.png","project_id":168940,"asset_id":192672,"created_at":"2020-07-21T10:47:53.623+08:00","updated_at":"2020-07-21T10:47:53.623+08:00"},{"id":2922557,"file_name":"p1_2.png","project_id":168940,"asset_id":192673,"created_at":"2020-07-21T10:47:53.624+08:00","updated_at":"2020-07-21T10:47:53.624+08:00"},{"id":2922558,"file_name":"p1_3.png","project_id":168940,"asset_id":192674,"created_at":"2020-07-21T10:47:53.624+08:00","updated_at":"2020-07-21T10:47:53.624+08:00"},{"id":2922559,"file_name":"p2_0.png","project_id":168940,"asset_id":192675,"created_at":"2020-07-21T10:47:53.625+08:00","updated_at":"2020-07-21T10:47:53.625+08:00"},{"id":2922560,"file_name":"p2_1.png","project_id":168940,"asset_id":192676,"created_at":"2020-07-21T10:47:53.626+08:00","updated_at":"2020-07-21T10:47:53.626+08:00"},{"id":2922561,"file_name":"p2_2.png","project_id":168940,"asset_id":192677,"created_at":"2020-07-21T10:47:53.627+08:00","updated_at":"2020-07-21T10:47:53.627+08:00"},{"id":2922562,"file_name":"p2_3.png","project_id":168940,"asset_id":192678,"created_at":"2020-07-21T10:47:53.628+08:00","updated_at":"2020-07-21T10:47:53.628+08:00"},{"id":2922563,"file_name":"shot.wav","project_id":168940,"asset_id":17859,"created_at":"2020-07-21T10:47:53.629+08:00","updated_at":"2020-07-21T10:47:53.629+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
截圖
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦