Skip to content

arundada9000/pokemon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pokémon Selector: The Element Wheel 🌀⚡

This project is an interactive web application that displays a rotating selection of Pokémon. Users can click on any small Pokémon image to update the central display, change the background color of the page, and instantly play that Pokémon's unique sound clip.

It is a demonstration of DOM manipulation, CSS transitions/animations, and data attributes for dynamic content loading, structured around a visually appealing circular layout.

🚀 Live Demo

arundada9000.github.io/pokemon/

✨ Key Features

  • Circular Layout: Small Pokémon images are dynamically positioned in a circle around the main container using JavaScript and trigonometry.
  • Interactive Selection: Clicking a small image triggers three simultaneous actions:
    1. The central image and its alt text are updated.
    2. The Pokémon's cry/sound is played using the HTML <audio> element.
    3. The body background color changes instantly to match the Pokémon's primary type/color (e.g., Electric yellow for Pikachu, Water blue for Piplup).
  • Visual Feedback: The selected small image receives a CSS border highlight, and the main image performs a "zoom-out" animation for visual flair.
  • Responsive Design: The layout adapts to fit the size of the viewport on all devices using CSS media queries.

Preview

Desktop Preview

preview image

preview image

preview image


Mobile Preview

preview image preview image

🏗️ How It Works (Professional Breakdown)

The professional operation of this project relies entirely on combining HTML Data Attributes with JavaScript DOM manipulation and CSS math.

1. Data-Driven HTML

All essential dynamic data for a Pokémon is stored directly in the <img> tag of the small image using custom attributes:

  • The data-music attribute holds the path to the Pokémon's sound file.
  • The data-bg attribute holds the specific Hex color code (e.g., #FFDE59) for the background change.
<img
  class="small-img"
  src="./assets/images/pikachu.jpeg"
  alt="Pikachu"
  data-music="./assets/sounds/pikachu.mp3"
  data-bg="#FFDE59"
/>

2. Circular Positioning with JavaScript

The script.js file calculates the precise position of each small image to create the perfect circular "wheel":

  1. It determines the total number of images (smallImgs.length).
  2. It uses trigonometry (specifically Math.cos() and Math.sin()) to calculate the X and Y coordinates on the circle's circumference for each image index (index).
  • x = centerX + radius.cos(angle)
  • y = centerY + radius.sin(angle)
  1. The calculated coordinates are then applied to the image's style using img.style.left and img.style.top in percentage units.

3. Dynamic Interaction Logic

When an image is clicked, the img.addEventListener("click", ...) function executes:

  • It uses img.getAttribute("data-music") and img.dataset.bg to quickly retrieve the data from the HTML.

  • It updates the audio.src and initiates playback (audio.play()).

  • It applies the retrieved color directly to the page using document.body.style.backgroundColor.

  • It manages the selection highlight and the main image's transition animation.


🛠️ Customization Guide

You can easily add, remove, or modify the Pokémon in this project by editing only the index.html file.

1. Adding a New Pokémon

To add a new creature to the wheel, create a new <img> tag inside the <div class="container"> and ensure you populate the four essential properties:

Property Example Value Description
src ./assets/images/snorlax.png Path to the Pokémon's image file.
alt "Snorlax" The name of the Pokémon.
data-music ./assets/sounds/snorlax.mp3 The file path for the sound clip.
data-bg #A8A878 The Hex color code for the background when selected.

Note: The JavaScript will automatically recalculate the position to maintain the perfect circular arrangement.


2. Updating Colors or Sounds

To modify the look or sound of an existing Pokémon:

  1. Open index.html.

  2. Locate the relevant <img> tag.

  3. Modify the Hex color in the data-bg attribute.

  4. Modify the path in the data-music attribute.


⚙️ Project Setup

To run this project on your local machine:

  1. Clone the Repository:
git clone github.com/arundada9000/pokemon
  1. Navigate to the Directory:
cd pokemon
  1. Ensure Assets are Present: Verify that all image (.jpeg, .png) and sound (.mp3) files are correctly placed in the ./assets/images/ and ./assets/sounds/ directories, matching the paths defined in index.html.

  2. Launch: Open the index.html file directly in your web browser.


Technologies Used

  • HTML5: Structure, semantics, and Data Attributes.

  • CSS3: Layout, responsive design, and animations (@keyframes).

  • JavaScript (ES6): Trigonometric positioning, DOM manipulation, and event handling.


🖋️ Attribution & Licensing

Created By

  • Author: Arun Neupane

  • Project: Developed for demonstration and educational purposes on the Code With Ease YouTube channel.

  • Inspiration: This project is a playful exploration of interactive web design and DOM manipulation.

Personal Note

Coding should be fun! This project was built to bring back the nostalgia of selection screens and explore how simple JavaScript and CSS can create dynamic, engaging interfaces. Gotta Catch 'Em All! ⚡


🌐 Connect with Me

I enjoy creating fun and educational web projects. Let's connect!

YouTube GitHub Instagram Gmail Facebook

Any Platform my username is arundada9000


⚠️ Fair Use & Asset Rights

The code provided in this repository is free to use and modify for personal and non-commercial projects.

However, please be aware that the Pokémon imagery, official names, and sound clips are the copyrighted property of Nintendo, Game Freak, and The Pokémon Company.

  • Code: You are free to reuse the HTML, CSS, and JavaScript logic.

  • Assets: The images and sounds are included here for educational demonstration and visual context only (under fair use principles). They are not licensed for reuse or redistribution in a commercial context and must be replaced with original or licensed assets for any commercial deployment.

Created for Code with ease youtube Channel

Channel Link : https://youtube.com/@arundada9000

Tutorial Link : https://youtu.be/

© 2025 Arun Neupane — All rights reserved for original code structure and design.

logo code with ease

Releases

No releases published

Packages

 
 
 

Contributors