ステージ
【HTML】index.html
<div id="stage">
<div class="score">00000000</div>
<!--#stage--></div>
【JS】config.js
//ゲーム上で使う設定のパラメーターを定義
class Config {
static puyoImageWidth = 40; //ぷよ画像の幅
static puyoImageHeight = 40; //ぷよ画像の高
static stageCols = 6; //ステージの横の個数
static stageRows = 12; //ステージの盾の個数
static stageBackgroundColor = '#11213b'; //ステージの背景色
}
【JS】game.js
// 起動された時に呼ばれる関数を登録する
window.addEventListener("load", () =>{
initialize();
});
function initialize(){
//ステージを準備する
Stage.initialize();
}
【JS】stage.js
//ステージ
class Stage{
static stageElement = null;
static initialize(){
Stage.stageElement = document.getElementById("stage");
Stage.stageElement.style.width = Config.puyoImageWidth * Config.stageCols + 'px';
Stage.stageElement.style.height = Config.puyoImageHeight * Config.stageRows + 'px';
Stage.stageElement.style.backgroundColor = Config.stageBackgroundColor;
}
}