-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Arnau's maze #15
Open
vidalhuix
wants to merge
9
commits into
Technigo:main
Choose a base branch
from
vidalhuix:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Arnau's maze #15
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
69fe03e
First commit, The maze starts and after the login I get response in t…
56db97c
app login working, first 1 into the maze ok save and change branch
0c85c84
merged everything from GameBody branch
34656ea
Add ReactTyped to description text, change font style, add actions to…
98f5569
code changes in GameScreen, add styling and save before adding Audio …
eb538d5
add restart and audio buttons styling, buttons code not working
c9bfc4d
add readme file
777ab2e
Netlify background images issues, add changes
d9eb4ea
change images folder to public after pernillas recomendation
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,11 @@ | ||
<h1 align="center"> | ||
<a href=""> | ||
<img src="./src/assets/banner.svg" alt="Project Banner Image"> | ||
</a> | ||
</h1> | ||
|
||
# Labyrinth - Zustand Project | ||
|
||
Replace this readme with your own information about your project. | ||
|
||
Start by briefly describing the assignment in a sentence or two. Keep it short and to the point. | ||
|
||
## Getting Started with the Project | ||
|
||
### Dependency Installation & Startup Development Server | ||
|
||
Once cloned, navigate to the project's root directory and this project uses npm (Node Package Manager) to manage its dependencies. | ||
|
||
The command below is a combination of installing dependencies, opening up the project on VS Code and it will run a development server on your terminal. | ||
|
||
```bash | ||
npm i && code . && npm run dev | ||
``` | ||
In this pair project, we built a text based adventure using Zustand for state management and an API from Technigo to post data. | ||
|
||
### The Problem | ||
|
||
Describe how you approached to problem, and what tools and techniques you used to solve it. How did you plan? What technologies did you use? If you had more time, what would be next? | ||
This week, I took a less effective approach. I relied on an AI to provide the project structure, resulting in three components I didn't fully understand. This led to spending most of the week deciphering the code. Instead If I had writedn the code myself would have been a more valuable learning experience. | ||
|
||
### View it live | ||
|
||
Every project should be deployed somewhere. Be sure to include the link to the deployed project so that the viewer can click around and see what it's all about. | ||
|
||
## Instructions | ||
|
||
<a href="instructions.md"> | ||
See instructions of this project | ||
</a> | ||
[here](https://arnaus-maze.netlify.app/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import { Maze } from "./components/Maze"; | ||
|
||
export const App = () => { | ||
return ( | ||
<div> | ||
Labyrinth Project | ||
</div> | ||
<> | ||
<Maze /> | ||
</> | ||
); | ||
}; |
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.audio, | ||
.restart { | ||
position: fixed; | ||
top: 5px; | ||
color: rgba(255, 255, 255, 0.3); | ||
border: none; | ||
} | ||
|
||
.audio { | ||
left: 5px; | ||
} | ||
|
||
.restart { | ||
right: 5px; | ||
} | ||
|
||
.audio:hover, | ||
.restart:hover { | ||
color: rgb(0, 0, 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import "./Buttons.css"; | ||
import { useGlobalStoreData } from "../../stores/storeData"; | ||
|
||
export const RestartButton = () => { | ||
const { startGame } = useGlobalStoreData(); | ||
|
||
const handleRestart = () => { | ||
// Reset the login data in the store | ||
useGlobalStoreData.setState({ | ||
logindata: { | ||
isLoggedIn: false, | ||
username: "", | ||
type: null, | ||
direction: null, | ||
coordinates: null, | ||
}, | ||
}); | ||
|
||
// Call startGame to restart the game | ||
startGame(""); // Pass an empty string as username to restart the game | ||
}; | ||
|
||
return ( | ||
<button className="otherButtons restart" onClick={handleRestart}> | ||
Restart | ||
</button> | ||
); | ||
}; | ||
|
||
export const AudioButton = () => { | ||
return ( | ||
<> | ||
<button className="otherButtons audio">Audio</button> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
.footer-container { | ||
position: absolute; | ||
bottom: 0; | ||
margin-top: auto; | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-between; | ||
align-items: center; | ||
padding: 5px; | ||
background-color: #010101; | ||
color: rgb(255, 255, 255); | ||
width: 100%; | ||
} | ||
|
||
.footer-container p { | ||
margin: 10px; | ||
font-size: 0.85rem; | ||
} | ||
|
||
.logo { | ||
height: 30px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import "./Footer.css"; | ||
import image from "../assets/technigo-logo.svg"; | ||
|
||
export const Footer = () => { | ||
return ( | ||
<footer className="footer-container"> | ||
<p>2024 by Arnau Vidal </p> | ||
<img src={image} alt="Technigo logo" className="logo" /> | ||
</footer> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
.game-screen-background { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
background-size: cover; | ||
background-position: center; | ||
height: 100vh; | ||
width: 100vh; | ||
} | ||
|
||
.game-screen { | ||
margin: 20px auto auto auto; | ||
padding: 10px; | ||
display: flex; | ||
flex-direction: column; | ||
flex-wrap: wrap; | ||
max-width: 400px; | ||
justify-content: center; | ||
align-items: center; | ||
text-align: center; | ||
border-radius: 10px; | ||
background-color: rgba(0, 0, 0, 0.7); | ||
} | ||
|
||
.game-screen-background { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
background-size: cover; | ||
background-position: center; | ||
height: 100vh; | ||
width: 100vh; | ||
} | ||
|
||
.actions { | ||
opacity: 0; | ||
animation: fade-in 1s ease-in-out forwards; | ||
} | ||
|
||
.otherButtons:hover { | ||
background-color: var(--COLOR-2); | ||
} | ||
|
||
.showDirections { | ||
opacity: 0; | ||
animation: fade-in 1s ease-in-out forwards; | ||
} | ||
|
||
@keyframes fade-in { | ||
from { | ||
opacity: 0; | ||
} | ||
to { | ||
opacity: 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { useState } from "react"; | ||
import { useGlobalStoreData } from "../stores/storeData"; | ||
import { ReactTyped } from "react-typed"; | ||
import "./GameScreen.css"; | ||
import { AudioButton, RestartButton } from "./Buttons/Buttons"; | ||
|
||
export const GameScreen = ({ actions }) => { | ||
const [isLoading, setLoading] = useState(false); | ||
const [typingComplete, setTypingComplete] = useState(false); | ||
const [showActions, setShowActions] = useState(false); | ||
|
||
const getDescription = () => { | ||
return useGlobalStoreData.getState().gamedata.description; | ||
}; | ||
|
||
const getCoordinates = () => { | ||
return useGlobalStoreData.getState().gamedata.coordinates; | ||
}; | ||
|
||
const getActions = () => { | ||
return useGlobalStoreData.getState().gamedata.actions; | ||
}; | ||
|
||
const handleAction = async (action) => { | ||
setLoading(true); | ||
try { | ||
const username = useGlobalStoreData.getState().username(); | ||
await useGlobalStoreData | ||
.getState() | ||
.sendAction(username, action.type, action.direction); | ||
} catch (error) { | ||
console.error("Failed to perform action:", error); // Handle error, display error message to the user | ||
} finally { | ||
setLoading(false); | ||
setShowActions(false); | ||
setTypingComplete(false); | ||
} | ||
}; | ||
|
||
// Dynamically set the background image URL based on coordinates | ||
const cleanCoordinates = getCoordinates().replace(",", "-"); | ||
const backgroundImageUrl = `url("/background-image-${cleanCoordinates}.png"`; | ||
|
||
const hasDirections = getActions().some((action) => action.type === "move"); | ||
|
||
return ( | ||
<div | ||
className="game-screen-background" | ||
style={{ backgroundImage: backgroundImageUrl }} | ||
> | ||
<div className="game-screen"> | ||
<ReactTyped | ||
strings={[getDescription()]} | ||
typeSpeed={40} | ||
showCursor={false} | ||
onComplete={() => setTypingComplete(true)} | ||
/> | ||
{typingComplete && ( | ||
<> | ||
{hasDirections && ( | ||
<button | ||
className="otherButtons showDirections" | ||
onClick={() => setShowActions(!showActions)} | ||
> | ||
{showActions ? "Hide Directions" : "Show Directions"} | ||
</button> | ||
)} | ||
{showActions && ( | ||
<div className="actions"> | ||
{getActions().map((action, index) => ( | ||
<div key={index}> | ||
{action.type === "move" && ( | ||
<button | ||
className="btnDirection" | ||
onClick={() => handleAction(action)} | ||
disabled={isLoading} | ||
> | ||
Go: {action.direction} | ||
</button> | ||
)} | ||
<p>{action.description}</p> | ||
</div> | ||
))} | ||
</div> | ||
)} | ||
</> | ||
)} | ||
<AudioButton></AudioButton> | ||
<RestartButton></RestartButton> | ||
</div> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.login-background { | ||
display: flex; | ||
justify-content: center; | ||
background-image: url("../assets/start-image.jpg"); | ||
background-size: cover; | ||
background-position: center; | ||
height: 100vh; | ||
} | ||
|
||
.container-start { | ||
margin: auto; | ||
padding: 10px; | ||
display: flex; | ||
flex-direction: column; | ||
flex-wrap: wrap; | ||
max-width: 400px; | ||
justify-content: center; | ||
align-items: center; | ||
text-align: center; | ||
border-radius: 10px; | ||
background-color: rgba(0, 0, 0, 0.7); | ||
} | ||
|
||
.container-start input { | ||
margin: 10px; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unessecary react fragment