aprilkrg
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Project Steps ## SET UP ### Create your pitch [pitch link](https://hackmd.io/KEtIW1JYSEGS-3Mu78xN9A) - MVP vs Stretch vs Icebox - Wireframes ### Create your local project To create a new project, cd to the location you want to create your new project; I'll use my SEI Unit 1 folder to start. > **You can skip this step if you already have a directory with a README set up on your machine. > Confirm it is a git repo and has a README by running `ls -a`** Create the directory and move into it: ```bash mkdir tamagotchi-project cd tamagotchi-project git init ``` > *Change your branch from master to main with this command*: > `git branch -M main` Create the necessary file structure & files: ```bash mkdir scripts styles touch index.html scripts/main.js styles/main.css README.md ``` After making changes to the files, it's time to git add & commit: ```bash git add . git commit -m "add pitch to readme" ``` ### Create your remote project Create a new repository on github, give it a name, keep the view setting on "public", and ***DO NOT*** add a README file. There is already a README on our local project, so if we create one online we will have divergent histories and it will be more difficult to link the projects. After creating the github repo you should see a screen of setup options, and the desired url will be visible in a few places. ![github page that shows different set up options for the newly created repository](https://i.imgur.com/YNW12El.png) Save that url to your clipboard so we can use it in the next step. ### Link the remote and local projects Create an origin stream for our local project with this command, replacing my url argument for your own: ```bash git remote add origin https://github.com/aprilkrg/tamagotchi.git ``` Running this command will show the online repos your project has streams to, so confirm the origin has been set: ```bash git remote -v ``` ![terminal output that returns the url to the projects origin](https://i.imgur.com/FQNvkyU.png) Now that we've set the origin, we can push. In previous steps we added and committed so we can skip that this time - *but when in doubt run a full git add commit & push cycle!* ```bash git push origin main ``` Confirm that the work on your local repo has been pushed to the remote repo by going back to your github page and refreshing. You should now see your file structure and the latest commit message. ![github webpage of the tamagotchi project showing the top level files and folders, and the commit message "add pitch to readme"](https://i.imgur.com/OTPIzwU.png) The repository set up is complete! Next steps could be setting up the html boilerplate and linking the scripts and styles, or psuedocoding. ### Connect files Example of deferred script and google font link tags in an HTML head. ```html <link rel="preconnect" href="https://fonts.googleapis.com" /> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /> <link href="https://fonts.googleapis.com/css2 family=Roboto:wght@300;400;500;700&display=swap" rel="stylesheet"/> <link href="./styles/main.css" rel="stylesheet" /> <script defer src="./scripts/main.js"></script> <title>TAMAGOTCHI</title> ``` ## PSUEDOCODE ### Ideas Gameplay steps: - player starts game - the character stats start to decrement - the player can increment stats by interacting with buttons - when a stat is decreased, check for a 0 value; if 0 the game has been lost - use a timer to track how long the game has lasted; when it reaches a set value the game has been won - after a win or loss the user gets a chance to play again with reset values **Function:** start game change stat check for end of game reset **Form:** stat buttons stat bars reset button win message instructions ### Planning Character class: - play, eat, sleep levels (10 max) - static empty object so we can share information between classes - method to increase each stat levels up to 10 Game class: - timer set to null - static empty object, and variables initialized as null for the intervals - method to increment time attribute - method to set (2) interval timers for the game time and stat change - method to handle stat change on button click - method to check for game over conditions Render function: - select dom elements to render: stats and timer - set the inner text of the stat p tag to the characters current stat level - set the width of the stat using rems and concatenation - set timer html element to current game time - only render if game isn't over DOM Content Loaded function: - create new instances of Game and Character classes - set new instances as static obj value on each class - select dom elements to use for event listeners: buttons - add event listeners to start and stats button on start click - invoke game start method - loop over stat buttons to attach listener that invokes character method to increase stat - invoke render - add event listener to reset button on reset click - create new class instances - set start btn and msg to original settings - invoke render Let's use classes for the character and the game. We'll create the classes first, then use the dom content loaded function to create new instances of those classes. The character class will be responsible for increasing it's own stats, the game class will be responsible for decreasing stats. <!-- #### meta considerations - show them to create good frequent commit messages - use branches - tell them about the css reset - --> ## PLANNING ## Semantic HTML - one div to contain them all... - split board up into 3 cards - top hold game instructions, start button, and game time - middle holds character stats and stat buttons - bottom holds reset button - split middle div into (2) sections for the stats and btns - give btns an id, and the stat btns also get a class - use p tag to display stats - target specific innerText by using a span for the game time ## Styling ### CSS Reset Creates a clean base to build css on across browsers by resetting their default styling. ```css * { margin:0; box-sizing: border-box; } ``` ### CSS Variables Example of variable creation and use: ```css :root { --green-blue: #7BE1C9; --yellow-green: #C3E791; --celeste: #B9EEEA; --pink: #fde2e4; --lavender: #cddafd; } button { color: black; background-color: var(--green-blue); } ``` ## Javascript Create a connection check console log statement, and comments to guide our psuedocode. ```javascript! console.log("good morning developers") // character class // game class // render function // dom content loaded function ``` Load that in the browser from your VSCode by using the 'open in browser' or 'Live Server' extension (*Live Server will be nice for seeing style changes immediately*). Then open your dev tools console to read your message - if you see it you're good to go! If not, that means your files are not linked; check the files are saved and that you've written the html script correctly. ### Organization Comments to organize our classes: ```javascript class ... { // === ! STATIC VARS ! === // // === ! CONSTRUCTOR ! === // constructor() { console.log(this) } // === ! METHODS! === // } ``` And create our DOMContentLoaded function: ```javascript document.addEventListener("DOMContentLoaded", function() { console.log("main.js loaded") // === ! CREATE CLASS INSTANCES ! === // // === ! DOM VARIABLES ! === // // === ! EVENT LISTENERS ! === // } ``` A process that will promote debuggability of our code will be to start with the game logic of the classes, and focus on their interactions. We'll build Classes and invoke their creation and other methods in the dom content loaded function so that we can access that data in the dev tools console. We can test things there. Once we have the game logic to MVP we'll move onto rendering the data on the DOM in a useful way. We'll create DOM variables and set their values to properties from the classes. We can scaffold our testing by first displaying the data onto the DOM, and once we can do that then we invoke functions in the dev tools console and work to get the DOM to respond to the changing values, then we'll attach that functionality to buttons. Finally we'll work on a function to figure out the control flow of all the functions and connect them to event listeners and set intervals, leaving styling for last. ### Classes Each class should handle the data changes for itself, and to invoke those functions we'll save the instances of our classes as static properties on each class. Character Class ```javascript class Character { // === ! STATIC VARS ! === // static charObj = {} // === ! CONSTRUCTOR ! === // constructor() { this.name = "pet" this.playLevel = 10 this.eatLevel = 10 this.sleepLevel = 10 console.log(this) } // === ! METHODS! === // increaseStatLevel(event) { console.log("increase stat invoked", event.target) } } ``` Game Class ```javascript class Game { // === ! STATIC VARS ! === // static gameObj = {} static timerInterval = null static statInterval = null // === ! CONSTRUCTOR ! === // constructor () { this.timer = null console.log(this) } // === ! METHODS! === // gameTimer() { console.log("timer tick toc") } handleStatChange() { console.log("handle stat change invoked") } gameStart() { console.log("game start invoked") // increases the game time // decreases the stats of the character } gameOver() { console.log("game over invoked") // === ! LOSE CONDITION ! === // // === ! WIN CONDITION ! === // } } ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully