jjw - 토끼 타이쿤 소스 작업 중
by JM note
HTML
<canvas id="field" width="150" height="150"></canvas>
<script>
function draw_tile(x, y) {
ctx.strokeStyle = "black";
ctx.strokeRect(x * 50, y * 50, 50, 50);
ctx.fillStyle = "green";
ctx.fillRect(x * 50, y * 50, 50, 50);
}
function draw_rabbit(x, y) {
ctx.beginPath();
ctx.arc(x * 50 + 25, x * 50 + 25, 10, 0, Math.PI * 2, true);
ctx.fillStyle = "white";
ctx.fill();
}
var ctx = document.getElementById("field").getContext('2d');
for (var x = 0; x < 3; x++) {
for (var y = 0; y < 3; y++) {
draw_tile(x, y);
}
}
draw_rabbit(1, 1);
</script>