Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Pacman no.3
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>JS_PacMan 3</title>
</head>
<style type="text/css">
#pacman {
background-color: #fff;
}
</style>
<body>
<canvas id="pacman" width="500" height="300">
canvasがサポートされていません。
</canvas>
<script type="text/javascript">
function drawPacman(ctx, cx, cy) {
ctx.strokeStyle = "#FF0000";
ctx.fillStyle = "#FF0000";
ctx.beginPath();
ctx.lineWidth = 3;
ctx.arc (cx, cy, 50, 30 * Math.PI/180, 330 * Math.PI/180,false);
ctx.lineTo (cx, cy)
ctx.lineTo (cx + 50 * Math.cos (30 * Math.PI/180), cy + 50 * Math.sin (30 * Math.PI/180));
ctx.fill();
}
var cv= document.getElementById("pacman");
var ctx = cv.getContext("2d");
drawPacman(ctx, 50, 50);
drawPacman(ctx, 240, 50);
drawPacman(ctx, 400, 50);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment