Tess & Malin- Project Labyrinth#198
Conversation
dannebrob
left a comment
There was a problem hiding this comment.
Hi Tess and Malin,
Great game you have made, I think proves that you have a solid understanding of how to work with APIs and Redux. I think your code is well structured and easy to read.
I really enjoyed your loading animation, great work!
// Daniel and Carol
| }, | ||
| reducers: { | ||
| addPlayer: (store, action) => { | ||
| store.username = `${new Date().getTime()} ${action.payload}` |
There was a problem hiding this comment.
nice way to get somewhat unique username 👍
There was a problem hiding this comment.
Why not use "uniqid" on the username as well? This would make the reducer more readable. But hey it works 😋
| export const ApiStart = 'https://labyrinth.technigo.io/start' | ||
| export const ApiMove = 'https://labyrinth.technigo.io/action' No newline at end of file |
There was a problem hiding this comment.
A clever way to not have to repeat the https
| {loading && <Loader loaderColor="#fff" textColor="#fff" />} | ||
| {!loading && currentPosition && <GamePlay />} | ||
| {!loading && !currentPosition && <StartingPage />} |
| switch (currentCoordinate) { | ||
| case '1,0': | ||
| backgroundImage = FirstImage; | ||
| break; | ||
| case '1,1': | ||
| backgroundImage = SecondImage; | ||
| break; | ||
| case '0,1': | ||
| backgroundImage = ThirdImage; | ||
| break; | ||
| case '0,2': | ||
| backgroundImage = FourthImage; | ||
| break; | ||
| case '0,3': | ||
| backgroundImage = FifthImage; | ||
| break; | ||
| case '1,3': | ||
| backgroundImage = SixthImage; | ||
| break; | ||
| default: | ||
| backgroundImage = DefaultImg; |
There was a problem hiding this comment.
Nice way to switch backgrounds, another way to do it is to have an object with all the background images as values, with the coordinates as keys.
const backgroundImages = { '0,0': '/assets/img2.jpg', '1,0': '/assets/img3.jpg', '1,1': 'assets/img4.jpg', '0,1': 'assets/img5.jpg', '0,2': 'assets/img6.jpg', '0,3': 'assets/img7.jpg', '1,3': 'assets/img8.jpg' };
https://zippy-vacherin-041127.netlify.app/