{"id":183397,"student_id":2589,"content":"","created_at":"2020-08-21T14:37:13.460+08:00","updated_at":"2023-03-14T11:21:25.071+08:00","name":"蒙地卡羅求 PI - 開始後用滑鼠點擊舞台以啟用按鍵,重整畫面即可重新遊戲。","language":"javascript","screenshot":{"url":null},"parent_id":3,"plugin":"Game.set({\n autoRendering: false, //改成手動繪圖\n width: 1000, //設定場景寬度\n height: 1000, //設定場景高度\n});\n\n//將遊戲場景塗成白色\npen.size = 0;\npen.fillColor = 'white';\npen.drawRect(0, 0, 1000, 1000);\n\nvar red = 0; //紅色的點\nvar orange = 0; // 橘色的點\n\nforever(loop); //重複不斷執行遊戲迴圈\n\n//遊戲主迴圈\nfunction loop () {\n for (var i = 0; i \u003c 1000; i++) {\n var x = Math.random()*1000;\n var y = Math.random()*1000;\n var d = Math.sqrt((x - 500)*(x - 500) + (y - 500)*(y - 500));\n\n if (d \u003c 500) {\n pen.fillColor = 'red';\n red++;\n } else {\n pen.fillColor = 'orange';\n orange++;\n }\n pen.drawRect(x, y, 1, 1);\n }\n\n pen.fillColor = 'white';\n pen.drawRect(0, 0, 400, 50);\n print(4*red/(red + orange), 10, 10, 'black', 30);\n};\n\n","description":null,"note":null,"status":"public","like_student_ids":[24008,16868],"is_featured":false,"views":279,"hashid":"meys3mdv","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
1:1:1
1:1
full
幫助
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦