Skip to content

naimozcan/not-today

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

20 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Not Today! ๐ŸŽฎ

A browser-based arcade shooter game where you defend your base against waves of alien invaders using light projectiles.

Game Preview

๐ŸŽฏ Game Overview

Not Today! is a fast-paced defense shooter where mysterious aliens approach your base from above. Your mission: eliminate them before they reach the ground and damage your defenses. Each alien requires 5 precise hits to be destroyed, testing your accuracy and reaction time under pressure.

๐Ÿ•น๏ธ Gameplay

  • Control your character using keyboard inputs (WASD or Arrow keys)
  • Shoot light balls upward to hit descending aliens
  • Destroy invaders before they reach your base (5 hits each)
  • Protect your base - each alien that reaches the ground reduces your base life by 5%
  • Score points for every alien destroyed
  • Track your high scores across play sessions

๐ŸŽฎ Controls

Key Action
A / โ† Move Left
D / โ†’ Move Right
W / โ†‘ Shoot Light Ball
Pause Pause/Resume Game
Quit Exit to Main Menu

๐Ÿ› ๏ธ Technical Implementation

Core Technologies

  • Vanilla JavaScript - Pure JS implementation with no frameworks
  • DOM Manipulation - Dynamic element creation and positioning
  • CSS3 - Styling and visual effects
  • HTML5 Audio API - Background music and sound effects

Game Architecture

Object-Oriented Design

The game uses ES6 classes for clean, modular code:

// Three main game entities
class Prof { }        // Player character with movement and shooting
class Invader { }     // Alien enemies with AI movement and collision
class LightBall { }   // Projectiles with automatic trajectory

Game Loop

  • 60 FPS game loop using setInterval(gameLoop, 1000/60)
  • Collision detection system for projectile-enemy interactions
  • Spawning system generating aliens at 2-second intervals
  • Life management tracking both enemy health and base integrity

Key Features

  • Collision Detection: AABB (Axis-Aligned Bounding Box) algorithm for precise hit detection
  • Perspective Scaling: Enemies grow larger as they approach (simulating depth)
  • Projectile Physics: Light balls shrink as they travel upward
  • LocalStorage Integration: Persistent high score and last score tracking
  • Audio System: Toggle-able music and sound effects
  • Pause Mechanism: Full game state pause/resume functionality

Code Highlights

Dynamic Spawning

function invaderSpawn() {
    let randomX = Math.floor(Math.random() * 640) - 320;
    let newInvaderObj = new Invader(randomX);
    invaderArr.push(newInvaderObj);
}

Collision Detection

if (invader.x < lightBall.x + lightBall.width &&
    invader.x + invader.width > lightBall.x &&
    invader.y < lightBall.y + lightBall.height &&
    invader.y + invader.height > lightBall.y) {
    invader.life--;
    // Handle collision...
}

๐ŸŽจ Features

Game Mechanics

  • โœ… Progressive difficulty with continuous alien spawning
  • โœ… Multi-hit enemy system (5 hits per alien)
  • โœ… Base health system with visual indicator
  • โœ… Score tracking with formatted 6-digit display
  • โœ… 3-second countdown before game start

User Interface

  • โœ… Start screen with score display
  • โœ… In-game HUD showing current, last, and high scores
  • โœ… Real-time base life indicator
  • โœ… Game over screen with results
  • โœ… Music and SFX toggle controls

Polish

  • โœ… Background music with loop functionality
  • โœ… Sound effects for shooting, explosions, and game events
  • โœ… Quit confirmation dialog
  • โœ… Persistent data storage using localStorage
  • โœ… Smooth animations and visual feedback

๐Ÿ“ Project Structure

not-today/
โ”œโ”€โ”€ index.html              # Main HTML structure
โ”œโ”€โ”€ style.css               # Game styling
โ”œโ”€โ”€ script.js               # Main game logic (provided code)
โ”œโ”€โ”€ classes/
โ”‚   โ”œโ”€โ”€ Prof.js            # Player class
โ”‚   โ”œโ”€โ”€ Invader.js         # Enemy class
โ”‚   โ””โ”€โ”€ LightBall.js       # Projectile class
โ””โ”€โ”€ assets/
    โ”œโ”€โ”€ img/               # Game sprites and graphics
    โ”‚   โ”œโ”€โ”€ prof-stable.png
    โ”‚   โ”œโ”€โ”€ prof-hands-up.png
    โ”‚   โ”œโ”€โ”€ ground-alien.png
    โ”‚   โ”œโ”€โ”€ light-ball.png
    โ”‚   โ””โ”€โ”€ enemy-explosion.png
    โ””โ”€โ”€ audio/
        โ”œโ”€โ”€ music/         # Background tracks
        โ””โ”€โ”€ fx/            # Sound effects

๐Ÿš€ Getting Started

  1. Clone the repository

    git clone https://github.com/yourusername/not-today.git
  2. Navigate to the project directory

    cd not-today
  3. Open in browser

    # Simply open index.html in your browser
    # Or use a local server:
    python -m http.server 8000
    # Then visit http://localhost:8000

๐ŸŽฏ Game Logic Flow

Start Screen โ†’ Countdown (3s) โ†’ Game Active
    โ†“                              โ†“
High Score                    Spawn Aliens
Last Score                    Player Movement
Music Toggle                  Shoot Projectiles
                              Collision Check
                              Base Life Check
                                  โ†“
                            Game Over Screen
                                  โ†“
                            Update Scores
                                  โ†“
                            Return to Start

๐Ÿ“Š Learning Outcomes

This project demonstrates proficiency in:

  • JavaScript Fundamentals: ES6+ syntax, classes, arrow functions
  • DOM Manipulation: Dynamic element creation and management
  • Game Development Concepts: Game loops, collision detection, state management
  • Event Handling: Keyboard input, click events, audio controls
  • Data Persistence: localStorage API for score tracking
  • Array Operations: Managing game entity collections
  • Timing Functions: setInterval, setTimeout for game timing
  • Object-Oriented Programming: Class-based architecture
  • Browser APIs: Audio API, localStorage, DOM API

๐ŸŽ“ Technical Skills Showcased

Skill Implementation
Algorithm Design AABB collision detection, spawn randomization
State Management Game state (start/play/pause/end) handling
Performance Efficient 60 FPS game loop
User Experience Responsive controls, visual feedback
Code Organization Modular class-based structure
Asset Management Audio and image resource handling

๐Ÿ”ง Potential Enhancements

  • Add difficulty levels (spawn rate, enemy speed)
  • Implement power-ups (rapid fire, shield, slow-motion)
  • Create multiple enemy types with different behaviors
  • Add boss battles at score milestones
  • Implement combo system for consecutive hits
  • Add particle effects for explosions
  • Mobile touch controls
  • Leaderboard system with backend integration

๐Ÿ“ License

This project is open source and available under the MIT License.

๐Ÿ‘ค Author

Your Name

๐Ÿ™ Acknowledgments

  • Game concept inspired by classic arcade shooters
  • Built as a learning project to demonstrate JavaScript game development skills

Note: This game was created as a portfolio project to demonstrate proficiency in vanilla JavaScript, DOM manipulation, and game development fundamentals without relying on frameworks or game engines.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published