Code Monkey home page Code Monkey logo

find-me's Introduction

Simple 'Hidden Objects' game around Path of Exile's unique items.

Find the listed items in an image with many of them, similar to finding Waldo's games. Path of Exile is an ARPG game where there are thousands of unique items that you can collect, and only a small number of them are shown in the image used for this game. It's obviously more difficult to engage if you're not familiar with the game itself, but you can always google the name of the items you need to find to have an image/icon for reference and try to find them in the picture!

Running the project locally:

Clone this repo, and in the project directory type 'npm -i' to get the few dependencies up and running, after that you can run this command to start the app locally:

npm start

Challenges and discoveries

My first real challenge while building this project was definitely how to tackle navigating an image and letting the app know where the mouse is on that image. After some research, I found multiple ways of handling this, and I went with what seemed the most intuitive one, which was through the nativeEvent object generated from clicking the image element. Extracting the X and Y positions of the mouse click, then transforming these coordinates into the percentage of the image's width and height, with the help of 'event.target.width' and height. This allowed for the coordinates to always be the same regardless of screen size, as long as the image maintains its aspect ratio. By giving each item a max and min Y and X coords, I was able to form a rectangle and adapt it to the position and size of each item.

The second challenging aspect was around the 'clock' component, and all of its control flow on when to pause it, save time, keep the clock running, etc. Supporting myself on the localStorage for this was quite helpful, though it could be tweaked to make it so the time stays saved in localStorage to keep people from 'restarting' the timer by refreshing the page. Since the app is in just 'play for fun' mode I haven't done that just yet.

Something else that took some time and energy was the conditional rendering/styling of a bunch of elements, such as giving the items listed in teal to find a line-through when they've been found, showing an error message if the form to register the player on the leaderboards isn't validated, or knowing what to render depending on the state of the game (hasn't started, it's in process or it's been won). Achieved most of these by using styles in the React code and combining them with the conditions in Javascript right there, except the form validation one which was done through CSS, using the 'element:invalid' property. I can confidently say that conditionally rendering and styling will be far easier for me in the future after this project!

Another thing that was fairly challenging was the chaining of props from a component to sometimes 2 or 3 components down the line. This is something that is better accomplished by using Redux (I think) and the Context API, but it's things I'm yet to learn, though it's probably the very next thing I'll be studying. I still made it work, obviously through a much more tedious and time-consuming approach and definitely not best-practice.

Things I want to improve on/study soon This is the first project where I implemented any sort of backend, and I did it through Firebase, which was fairly simple but still took a certain amount of time and exploration. Database/backend is something that I definitely want to get into more, at the very least so I need to invest less time on it whenever I want to implement something as simple as I did here, and the next section in The Odin Project is all about the backend, so I'll be headed in that direction regardless! Aside from that I'll soon be getting into these React topics: -Redux -Context API -Styled components

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.