{"id":204880,"student_id":2589,"content":"var bgm = sound.play('bgm.mp3');\n\n//人物初始化\nvar teacher = createSprite([\"back_1.png\", \"back_2.png\", \"turn_1.png\", \"turn_2.png\", \"angry.png\"]);\nteacher.x = 850;\nteacher.y = 400;\n\nvar koding = createSprite([\"awake.png\",\"doze.png\"]);\nkoding.x = 600;\nkoding.y = 700;\n\nvar boy = createSprite([\"boy_1.png\", \"boy_2.png\", \"boy_3.png\", \"boy_4.png\"]);\nboy.x = 1000;\nboy.y = 700;\nboy.hidden = true;\n\nvar girl = createSprite([\"girl_1.png\", \"girl_2.png\", \"girl_3.png\"]);\ngirl.x = 200;\ngirl.y = 700;\ngirl.hidden = true;\n\n//按鈕初始化\nvar startBtn = createSprite(\"startBtn.png\");\nstartBtn.x = 400;\nstartBtn.y = 400;\n\nvar zzzBtn = createSprite(\"zzzBtn.png\");\nzzzBtn.y = 750;\nzzzBtn.hidden = true;\n\n//按鈕觸發行為\nvar isDozing = false;\n\nstartBtn.on(\"click\", function(){\n startBtn.hidden = true;\n zzzBtn.hidden = false;\n})\n\nzzzBtn.on(\"mousedown\", function(){\n isDozing = true;\n koding.costumeId = 1;\n})\n\nzzzBtn.on(\"mouseup\", function(){\n isDozing = false;\n koding.costumeId = 0;\n})\n\nvar clock = 0;\nvar score = 0;\nvar level = 1;\n\n//老師動作切換\nfunction moveTeacher(){\n var s = Math.random();\n if(s\u003c0.5){\n if(teacher.costumeId\u003e0){\n teacher.costumeId-=1;\n }\n }else{\n if(teacher.costumeId\u003c4){\n teacher.costumeId+=1;\n }\n }\n}\n\n//男同學動作切換\nfunction moveBoy(){\n var s = Math.random();\n if(s\u003c0.5){\n if(boy.costumeId\u003e0){\n boy.costumeId-=1;\n }\n }else{\n if(boy.costumeId\u003c3){\n boy.costumeId+=1;\n }\n }\n}\n\n//女同學動作切換\nfunction moveGirl(){\n var s = Math.random();\n if(s\u003c0.5){\n if(girl.costumeId\u003e0){\n girl.costumeId-=1;\n }\n }else{\n if(girl.costumeId\u003c2){\n girl.costumeId+=1;\n }\n }\n}\n\nvar pen = pen;\n\n//繪製能量值外框\nfunction drawEdge(){\n pen.size = 10;\n pen.color = \"black\";\n pen.fillColor = \"white\";\n pen.drawRect(500, 800, 200, 50);\n}\n\n//繪製能量值\nfunction drawScore(){\n pen.fillColor = \"red\";\n pen.drawRect(500, 800, score, 50);\n}\n\n//加分\nfunction addScore(){\n if(isDozing){\n score += 0.5;\n //console.log(score);\n }\n}\n\n//檢查遊戲是否結束\nfunction checkGameOver(){\n if(isDozing \u0026\u0026 (teacher.costumeId == 4 || boy.costumeId == 3 || girl.costumeId == 2)){\n drawText(\"Game Over\", 300, 250, \"yellow\", 80);\n stop();\n }\n}\n\n//檢查關卡切換並顯示關卡\nfunction checkLevel(){\n if(score\u003e200){\n level += 1;\n score = 0;\n if(level == 2){\n boy.hidden = false; \n } else if(level == 3){\n girl.hidden = false; \n } else {\n drawText(\"You win!\", 300, 250, \"yellow\", 80);\n stop();\n }\n }\n if(level \u003c 4){\n drawText(\"Level \" + level, 300, 120, \"white\", 50);\n }\n}\n\n// 不停地執行...\nforever(function(){\n if(startBtn.hidden == false){\n setBackdrop(\"tutorial.jpg\");\n } else {\n setBackdrop(\"classroom.jpg\");\n clock += 1;\n if(clock%40 == 0 \u0026\u0026 level\u003e0){\n moveTeacher();\n }\n if(clock%60 == 0 \u0026\u0026 level\u003e1){\n moveBoy();\n }\n if(clock%80 == 0 \u0026\u0026 level\u003e2){\n moveGirl();\n }\n addScore();\n drawEdge();\n drawScore();\n checkGameOver();\n checkLevel();\n }\n});","created_at":"2020-11-18T17:40:28.831+08:00","updated_at":"2020-11-18T17:40:56.751+08:00","name":"dozeOff_teacher","language":"javascript","screenshot":{"url":"https://cdn0.koding.school/uploads/project/screenshot/204880/d8e41cb80e0f9c283f63110b7d912e3f.jpg"},"parent_id":2,"plugin":"Game.set({width: 1200, height: 900})","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":80,"hashid":"9ygsppner","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3549026,"file_name":"bgm.mp3","project_id":204880,"asset_id":282705,"created_at":"2020-11-18T17:40:39.651+08:00","updated_at":"2020-11-18T17:40:39.651+08:00"},{"id":3549027,"file_name":"boy_4.png","project_id":204880,"asset_id":282706,"created_at":"2020-11-18T17:40:39.656+08:00","updated_at":"2020-11-18T17:40:39.656+08:00"},{"id":3549028,"file_name":"startBtn.png","project_id":204880,"asset_id":282707,"created_at":"2020-11-18T17:40:39.660+08:00","updated_at":"2020-11-18T17:40:39.660+08:00"},{"id":3549029,"file_name":"back_2.png","project_id":204880,"asset_id":282708,"created_at":"2020-11-18T17:40:39.664+08:00","updated_at":"2020-11-18T17:40:39.664+08:00"},{"id":3549030,"file_name":"boy_3.png","project_id":204880,"asset_id":282709,"created_at":"2020-11-18T17:40:39.668+08:00","updated_at":"2020-11-18T17:40:39.668+08:00"},{"id":3549031,"file_name":"awake.png","project_id":204880,"asset_id":282710,"created_at":"2020-11-18T17:40:39.672+08:00","updated_at":"2020-11-18T17:40:39.672+08:00"},{"id":3549032,"file_name":"angry.png","project_id":204880,"asset_id":282711,"created_at":"2020-11-18T17:40:39.675+08:00","updated_at":"2020-11-18T17:40:39.675+08:00"},{"id":3549033,"file_name":"girl_1.png","project_id":204880,"asset_id":282712,"created_at":"2020-11-18T17:40:39.679+08:00","updated_at":"2020-11-18T17:40:39.679+08:00"},{"id":3549034,"file_name":"girl_3.png","project_id":204880,"asset_id":282713,"created_at":"2020-11-18T17:40:39.683+08:00","updated_at":"2020-11-18T17:40:39.683+08:00"},{"id":3549035,"file_name":"boy_2.png","project_id":204880,"asset_id":282714,"created_at":"2020-11-18T17:40:39.687+08:00","updated_at":"2020-11-18T17:40:39.687+08:00"},{"id":3549036,"file_name":"girl_2.png","project_id":204880,"asset_id":282715,"created_at":"2020-11-18T17:40:39.691+08:00","updated_at":"2020-11-18T17:40:39.691+08:00"},{"id":3549037,"file_name":"turn_1.png","project_id":204880,"asset_id":282716,"created_at":"2020-11-18T17:40:39.694+08:00","updated_at":"2020-11-18T17:40:39.694+08:00"},{"id":3549038,"file_name":"zzzBtn.png","project_id":204880,"asset_id":282717,"created_at":"2020-11-18T17:40:39.698+08:00","updated_at":"2020-11-18T17:40:39.698+08:00"},{"id":3549039,"file_name":"doze.png","project_id":204880,"asset_id":282718,"created_at":"2020-11-18T17:40:39.702+08:00","updated_at":"2020-11-18T17:40:39.702+08:00"},{"id":3549040,"file_name":"turn_2.png","project_id":204880,"asset_id":282719,"created_at":"2020-11-18T17:40:39.706+08:00","updated_at":"2020-11-18T17:40:39.706+08:00"},{"id":3549041,"file_name":"boy_1.png","project_id":204880,"asset_id":282720,"created_at":"2020-11-18T17:40:39.710+08:00","updated_at":"2020-11-18T17:40:39.710+08:00"},{"id":3549042,"file_name":"back_1.png","project_id":204880,"asset_id":282721,"created_at":"2020-11-18T17:40:39.713+08:00","updated_at":"2020-11-18T17:40:39.713+08:00"},{"id":3549043,"file_name":"tutorial.jpg","project_id":204880,"asset_id":282722,"created_at":"2020-11-18T17:40:39.720+08:00","updated_at":"2020-11-18T17:40:39.720+08:00"},{"id":3549044,"file_name":"classroom.jpg","project_id":204880,"asset_id":282723,"created_at":"2020-11-18T17:40:39.725+08:00","updated_at":"2020-11-18T17:40:39.725+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦