Code Strikers is an interactive browser-based soccer programming game that teaches coding through gameplay. Players write JavaScript code to control a soccer player, navigate around defenders, and score goals. The game combines the excitement of soccer with fundamental programming concepts, making it perfect for beginners learning to code.
Built with vanilla HTML, CSS, and JavaScript, Code Strikers features:
- ๐ฏ Progressive Learning Levels - Start simple and advance to complex challenges
- ๐ค AI Bot Mode - Four difficulty levels with intelligent opponents
- ๐ฅ Local Multiplayer - 1v1 mode for competitive play with friends
- ๐ป Professional Code Editor - Syntax highlighting, line numbers, and auto-indentation
- โก Real-time Execution - Watch your code come to life on the field
- ๐จ Polished UI - Animated sprites, smooth gameplay, and sound effects
- Clone or download this repository
- Open
index.htmlin any modern web browser (Chrome, Firefox, Safari, Edge) - Select a level from the dropdown menu
- Click "Start" to begin playing
- Write code in the editor and click "Run" to execute it
No installation, dependencies, or setup required - just open and play!
- Select a Level: Choose from the level dropdown (Level 1-4 for programming challenges)
- Write Code: Type JavaScript commands in the code editor to control your player
- Run Your Code: Click the green "Run" button to execute your program
- Watch It Execute: Your player animates each command in sequence
- Score Goals: Navigate around defenders and shoot the ball into the goal
- Learn & Iterate: Use syntax errors and feedback to improve your code
For Bot Mode and 1v1 Mode, you control players in real-time using keyboard controls instead of writing code. Choose your game mode (Timed, To Score, or Freeplay) and difficulty settings before starting.
moveRight()โ Move player 1 space to the rightmoveLeft()โ Move player 1 space to the leftmoveUp()โ Move player 1 space upmoveDown()โ Move player 1 space down
shootBall()โ Shoot the ball 4 spaces to the right toward the goal
repeat(N):โ Repeat the indented code block N times (Python-style syntax)
Note: Use proper indentation (2 spaces) for code inside repeat() blocks. The editor supports auto-indentation when you press Enter after the colon.
Learning Goal: Sequential commands and function calls
Challenge: Move right and shoot to score. No defenders to worry about.
Example Solution:
moveRight();
moveRight();
moveRight();
moveRight();
moveRight();
shootBall();Learning Goal: Planning paths and avoiding obstacles
Challenge: Two static defenders block your path. Navigate around them without colliding.
Example Solution:
moveRight();
moveRight();
moveUp();
moveRight();
moveRight();
moveDown();
shootBall();Learning Goal: Using repeat() for efficiency
Challenge: Multiple defenders scattered across the field. Use loops to write cleaner code.
Example Solution:
repeat(3):
moveRight()
moveUp()
repeat(2):
moveRight()
shootBall()Key Concept: Instead of writing moveRight() five times, use repeat(5): to make your code more elegant and maintainable.
Learning Goal: Timing and observation
Challenge: Defenders move up and down in patterns. Time your movements carefully to avoid collisions.
Strategy: Watch the defender patterns, then write code that moves through safe zones at the right moments.
Test your skills against an AI-controlled opponent! The bot uses pathfinding and decision-making algorithms to chase the ball, defend the goal, and shoot.
๐ข Easy
- Slow movement speed
- Basic shooting mechanics
- Simple ball-chasing AI
- Perfect for beginners
๐ก Medium
- Faster movement
- Improved shooting accuracy
- Predictive interception - tries to cut off your path
- Good challenge for intermediate players
๐ด Hard
- Quick, responsive movement
- Advanced dodging mechanics - can avoid your shots
- Smart positioning between you and the goal
- Aggressive tackling behavior
โซ Impossible
- Lightning-fast reactions
- Master-level tactics and feints
- Unpredictable movement patterns
- Extremely difficult to beat
โฑ๏ธ Timed Mode
- Race against the clock (set custom duration from 1-20 minutes)
- Score as many goals as possible before time runs out
- Highest score wins
๐ฏ To Score Mode
- First to reach the target score wins
- Set custom winning score (1-100 points)
- Best for competitive matches
โ Freeplay Mode
- No time limit or score target
- Practice and experiment freely
- End the game manually when ready
Turn goalkeepers ON or OFF for both modes. Goalers add an extra challenge by blocking shots at the goal.
Challenge a friend in local multiplayer! Two players compete head-to-head on the same keyboard.
Player 1 (Blue - Left Side)
- W - Move up
- A - Move left
- S - Move down
- D - Move right
- SPACE - Shoot (hold to charge power, release to shoot)
Player 2 (Red - Right Side)
- โ - Move up
- โ - Move left
- โ - Move down
- โ - Move right
- M - Shoot (hold to charge power, release to shoot)
Press and hold the shoot button to charge up power (watch the power bar fill up), then release to shoot. The longer you hold, the more powerful and faster the shot!
Same as Bot Mode - choose Timed, To Score, or Freeplay with optional goalers.
- Keywords (
repeat,for) in blue - Function names in orange
- Numbers in teal
- Parentheses and braces color-coded
- Colons highlighted in red
- โ
Auto-closing parentheses - Type
(and)appears automatically - โ
Auto-indentation - Press Enter after
repeat(N):to auto-indent with 2 spaces - โ Line numbers - Professional IDE-style line numbering that scrolls with your code
- โ Tab support - Press Tab to insert 2 spaces for indentation
- โ Real-time syntax errors - See errors highlighted as you type
- โ Code validation - Checks for invalid commands before running
- Enter after
repeat(N):โ Auto-indent next line - Tab โ Insert 2 spaces
- Ctrl+A / Cmd+A โ Select all code
- Ctrl+V / Cmd+V โ Paste code
- Sequential Execution - Code runs line by line from top to bottom
- Function Calls - Using pre-defined functions to perform actions
- Loops - Repeating code blocks efficiently with
repeat(N): - Indentation - Proper code formatting and scope
- Debugging - Reading error messages and fixing syntax issues
- Problem Solving - Breaking down challenges into smaller steps
- Algorithm Design - Planning step-by-step solutions
- Pattern Recognition - Identifying repetitive actions
- Abstraction - Using loops instead of repetition
- Decomposition - Breaking complex problems into simple commands
- Testing & Iteration - Running code, observing results, and improving
- Vanilla JavaScript - No frameworks or libraries required
- HTML5 Canvas - Smooth 60 FPS animations
- CSS3 - Modern styling with animations and transitions
- ContentEditable - Custom-built code editor
- Collision Detection - Precise player-defender and ball-goal collision
- Physics Simulation - Ball rolling, shooting mechanics, and momentum
- Pathfinding AI - Bot uses smart decision-making for movement
- Animation System - Smooth sprite animations and transitions
- โ Chrome 90+
- โ Firefox 88+
- โ Safari 14+
- โ Edge 90+
CodeStrikers/
โโโ index.html # Main game page
โโโ styles.css # All styling and animations
โโโ ui.js # UI controls, editor, event handlers
โโโ main.js # Game engine, physics, AI
โโโ levels.js # Level configurations
โโโ movement.js # Player movement logic
โโโ field.js # Soccer field rendering
โโโ sound.js # Sound effects manager
โโโ assets/ # Images and sprites
โ โโโ attacker.png
โ โโโ defender.png
โ โโโ soccer.png
โ โโโ soccer_goal.png
โ โโโ soccer_field.png
โโโ README.md