gameOfLive
1)次のコードで、変数を作成する理由は何function gameOfLife()
ですか?
2)とは何gol
ですか?配列のように見えますが、構文やその呼び方に慣れていません。
私はhttp://sixfoottallrabbit.co.uk/gameoflife/を勉強しています
if (!window.gameOfLife) var gameOfLife = function() {
var gol = {
body: null,
canvas: null,
context: null,
grids: [],
mouseDown: false,
interval: null,
control: null,
moving: -1,
clickToGive: -1,
table: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(''),
tableBack: null,
init: function(width, height) {
gol.body = document.getElementsByTagName('body')[0];
gol.canvas = document.createElement('canvas');
if (gol.canvas.getContext) {
gol.context = gol.canvas.getContext('2d');
document.getElementById('content').appendChild(gol.canvas);
gol.canvas.width = width;
gol.canvas.height = height;
gol.canvas.style.marginLeft = "8px";
gol.control = document.getElementById('gridcontrol');
gol.canvas.onmousedown = gol.onMouseDown;
gol.canvas.onmousemove = gol.onMouseMove;
gol.canvas.onmouseup = gol.onMouseUp;
gol.addGrid(48,32,100,44,8);
gol.refreshAll();
gol.refreshGridSelect(-1);
gol.getOptions(-1);
gol.genTableBack();
} else {
alert("Canvas not supported by your browser. Why don't you try Firefox or Chrome? For now, you can have a hug. *hug*");
}
},
}
}