Skip to content

Interactive browser-based soccer programming game that teaches JavaScript through gameplay. Control a player with code, navigate defenders, and score goals. Includes 4 learning levels, AI bot mode, 1v1 multiplayer, and a custom code editor with syntax highlighting and line numbers. Built with vanilla HTML, CSS, and JavaScript.

Notifications You must be signed in to change notification settings

Code4Community/CodeStrikers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

162 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

โšฝ Code Strikers

๐ŸŽฎ Overview

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

๐Ÿš€ Quick Start

  1. Clone or download this repository
  2. Open index.html in any modern web browser (Chrome, Firefox, Safari, Edge)
  3. Select a level from the dropdown menu
  4. Click "Start" to begin playing
  5. Write code in the editor and click "Run" to execute it

No installation, dependencies, or setup required - just open and play!


๐Ÿ“š How to Play

Programming Levels (1-4)

  1. Select a Level: Choose from the level dropdown (Level 1-4 for programming challenges)
  2. Write Code: Type JavaScript commands in the code editor to control your player
  3. Run Your Code: Click the green "Run" button to execute your program
  4. Watch It Execute: Your player animates each command in sequence
  5. Score Goals: Navigate around defenders and shoot the ball into the goal
  6. Learn & Iterate: Use syntax errors and feedback to improve your code

Interactive Modes (Bot & 1v1)

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.


๐ŸŽฎ Available Commands

Movement Functions

  • moveRight() โ€“ Move player 1 space to the right
  • moveLeft() โ€“ Move player 1 space to the left
  • moveUp() โ€“ Move player 1 space up
  • moveDown() โ€“ Move player 1 space down

Action Functions

  • shootBall() โ€“ Shoot the ball 4 spaces to the right toward the goal

Loop Functions

  • 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.


๐ŸŽฏ Game Levels

Level 1: Basic Movement

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();

Level 2: Navigation

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();

Level 3: Loops & Patterns

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.


Level 4: Dynamic Obstacles

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.


๐Ÿค– Bot Mode

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.

Difficulty Levels

๐ŸŸข 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

Game Modes

โฑ๏ธ 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

Goaler Toggle

Turn goalkeepers ON or OFF for both modes. Goalers add an extra challenge by blocking shots at the goal.


๐Ÿ‘ฅ 1v1 Mode

Challenge a friend in local multiplayer! Two players compete head-to-head on the same keyboard.

Controls

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)

Shooting Mechanics

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!

1v1 Game Modes

Same as Bot Mode - choose Timed, To Score, or Freeplay with optional goalers.


โœจ Code Editor Features

Syntax Highlighting

  • Keywords (repeat, for) in blue
  • Function names in orange
  • Numbers in teal
  • Parentheses and braces color-coded
  • Colons highlighted in red

Smart Editor Behaviors

  • โœ… 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

Keyboard Shortcuts

  • 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

๐ŸŽ“ What You'll Learn

Programming Concepts

  • 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

Computational Thinking

  • 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

๐Ÿ› ๏ธ Technical Features

Architecture

  • 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

Game Engine

  • 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

Browser Support

  • โœ… Chrome 90+
  • โœ… Firefox 88+
  • โœ… Safari 14+
  • โœ… Edge 90+

๐Ÿ“ Project Structure

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

About

Interactive browser-based soccer programming game that teaches JavaScript through gameplay. Control a player with code, navigate defenders, and score goals. Includes 4 learning levels, AI bot mode, 1v1 multiplayer, and a custom code editor with syntax highlighting and line numbers. Built with vanilla HTML, CSS, and JavaScript.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5