const canvas = document.getElementById('gameCanvas');
const ctx = canvas.getContext('2d');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
function drawReel() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = '#1a1a1a';
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.drawImage(reelImage, 100, 100, 200, 200);
}
window.addEventListener('resize', () => {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
drawReel();
});
drawReel();
Canvas Rendering
This code sets up an HTML5 Canvas for rendering game graphics, a core component of Slot Astronaut. It initializes the canvas to match the window size, ensuring responsiveness. The drawReel function clears the canvas and draws a reel image, optimized for mobile screens. Resizing is handled dynamically to maintain visuals across devices.