{"id":193733,"student_id":2589,"content":"sound.play(\"bgm.mp3\")\n// 設定背景與桌子:\nsetBackdrop(\"bar.png\");\nvar table_1 = createSprite(\"table_1.png\");\nvar table_2 = createSprite(\"table_2.png\");\nvar table_3 = createSprite(\"table_3.png\");\nvar table_4 = createSprite(\"table_4.png\");\n//第一排客人要在table_1後面,第二排客人要在table_2後面......\n//因此需要編排圖層,4張桌子跟4排客人加起來有8層\n//圖層編號是1, 3, 5, 7\ntable_1.layer = 2;\ntable_2.layer = 4;\ntable_3.layer = 6;\ntable_4.layer = 8;\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\", \"kodingUpset.png\"]);\nkoding.costumeId = 0;\nkoding.x = 950;\nkoding.y = 220;\nkoding.direction = 100;\n\nfunction kodingGoDown(){\n if (koding.y \u003c 850) {\n koding.y += 180;\n }\n}\n\nfunction kodingGoUp(){\n if (koding.y \u003e 250) {\n koding.y -= 180;\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\nfunction createBeer(yloc) {\n var beer = createSprite([\"beer.png\",\"broken.png\"]);\n beer.x = 800;\n beer.y = yloc+20\n beer.layer = 10\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\", \"customerAngry.png\"]);\n customer.costumeId = 0;\n //table=0~3\n table = Math.ceil(Math.random()*4);\n //客人要在桌子後面,所以桌子的圖層編號是1, 3, 5, 7\n customer.layer = 2*table-1;\n \n //視覺效果上,每一層入口有些傾斜,所以初始x值會不同\n //但是這樣程式碼會很醜,要判斷消失位置也很困難,故作罷\n /*\n //table_1:350-55, table_2:350-55-55, ...\n customer.x = 350-55*table;\n */\n customer.x = 100;\n //客人的位置比酒保偏上20,所以從220變成200\n //table_1:200, table_2:200+180, table_3: 200+180+180...\n customer.y = 20+180*table;\n customers.push(customer);\n //x跟y的關係:x=350-55*(y-20)/180 = \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 100) {\n backCustomers[i].destroy();\n }\n }\n}\n\nfunction checkGameOver() {\n for (var i = 0; i \u003c beerMugs.length; i++) {\n //理論上每個桌子撞到牆面的水平位置不一樣\n //但是要一一偵測牆面在哪太麻煩,先作罷\n if(beerMugs[i].x\u003c100){\n /*\n //用下面的方式雖然程式碼簡潔,\n //但是會有bug,而且碰撞偵測超慢,只好作罷\n //可惜沒有顏色碰撞偵測......\n if (!(beerMugs[i].touched(table_1) ||\n beerMugs[i].touched(table_2) ||\n beerMugs[i].touched(table_3) ||\n beerMugs[i].touched(table_4))){\n */\n beerMugs[i].costumeId = 1;\n sound.play(\"beerHit.mp3\");\n gameOver();\n }\n }\n \n for(var i = 0; i \u003c customers.length; i++){\n if(customers[i].x \u003e 850){\n customers[i].costumeId = 2;\n gameOver();\n }\n }\n}\n\nfunction gameOver() {\n koding.costumeId = 2;\n drawText(\"GAME OVER\", 300, 350, 'white', 100);\n stop();\n}\n\n// 不停地執行...\nforever(function() {\n drawText(\"Score:\", 900, 50, 'white', 50);\n drawText(score, 1080, 50, 'white', 50);\n drawText(\"Level:\", 50, 50, 'white', 50);\n drawText(level, 200, 50, 'white', 50);\n drawText(\"Interval:\", 400, 50, 'white', 50);\n drawText(interval, 600, 50, 'white', 50);\n createCustomer();\n moveCustomers();\n moveBeerMugs();\n checkGameOver();\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-09-22T18:57:32.036+08:00","updated_at":"2020-09-22T18:57:50.674+08:00","name":"beertender_teacher","language":"javascript","screenshot":{"url":null},"parent_id":2,"plugin":"Game.set({width: 1200, height: 900})","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":72,"hashid":"36ys6vwz","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[{"id":3313262,"file_name":"bgm.mp3","project_id":193733,"asset_id":264921,"created_at":"2020-09-22T18:57:50.614+08:00","updated_at":"2020-09-22T18:57:50.614+08:00"},{"id":3313263,"file_name":"beerHit.mp3","project_id":193733,"asset_id":264922,"created_at":"2020-09-22T18:57:50.620+08:00","updated_at":"2020-09-22T18:57:50.620+08:00"},{"id":3313264,"file_name":"kodingUpset.png","project_id":193733,"asset_id":264923,"created_at":"2020-09-22T18:57:50.624+08:00","updated_at":"2020-09-22T18:57:50.624+08:00"},{"id":3313265,"file_name":"customerAngry.png","project_id":193733,"asset_id":264924,"created_at":"2020-09-22T18:57:50.628+08:00","updated_at":"2020-09-22T18:57:50.628+08:00"},{"id":3313266,"file_name":"broken.png","project_id":193733,"asset_id":264925,"created_at":"2020-09-22T18:57:50.631+08:00","updated_at":"2020-09-22T18:57:50.631+08:00"},{"id":3313267,"file_name":"table_1.png","project_id":193733,"asset_id":264926,"created_at":"2020-09-22T18:57:50.636+08:00","updated_at":"2020-09-22T18:57:50.636+08:00"},{"id":3313268,"file_name":"table_4.png","project_id":193733,"asset_id":264927,"created_at":"2020-09-22T18:57:50.639+08:00","updated_at":"2020-09-22T18:57:50.639+08:00"},{"id":3313269,"file_name":"table_red.png","project_id":193733,"asset_id":264928,"created_at":"2020-09-22T18:57:50.644+08:00","updated_at":"2020-09-22T18:57:50.644+08:00"},{"id":3313270,"file_name":"table_2.png","project_id":193733,"asset_id":264929,"created_at":"2020-09-22T18:57:50.647+08:00","updated_at":"2020-09-22T18:57:50.647+08:00"},{"id":3313271,"file_name":"table_3.png","project_id":193733,"asset_id":264930,"created_at":"2020-09-22T18:57:50.651+08:00","updated_at":"2020-09-22T18:57:50.651+08:00"},{"id":3313272,"file_name":"kodingWithBeer.png","project_id":193733,"asset_id":264931,"created_at":"2020-09-22T18:57:50.654+08:00","updated_at":"2020-09-22T18:57:50.654+08:00"},{"id":3313273,"file_name":"koding.png","project_id":193733,"asset_id":264932,"created_at":"2020-09-22T18:57:50.658+08:00","updated_at":"2020-09-22T18:57:50.658+08:00"},{"id":3313274,"file_name":"customerWithBeer.png","project_id":193733,"asset_id":264933,"created_at":"2020-09-22T18:57:50.662+08:00","updated_at":"2020-09-22T18:57:50.662+08:00"},{"id":3313275,"file_name":"customer.png","project_id":193733,"asset_id":264934,"created_at":"2020-09-22T18:57:50.665+08:00","updated_at":"2020-09-22T18:57:50.665+08:00"},{"id":3313276,"file_name":"beer.png","project_id":193733,"asset_id":264935,"created_at":"2020-09-22T18:57:50.669+08:00","updated_at":"2020-09-22T18:57:50.669+08:00"},{"id":3313277,"file_name":"bar.png","project_id":193733,"asset_id":264936,"created_at":"2020-09-22T18:57:50.672+08:00","updated_at":"2020-09-22T18:57:50.672+08:00"}]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦