Code pour Canvas. Carte simple.

				
					<!DOCTYPE html>
<html lang="fr">
<head>
    <meta charset="UTF-8">
    <title>Compilation - Zone de jeu 2D</title>
    <style>
        canvas {
            border: 1px solid black;
        }
        button {
            margin: 10px;
        }
    </style>
</head>
<body>
    <canvas id="myCanvas" width="600" height="600"></canvas>
    <br>
    <script>
        // Récupérer le canvas et son contexte
        const canvas = document.getElementById("myCanvas");
        const ctx = canvas.getContext("2d");

        // Redessiner tout
        function redraw() {
            ctx.clearRect(0, 0, canvas.width, canvas.height);
        }

        // Initialisation
        redraw();
    </script>
</body>
</html>
				
			

Leave a Reply