-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add reusable getRandomTip function, create bedroom_shelf interaction (#…
- Loading branch information
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
src/interactions/map_campus_house_1/bedroomShelf.interaction.js
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,19 @@ | ||
import { displayDialogue } from '../../utils'; | ||
import { updateEnergyState } from '../../utils/energyUpdate'; | ||
import { getRandomTip } from '../../utils/randomTip'; | ||
|
||
export const bedroomShelfInteractions = (player, k, map) => { | ||
player.onCollide('bedroom_shelf', () => { | ||
player.isInDialog = true; | ||
|
||
displayDialogue({ | ||
k, | ||
player, | ||
text: ["Here's a tip for learning to code:", getRandomTip()], | ||
onDisplayEnd: () => { | ||
player.isInDialog = false; | ||
}, | ||
}); | ||
updateEnergyState(player.state, player.state.energy + 5); | ||
}); | ||
}; |
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
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,33 @@ | ||
|
||
export const getRandomTip = () => { | ||
|
||
// Feel free to add additional tips to this array. | ||
const tipsForLearningToCode = [ | ||
"Start by understanding the fundamentals like variables, loops, and functions before diving into more complex topics.", | ||
"Practice regularly by building small projects or solving coding challenges to solidify your knowledge.", | ||
"Don't be afraid to make mistakes; debugging is a key part of the learning process and will help you improve.", | ||
"Read and understand other people's code; it can expose you to new techniques and approaches to solving problems.", | ||
"Break down complex problems into smaller, manageable parts to avoid feeling overwhelmed.", | ||
"Use comments in your code to explain your thought process and make it easier to understand later.", | ||
"Leverage online resources like Stack Overflow and documentation when you get stuck, but try to solve problems on your own first.", | ||
"Learn how to effectively use a debugger or console to trace and fix errors in your code.", | ||
"Write clean and readable code by following best practices such as consistent indentation and meaningful variable names.", | ||
"Don't focus too much on memorizing syntax: understanding concepts and knowing where to find answers is more important.", | ||
"Start with one language and get comfortable with it before moving on to others.", | ||
"Use version control systems like Git to keep track of changes and collaborate with others.", | ||
"Focus on learning how to think logically and solve problems rather than just learning syntax.", | ||
"Set small, achievable goals to stay motivated and measure your progress over time.", | ||
"Get comfortable reading official documentation, as it's often the best source of information.", | ||
"Pair programming with a friend or mentor can help you learn faster and gain new perspectives.", | ||
"Write tests for your code to ensure it works as expected and is easy to maintain in the future.", | ||
"Keep your functions and code blocks small and focused on one task to improve readability and reusability.", | ||
"Understand how data structures like arrays, objects, and lists work, as they are fundamental in coding.", | ||
"Always keep learning and stay curious—new frameworks, libraries, and tools are constantly being developed." | ||
]; | ||
|
||
// Select a random tip from the array | ||
const randomTip = tipsForLearningToCode[Math.floor(Math.random() * tipsForLearningToCode.length)]; | ||
|
||
// Return the random tip | ||
return randomTip; | ||
} |