<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sensible Soccer Deluxe</title>
<style>
body {
margin: 0;
padding: 0;
background: #1a5d1a;
font-family: 'Courier New', monospace;
overflow: hidden;
user-select: none;
}
#gameContainer {
position: relative;
width: 100vw;
height: 100vh;
overflow: hidden;
}
#field {
position: absolute;
width: 1200px;
height: 800px;
background: linear-gradient(90deg, #2d8f2d 0%, #228b22 50%, #2d8f2d 100%);
border: 4px solid white;
transition: transform 0.1s ease-out;
}
.fieldLine {
position: absolute;
background: white;
}
.centerCircle {
position: absolute;
left: 550px;
top: 350px;
width: 100px;
height: 100px;
border: 3px solid white;
border-radius: 50%;
background: transparent;
}
.centerSpot {
position: absolute;
left: 596px;
top: 396px;
width: 8px;
height: 8px;
background: white;
border-radius: 50%;
}
.goal {
position: absolute;
background: #333;
border: 3px solid white;
}
.goalLeft {
left: -6px;
top: 320px;
width: 6px;
height: 160px;
}
.goalRight {
right: -6px;
top: 320px;
width: 6px;
height: 160px;
}
.penaltyBox {
position: absolute;
border: 3px solid white;
background: transparent;
}
.penaltyBoxLeft {
left: 0;
top: 240px;
width: 120px;
height: 320px;
}
.penaltyBoxRight {
right: 0;
top: 240px;
width: 120px;
height: 320px;
}
.player {
position: absolute;
width: 16px;
height: 16px;
border-radius: 50%;
border: 2px solid #000;
transition: none;
z-index: 10;
display: flex;
align-items: center;
justify-content: center;
font-size: 8px;
font-weight: bold;
color: white;
text-shadow: 1px 1px 1px #000;
}
.playerTeam1 {
background: #ff4444;
}
.playerTeam2 {
background: #4444ff;
}
.playerSelected {
border-color: #ffff00 !important;
border-width: 3px !important;
box-shadow: 0 0 10px #ffff00;
}
.ball {
position: absolute;
width: 12px;
height: 12px;
background: radial-gradient(circle at 30% 30%, white, #ddd, #888);
border-radius: 50%;
z-index: 15;
box-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}
#ui {
position: fixed;
top: 0;
left: 0;
right: 0;
background: rgba(0,0,0,0.8);
color: white;
padding: 10px;
z-index: 100;
display: flex;
justify-content: space-between;
align-items: center;
}
#score {
font-size: 24px;
font-weight: bold;
}
#timer {
font-size: 18px;
}
#commentary {
position: fixed;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
background: rgba(0,0,0,0.9);
color: #ffff00;
padding: 10px 20px;
border-radius: 5px;
font-size: 14px;
max-width: 400px;
text-align: center;
z-index: 100;
opacity: 0;
transition: opacity 0.3s;
}
#controls {
position: fixed;
top: 60px;
right: 10px;
background: rgba(0,0,0,0.8);
color: white;
padding: 10px;
border-radius: 5px;
font-size: 12px;
z-index: 100;
}
.celebration {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 48px;
color: #ffff00;
text-shadow: 3px 3px 6px #000;
z-index: 200;
animation: celebrate 3s ease-out;
}
@keyframes celebrate {
0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
50% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}
.weather {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 50;
}
.raindrop {
position: absolute;
width: 2px;
height: 10px;
background: rgba(173, 216, 230, 0.6);
animation: rain 1s linear infinite;
}
@keyframes rain {
to { transform: translateY(100vh); }
}
#matchResult {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: rgba(0,0,0,0.95);
color: white;
padding: 30px;
border-radius: 10px;
text-align: center;
z-index: 200;
display: none;
}
</style>
</head>
<body>
<div id="gameContainer">
<div id="field">
<!-- Field markings -->
<div class="fieldLine" style="left: 0; top: 0; width: 100%; height: 3px;"></div>
<div class="fieldLine" style="left: 0; bottom: 0; width: 100%; height: 3px;"></div>
<div class="fieldLine" style="left: 0; top: 0; width: 3px; height: 100%;"></div>
<div class="fieldLine" style="right: 0; top: 0; width: 3px; height: 100%;"></div>
<div class="fieldLine" style="left: 597px; top: 0; width: 3px; height: 100%;"></div>
<div class="centerCircle"></div>
<div class="centerSpot"></div>
<div class="goal goalLeft"></div>
<div class="goal goalRight"></div>
<div class="penaltyBox penaltyBoxLeft"></div>
<div class="penaltyBox penaltyBoxRight"></div>
</div>
<div id="ui">
<div id="score">RED 0 - 0 BLUE</div>
<div id="timer">00:00</div>
<div>Weather: <span id="weather">Clear</span></div>
</div>
<div id="controls">
WASD: Move | SPACE: Tackle/Shoot | Q: Pass | E: Long Pass<br>
TAB: Switch Player | R: Restart Match
</div>
<div id="commentary"></div>
<div id="matchResult"></div>
<div class="weather" id="weatherEffect"></div>
</div>
<script>
class Game {
constructor() {
this.field = document.getElementById('field');
this.gameContainer = document.getElementById('gameContainer');
this.fieldWidth = 1200;
this.fieldHeight = 800;
this.cameraX = 0;
this.cameraY = 0;
this.ball = null;
this.players = [];
this.team1Players = [];
this.team2Players = [];
this.selectedPlayer = null;
this.score = { team1: 0, team2: 0 };
this.gameTime = 0;
this.matchDuration = 90000; // 90 seconds = 90 minutes
this.gameRunning = true;
this.kickOffTeam = 1;
this.weather = 'clear';
this.weatherEffects = {
friction: 1,
ballBounce: 1,
visibility: 1
};
this.keys = {};
this.lastGoalTime = 0;
this.commentary = [];
this.init();
}
init() {
this.createBall();
this.createPlayers();
this.setupEventListeners();
this.setRandomWeather();
this.kickOff();
this.gameLoop();
this.updateTimer();
}
createBall() {
this.ball = {
element: document.createElement('div'),
x: this.fieldWidth / 2,
y: this.fieldHeight / 2,
vx: 0,
vy: 0,
radius: 6,
possession: null,
lastTouch: null
};
this.ball.element.className = 'ball';
this.field.appendChild(this.ball.element);
this.updateBallPosition();
}
createPlayers() {
const formations = {
'4-4-2': [
{ x: 0.1, y: 0.5 }, // GK
{ x: 0.25, y: 0.2 }, { x: 0.25, y: 0.4 }, { x: 0.25, y: 0.6 }, { x: 0.25, y: 0.8 }, // Defense
{ x: 0.5, y: 0.25 }, { x: 0.5, y: 0.45 }, { x: 0.5, y: 0.55 }, { x: 0.5, y: 0.75 }, // Midfield
{ x: 0.75, y: 0.35 }, { x: 0.75, y: 0.65 } // Attack
],
'4-3-3': [
{ x: 0.1, y: 0.5 },
{ x: 0.25, y: 0.15 }, { x: 0.25, y: 0.35 }, { x: 0.25, y: 0.65 }, { x: 0.25, y: 0.85 },
{ x: 0.5, y: 0.3 }, { x: 0.5, y: 0.5 }, { x: 0.5, y: 0.7 },
{ x: 0.75, y: 0.25 }, { x: 0.75, y: 0.5 }, { x: 0.75, y: 0.75 }
]
};
const formationNames = Object.keys(formations);
const team1Formation = formations[formationNames[Math.floor(Math.random() * formationNames.length)]];
const team2Formation = formations[formationNames[Math.floor(Math.random() * formationNames.length)]];
// Create Team 1 (Red)
team1Formation.forEach((pos, i) => {
const player = this.createPlayer(
pos.x * this.fieldWidth,
pos.y * this.fieldHeight,
1,
i === 0 ? 'GK' : (i < 5 ? 'DEF' : (i < 9 ? 'MID' : 'ATT')),
i + 1
);
this.team1Players.push(player);
this.players.push(player);
});
// Create Team 2 (Blue) - mirror formation
team2Formation.forEach((pos, i) => {
const player = this.createPlayer(
(1 - pos.x) * this.fieldWidth,
pos.y * this.fieldHeight,
2,
i === 0 ? 'GK' : (i < 5 ? 'DEF' : (i < 9 ? 'MID' : 'ATT')),
i + 1
);
this.team2Players.push(player);
this.players.push(player);
});
this.selectedPlayer = this.team1Players[1]; // Start with outfield player
this.updateSelectedPlayer();
}
createPlayer(x, y, team, position, number) {
const player = {
element: document.createElement('div'),
x: x,
y: y,
vx: 0,
vy: 0,
team: team,
position: position,
number: number,
radius: 8,
speed: 2 + Math.random() * 1.5,
skill: 0.5 + Math.random() * 0.5,
stamina: 100,
homeX: x,
homeY: y,
hasBall: false,
tackleTime: 0,
aiState: 'positioning',
aiTarget: null
};
player.element.className = `player playerTeam${team}`;
player.element.textContent = number;
this.field.appendChild(player.element);
this.updatePlayerPosition(player);
return player;
}
setupEventListeners() {
document.addEventListener('keydown', (e) => {
this.keys[e.key.toLowerCase()] = true;
if (e.key === 'Tab') {
e.preventDefault();
this.switchPlayer();
} else if (e.key.toLowerCase() === 'r') {
this.restartMatch();
}
});
document.addEventListener('keyup', (e) => {
this.keys[e.key.toLowerCase()] = false;
});
}
gameLoop() {
if (!this.gameRunning) return;
this.updatePlayers();
this.updateBall();
this.updateAI();
this.updateCamera();
this.checkCollisions();
this.checkGoals();
this.checkBoundaries