Changed around line 1
+ document.addEventListener('DOMContentLoaded', () => {
+ const canvas = document.getElementById('gameCanvas');
+ const ctx = canvas.getContext('2d');
+ const characters = document.querySelectorAll('.character-card');
+ const startButton = document.getElementById('startGame');
+
+ let selectedCharacter = null;
+ let computerCharacter = null;
+ let gameInProgress = false;
+
+ // Set canvas size
+ function resizeCanvas() {
+ canvas.width = canvas.offsetWidth;
+ canvas.height = canvas.offsetHeight;
+ }
+
+ resizeCanvas();
+ window.addEventListener('resize', resizeCanvas);
+
+ // Character selection
+ characters.forEach(char => {
+ char.addEventListener('click', () => {
+ if (!gameInProgress) {
+ characters.forEach(c => c.classList.remove('selected'));
+ char.classList.add('selected');
+ selectedCharacter = char.dataset.character;
+ }
+ });
+ });
+
+ // Game initialization
+ startButton.addEventListener('click', () => {
+ if (selectedCharacter && !gameInProgress) {
+ gameInProgress = true;
+ startButton.disabled = true;
+ const availableCharacters = ['xi-jinping', 'putin', 'trump', 'modi']
+ .filter(char => char !== selectedCharacter);
+ computerCharacter = availableCharacters[Math.floor(Math.random() * availableCharacters.length)];
+ initGame();
+ }
+ });
+
+ function initGame() {
+ const player = {
+ x: 100,
+ y: canvas.height - 100,
+ width: 50,
+ height: 100,
+ health: 100
+ };
+
+ const computer = {
+ x: canvas.width - 150,
+ y: canvas.height - 100,
+ width: 50,
+ height: 100,
+ health: 100
+ };
+
+ function gameLoop() {
+ if (!gameInProgress) return;
+
+ // Clear canvas
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+
+ // Draw players
+ ctx.fillStyle = '#ff3e3e';
+ ctx.fillRect(player.x, player.y, player.width, player.height);
+ ctx.fillStyle = '#3e3eff';
+ ctx.fillRect(computer.x, computer.y, computer.width, computer.height);
+
+ // Update health bars
+ document.getElementById('player1Health').style.width = `${player.health}%`;
+ document.getElementById('player2Health').style.width = `${computer.health}%`;
+
+ requestAnimationFrame(gameLoop);
+ }
+
+ gameLoop();
+ }
+ });