ASCII Mario Game (HTML Canvas)
10. ASCII Mario Game (HTML Canvas)
=================================
<canvas id="mario" width="400" height="200"></canvas>
<script>
const canvas = document.getElementById('mario');
const ctx = canvas.getContext('2d');
let x = 0;
function drawMario() {
ctx.clearRect(0, 0, 400, 200);
ctx.fillStyle = '#FF0000'; ctx.fillRect(x++, 150, 30, 50);
ctx.fillStyle = '#000'; ctx.fillRect(x, 160, 10, 10); // Hat
if (x > 370) x = 0;
requestAnimationFrame(drawMario);
}
drawMario();
</script>
Featured
Advertisement
Category
Action