{"id":169486,"student_id":10,"content":"// 設定背景:\nsetBackdrop(\"bar.png\");\n/*\nvar table = createSprite(\"table0.png\");\ntable.scale = 1;\ntable.x = 445;\ntable.y = 500;\n*/\nvar table = createSprite(\"table.png\");\ntable.scale = 1;\n\n// 播放音檔:\n//sound.play(\"Gymnopedie_No_1.mp3\");\nvar clock = 0;\nvar customers = [];\nvar beerMugs = [];\nvar backCustomers = [];\nvar score = 0;\nvar level = 1;\nvar speed = 0.5;\nvar interval = 200;\n\n//beertender\nvar koding = createSprite([\"koding.png\", \"kodingWithBeer.png\"]);\nkoding.costumeId = 0;\nkoding.x = 1200;\nkoding.y = 100;\nkoding.direction = 100;\n\nfunction kodingGoDown(){\n if (koding.y \u003c 400) {\n koding.y += 100;\n }\n}\n\nfunction kodingGoUp(){\n if (koding.y \u003e 100) {\n koding.y -= 100;\n }\n}\non(\"keydown\", \"down\", kodingGoDown);\non(\"keydown\", \"up\", kodingGoUp);\n\nfunction kodingGetBeer(){\n koding.costumeId = 1;\n}\n\nfunction kodingSendBeer(){\n koding.costumeId = 0;\n createBeer(koding.y);\n}\n\non(\"keydown\", \"space\", kodingGetBeer);\non(\"keyup\", \"space\", kodingSendBeer);\n/*\n//老師示範\nwhen(\"keydown\", \"down\", function() {\n if (koding.y \u003c 400) {\n koding.y += 100;\n }\n});\n//學生練習\nwhen(\"keydown\", \"up\", function() {\n if (koding.y \u003e 100) {\n koding.y -= 100;\n }\n});\n\nwhen(\"keydown\", \"space\", function() {\n koding.costumeId = 1;\n //待:只觸發一次嗎?\n //createBeer(koding.y);\n});\n\nwhen(\"keyup\", \"space\", function() {\n koding.costumeId = 0;\n createBeer(koding.y);\n});\n*/\nvar count = 0;\nfunction createBeer(yloc) {\n var beer = createSprite([\"beer.png\",\"broken.jpg\"]);\n //beer.scale = 0.15;\n beer.x = 500;\n beer.y = yloc+20;\n beerMugs.push(beer);\n\n beer.on(\"touch\", customers, function(target) {\n target.costumeId = 1;\n backCustomers.push(target);\n score += 1;\n beer.hidden = true;\n beer.destroy();\n });\n\n}\n\nfunction moveBeerMugs() {\n for (var i = 0; i \u003c beerMugs.length; i++) {\n if (beerMugs[i].hidden == false){\n beerMugs[i].x -= 2*speed;\n }\n }\n}\n\nfunction createCustomer() {\n if (clock%interval == 0) {\n var customer = createSprite([\"customer.png\", \"customerWithBeer.png\"]);\n customer.costumeId = 0;\n customer.x = 50;\n customer.y = 100*Math.ceil(Math.random()*4);\n //customer.direction = 0;\n customers.push(customer);\n }\n}\n\nfunction moveCustomers() {\n for (var i = 0; i \u003c customers.length; i++) {\n customers[i].x += speed;\n }\n for (var i = 0; i \u003c backCustomers.length; i++) {\n backCustomers[i].x -= 3*speed;\n if (backCustomers[i].x \u003c 50) {\n backCustomers[i].destroy();\n }\n }\n}\n\nfunction checkGameOver() {\n for (var i = 0; i \u003c beerMugs.length; i++) {\n if (beerMugs[i].x \u003c 20) {\n beerMugs[i].costumeId = 1;\n gameOver();\n }\n }\n \n for(var i = 0; i \u003c customers.length; i++){\n if(customers[i].x \u003e 500){\n gameOver();\n }\n }\n}\n\nfunction gameOver() {\n //gameOverLogo.hidden = false;\n //startBtn.hidden = false;\n drawText(\"GAME OVER\", 150, 220, 'white', 60);\n stop();\n}\n\n// 不停地執行...\nforever(function() {\n drawText(\"score:\", 500, 10, 'white', 20);\n drawText(score, 600, 10, 'white', 20);\n drawText(\"Level:\", 10, 10, 'white', 20);\n drawText(level, 80, 10, 'white', 20);\n drawText(\"interval:\", 210, 10, 'white', 20);\n drawText(interval, 310, 10, 'white', 20);\n createCustomer();\n moveCustomers();\n moveBeerMugs();\n checkGameOver();\n /*\n if(key.up){\n if (koding.y \u003e 100) {\n koding.y -= 100;\n }\n }\n if(key.down){\n if (koding.y \u003c 400) {\n koding.y += 100;\n }\n }\n */\n clock += 1;\n if(clock%500 == 0){\n speed += 0.2;\n level += 1;\n if(interval\u003e20){\n interval -= 30;\n }\n }\n});","created_at":"2020-07-22T18:21:49.934+08:00","updated_at":"2020-07-22T18:27:09.696+08:00","name":"beertender_teacher 副本","language":"javascript","screenshot":{"url":"https://cdn2.koding.school/uploads/project/screenshot/169486/60b7576b88a6abb3962f63196879edb5.jpg"},"parent_id":169140,"plugin":"Game.set({width: 1200, height: 900})","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":235,"hashid":"yeys6yyw","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":2929177,"file_name":"table0.png","project_id":169486,"asset_id":241088,"created_at":"2020-07-22T18:21:49.940+08:00","updated_at":"2020-07-22T18:21:49.940+08:00"},{"id":2929178,"file_name":"table.png","project_id":169486,"asset_id":240971,"created_at":"2020-07-22T18:21:49.941+08:00","updated_at":"2020-07-22T18:21:49.941+08:00"},{"id":2929179,"file_name":"table_red.png","project_id":169486,"asset_id":240970,"created_at":"2020-07-22T18:21:49.942+08:00","updated_at":"2020-07-22T18:21:49.942+08:00"},{"id":2929180,"file_name":"table_4.png","project_id":169486,"asset_id":240969,"created_at":"2020-07-22T18:21:49.943+08:00","updated_at":"2020-07-22T18:21:49.943+08:00"},{"id":2929181,"file_name":"table_3.png","project_id":169486,"asset_id":240968,"created_at":"2020-07-22T18:21:49.944+08:00","updated_at":"2020-07-22T18:21:49.944+08:00"},{"id":2929182,"file_name":"table_2.png","project_id":169486,"asset_id":240967,"created_at":"2020-07-22T18:21:49.945+08:00","updated_at":"2020-07-22T18:21:49.945+08:00"},{"id":2929183,"file_name":"table_1.png","project_id":169486,"asset_id":240966,"created_at":"2020-07-22T18:21:49.946+08:00","updated_at":"2020-07-22T18:21:49.946+08:00"},{"id":2929184,"file_name":"reference-01.png","project_id":169486,"asset_id":240965,"created_at":"2020-07-22T18:21:49.946+08:00","updated_at":"2020-07-22T18:21:49.946+08:00"},{"id":2929185,"file_name":"kodingWithBeer.png","project_id":169486,"asset_id":240964,"created_at":"2020-07-22T18:21:49.947+08:00","updated_at":"2020-07-22T18:21:49.947+08:00"},{"id":2929186,"file_name":"koding.png","project_id":169486,"asset_id":240963,"created_at":"2020-07-22T18:21:49.948+08:00","updated_at":"2020-07-22T18:21:49.948+08:00"},{"id":2929187,"file_name":"customerWithBeer.png","project_id":169486,"asset_id":240962,"created_at":"2020-07-22T18:21:49.949+08:00","updated_at":"2020-07-22T18:21:49.949+08:00"},{"id":2929188,"file_name":"customer.png","project_id":169486,"asset_id":240961,"created_at":"2020-07-22T18:21:49.950+08:00","updated_at":"2020-07-22T18:21:49.950+08:00"},{"id":2929189,"file_name":"beer.png","project_id":169486,"asset_id":240960,"created_at":"2020-07-22T18:21:49.951+08:00","updated_at":"2020-07-22T18:21:49.951+08:00"},{"id":2929190,"file_name":"bar.png","project_id":169486,"asset_id":240959,"created_at":"2020-07-22T18:21:49.952+08:00","updated_at":"2020-07-22T18:21:49.952+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦