onlyVishesh / Diamond-Clicker-Game

This repo contains code of my Diamond clicker Game that i made using HTML CSS and javascript . Hope you enjoy

Home Page:https://diamond-clicker-game.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Diamond Clicker

Diamond Clicker is an incremental game where the objective is simple: click on the diamond to earn it. As you accumulate diamonds, you can use them to purchase upgrades that will help you earn diamonds even faster. It's a game that combines simplicity with addictive gameplay, and I've had a lot of fun creating it.

Here is the link to play it right now - Play Now!!

A Quick Gameplay

67c34242-d341-4cfc-a936-7fa9aa59b764.mp4

Motivation

I created Diamond Clicker to learn and deepen my understanding of JavaScript concepts and their real-world applications. Developing this game allowed me to explore various aspects of web development while honing my skills in JavaScript.

What I've Learned

During the development of this game, I had the opportunity to learn and apply various concepts in web development. Some of the key learnings include:

  • Working with functions, setAttribute, classList, appendChild, createElement, changing the source of an image, and other DOM manipulation techniques.
  • Implementing event listeners and keybindings to enhance user interaction and gameplay experience.
  • Utilizing the setInterval function for timing events within the game.
  • Adding audio elements, controlling playback, and incorporating audio effects.
  • Saving and retrieving game progress using local storage, allowing players to continue their progress even if they close the game.

JavaScript Concepts:

I gained a deeper understanding of JavaScript concepts such as functions, classes, and event listeners. I leveraged functions to encapsulate reusable logic, utilized classes to organize and structure my code, and used event listeners to respond to user interactions like clicking on the diamond.

  • Functions - Functions allowed me to organize and reuse blocks of code. They helped me update the diamond count, apply upgrades, and perform other tasks with ease.

DOM Manipulation:

I learned how to manipulate the Document Object Model (DOM) to dynamically update the game interface. I used functions like setAttribute to modify HTML element attributes, classList to add and remove CSS classes, and appendChild to dynamically create and insert new elements into the DOM.

  • setAttribute - This powerful method enabled me to set the values of attributes on HTML elements dynamically. I used it to change the image source or assign classes based on the game's state.

  • classList - By using classList, I could manipulate the classes of HTML elements. It allowed me to add, remove, or toggle classes, adding visual effects or changing styles during gameplay.

  • appendChild - With appendChild, I could insert new elements as children of existing ones. This feature helped me dynamically add elements like notifications or upgrade options to enhance the game's interface.

  • createElement - The createElement function enabled me to create new HTML elements programmatically. It was especially useful for generating buttons, images, and other UI components on the fly.

Timed Events:

I utilized the setInterval function to schedule and execute timed events within the game. This allowed me to update the game state, handle automatic diamond generation, and perform other time-dependent actions.

  • Event listeners and keybindings - I implemented event listeners to capture user interactions and enhance gameplay. By using keybindings, I made the game more immersive, allowing players to interact with the diamond clicking experience.

  • setInterval - I utilized the setInterval function to schedule timed events within the game. It helped me control the pace of the game and execute functions at regular intervals.

Visual Feedback :

I learned how to dynamically change the source (src) attribute of an image element to provide visual feedback to the player. This allowed me to display different images based on specific conditions or game events.

  • Adding audio elements - I incorporated audio elements into the game to create an immersive experience. By controlling playback and applying audio effects, I enhanced the overall ambiance and engagement.

  • Changing the source of an image - I learned how to modify the src attribute of an image element dynamically. This skill allowed me to display different images for upgrades or trigger visual changes in response to events.

Data Persistence:

I discovered how to save and retrieve data using local storage. This feature enabled players to continue their progress even if they closed the game, providing a seamless user experience.

These learnings, along with many other cool JavaScript concepts, have provided me with valuable experience and a deeper understanding of web development.

Future Improvements

If I were to revisit this project in the future, here are some potential improvements I would consider:

  1. Enhanced Diamond Counter: Implementing a number system using the toLocaleString function to display the diamond counter and upgrade costs in a more readable format, such as millions, billions, etc.

  2. Leaderboard: Adding a leaderboard feature to track the highest diamond counts achieved by players, fostering competition and engagement among players.

  3. Power-Ups: Introducing power-ups or special abilities that can be unlocked or purchased using diamonds, providing additional gameplay mechanics and excitement.

  4. Prestige Mode: Implementing a prestige system where players can reset their progress in exchange for permanent bonuses or unlock new features, adding a sense of progression beyond the initial gameplay loop.

Conclusion

Diamond Clicker has been a rewarding project that allowed me to dive deep into JavaScript and explore various web development concepts. I've gained valuable experience in using JavaScript in a practical context while creating an enjoyable game. With potential future improvements, such as an enhanced diamond counter, leaderboard, power-ups, and a prestige mode, Diamond Clicker can become an even more engaging and addictive incremental game.

About

This repo contains code of my Diamond clicker Game that i made using HTML CSS and javascript . Hope you enjoy

https://diamond-clicker-game.vercel.app


Languages

Language:JavaScript 67.3%Language:CSS 18.3%Language:HTML 14.4%