Skip to content
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

Readme Ver 1 #25

Open
wants to merge 46 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
a73fbc1
Readme Ver 1
Sep 29, 2017
ff1fee7
shuffle function ver 1
Sep 30, 2017
5472f9f
shuffle function ver 2
Oct 2, 2017
c14fc9b
match card function, shuffle function
Oct 2, 2017
7c4a9a4
how
Oct 2, 2017
a146b16
end of the day help 1
Oct 2, 2017
f510f61
firstclicked issue
Oct 3, 2017
b707c8b
start restart button
Oct 3, 2017
85df551
avoid clicks
Oct 3, 2017
84d81ec
shuffle restart works
Oct 3, 2017
667ce1d
after prima consult wed
Oct 4, 2017
67a4590
visual
Oct 4, 2017
0019e89
design
Oct 5, 2017
72678de
soft launch ver 1
Oct 5, 2017
522b87e
song
Oct 5, 2017
a294c72
song
Oct 5, 2017
4aa026e
update html
Oct 5, 2017
28a8b86
dots
Oct 5, 2017
f684043
dots 2
Oct 5, 2017
e330e4d
images.
Oct 5, 2017
0bb9f1c
more dots
Oct 5, 2017
172196a
more dots....
Oct 5, 2017
f158ffe
more dots
Oct 5, 2017
c6b1bf8
more dots
Oct 5, 2017
bb0cb91
please work
Oct 5, 2017
df35194
work now
Oct 5, 2017
13df2f9
assets dots
Oct 5, 2017
b530799
background please
Oct 5, 2017
d087a4c
dots
Oct 5, 2017
46862cd
more dots last
Oct 5, 2017
df06d4f
dots
Oct 5, 2017
39f54d2
change back image
Oct 5, 2017
9ff0af5
change time 1
Oct 5, 2017
8ecc000
ediitng css
Oct 5, 2017
46fe25e
css
Oct 5, 2017
cd8c014
5.16pm
Oct 5, 2017
405e8f9
sounds folder
Oct 5, 2017
21ac2f7
change timeout to 500
Oct 5, 2017
a34079d
finished readme
Oct 5, 2017
aa48f18
readme backtick issue
Oct 5, 2017
042eb50
backtickkkkkk
Oct 5, 2017
2332186
backtick horror story
Oct 5, 2017
dc5b684
backtick horror story
Oct 5, 2017
80fe0d0
readme ver n
Oct 5, 2017
d66d267
readme final
Oct 5, 2017
93c7f17
added game link at top
Oct 5, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
196 changes: 100 additions & 96 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,96 +1,100 @@
# Project Name (Start editing here)
<!---
Read Me Contents
-->

# ![](https://ga-dash.s3.amazonaws.com/production/assets/logo-9f88ae6c9c3871690e33280fcf557f33.png) Project #1: The Game

### Overview

Let's start out with something fun - **a game!**

Everyone will get a chance to **be creative**, and work through some really **tough programming challenges** – since you've already gotten your feet wet with Tic Tac Toe, it's up to you to come up with a fun and interesting game to build.

**You will be working individually for this project**, but we'll be guiding you along the process and helping as you go. Show us what you've got!


---

### Technical Requirements

Your app must:

* **Render a game in the browser**
* **Any number of players** will be okay, switch turns will be great
* **Design logic for winning** & **visually display which player won**
* **Include separate HTML / CSS / JavaScript files**
* Stick with **KISS (Keep It Simple Stupid)** and **DRY (Don't Repeat Yourself)** principles
* Use **Javascript** for **DOM manipulation**, jQuery is not compulsory
* **Deploy your game online**, where the rest of the world can access it
* Use **semantic markup** for HTML and CSS (adhere to best practices)
* **No canvas** project will be accepted, only HTML5 + CSS3 + JS please

---

### Necessary Deliverables

* A **working game, built by you**, hosted somewhere on the internet
* A **link to your hosted working game** in the URL section of your GitHub repo
* A **git repository hosted on GitHub**, with a link to your hosted game, and frequent commits dating back to the very beginning of the project
* **A ``readme.md`` file** with explanations of the technologies used, the approach taken, installation instructions, unsolved problems, etc.

---

### Suggested Ways to Get Started

* **Break the project down into different components** (data, presentation, views, style, DOM manipulation) and brainstorm each component individually. Use whiteboards!
* **Use your Development Tools** (console.log, inspector, alert statements, etc) to debug and solve problems
* Work through the lessons in class & ask questions when you need to! Think about adding relevant code to your game each night, instead of, you know... _procrastinating_.
* **Commit early, commit often.** Don’t be afraid to break something because you can always go back in time to a previous version.
* **Consult documentation resources** (MDN, jQuery, etc.) at home to better understand what you’ll be getting into.
* **Don’t be afraid to write code that you know you will have to remove later.** Create temporary elements (buttons, links, etc) that trigger events if real data is not available. For example, if you’re trying to figure out how to change some text when the game is over but you haven’t solved the win/lose game logic, you can create a button to simulate that until then.

---

### Potential Project Ideas

##### Blackjack
Make a one player game where people down on their luck can lose all their money by guessing which card the computer will deal next!

##### Self-scoring Trivia
Test your wits & knowledge with whatever-the-heck you know about (so you can actually win). Guess answers, have the computer tell you how right you are!

---

### Useful Resources

* **[MDN Javascript Docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript)** _(a great reference for all things Vanilla Javascript)_
* **[jQuery Docs](http://api.jquery.com)** _(if you're using jQuery)_
* **[GitHub Pages](https://pages.github.com)** _(for hosting your game)_
* **[How to write readme - Markdown CheatSheet](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet)** _(for editing this readme)_
* **[How to write a good readme for github repo!](https://gist.github.com/PurpleBooth/109311bb0361f32d87a2)** _(to make it better)_

---

### Project Feedback + Evaluation

* __Project Workflow__: Did you complete the user stories, wireframes, task tracking, and/or ERDs, as specified above? Did you use source control as expected for the phase of the program you’re in (detailed above)?

* __Technical Requirements__: Did you deliver a project that met all the technical requirements? Given what the class has covered so far, did you build something that was reasonably complex?

* __Creativity__: Did you add a personal spin or creative element into your project submission? Did you deliver something of value to the end user (not just a login button and an index page)?

* __Code Quality__: Did you follow code style guidance and best practices covered in class, such as spacing, modularity, and semantic naming? Did you comment your code as your instructors have in class?

* __Deployment__: Did you deploy your application to a public url using GitHub Pages?

* __Total__: Your instructors will give you a total score on your project between:

Score | Expectations
----- | ------------
**0** | _Incomplete._
**1** | _Does not meet expectations._
**2** | _Meets expectations, good job!_
**3** | _Exceeds expectations, you wonderful creature, you!_

This will serve as a helpful overall gauge of whether you met the project goals, but __the more important scores are the individual ones__ above, which can help you identify where to focus your efforts for the next project!
# **Eat This**
Play the game: https://liyuan23.github.io/project-1/

## **Table of Contents**
1. Overview
2. Flowchart
3. Instructions
4. Interesting Logic I Learnt
5. Motivation
6. Potential Improvements
7. Time Management
8. External Libraries/Frameworks
9. References

### **Overview**
Memory has long been a favourite game for all ages. Test your memory with Eat This - a matching card game for all those who have a strong desire to eat. This game requires a good knowledge of observation, concentration and a good memory to win. The objective of the game is to collect the most matching pairs. The game is designed so two players can play against each other and win by scoring higher than the other player.

### **Flowchart**
<img src="/assets/img/gameflowchart.png" border = 2px solid black>

### **Instructions**
<img src="/assets/img/gamescreenshot.png" border = 2px solid black>

**How To Play:**
+ Each player clicks on two cards to try and match them
+ Every successful match gives the player two points
+ The player with the highest score wins

### **Interesting Logic I Learnt**
+ Shuffle Function
+ Generate random numbers and replace numbers in an array with a while loop
``` javascript
function shuffle (array) {
let counter = array.length
// While there are elements in the array
while (counter > 0) {
// Pick a random index
let index = Math.floor(Math.random() * counter)
// Decrease counter by 1
counter--
// SWOP
// use temp to store last counter (20)
let temp = array[counter]
// random index replace with last counter (20)
array[counter] = array[index]
// push back last counter (20) into random index prev position
array[index] = temp
}
return array
}
```

+ Using for loops to add classes and assign `div`s

+ How to call functions and use multiple parameters and pass in additional arguments


+ How to use 'this' to find last clicked div
``` javascript
$(this).find('img').attr('src', './assets/img/back.jpg')
cardsSave.pop()
```


+ How to find values without the use of 'this' to find second last clicked div
``` javascript
$(`.card[data-id="${firstClicked}"]`).find('img').attr('src', './assets/img/back.jpg')
```

### **Motivation**
I like food, I thought this would be relatively simple, but as I added more functions, I soon realised the many problems one function could cause.

For example, adding the ```avoid clicks class``` causes the program to lag at times as the player does not realise the code is still checking for matches and continues to click frantically which in turn causes more confusion with the checking.

Fortunately, there are a lot of helpful resources in this course and online, which helped me to overcome these problems.

### **Potential Improvements**
+ CSS reorganisation, reduce/increase the number of cards to fit well within one frame without scrolling
+ Animate card flips
+ Think of a way to get around the clicking bug
+ Reduce the need for myArray by renaming images

### **Time Management**
+ 29 September 2017: Thought about flow of game and pseudocode, started writing some shuffle functions and understand them
+ 2 October 2017: Fixed shuffle, flipback and match functions with help from Prima
+ 3 October 2017: Added timer, score, start and restart buttons, reorganised code
+ 4 October 2017: Made the game two players, added instructions, used css to style the game and got help from Prima to learn how to refactor code
+ 5 October 2017: Fixed issues with flipback of matched pairs and winning logic

### **External Libraries / Frameworks**

[JQuery] (https://jquery.com/)

### **References**
+ Shuffle Function: https://bost.ocks.org/mike/shuffle/
+ Images:
1. https://www.instagram.com/naturally.jo/?hl=en
2. http://www.godiva.com.sg/sgen/self-treats/ice-cream-chocolate-soft-serve.html
3. https://keioaboutchocolate.wordpress.com/about/
+ Everyone who helped me
Binary file added assets/.DS_Store
Binary file not shown.
162 changes: 162 additions & 0 deletions assets/css/stylesheet.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
.background{
background-image: url("../img/background.jpg");
background-repeat: no-repeat;
background-position: center;
background-attachment: fixed;
background-size: 1400px 800px;
overflow: hidden;

}

h2, h3, h5 {
font-family: 'Parisienne', cursive;
font-size: 25px;
color: #995129;
background: rgba(255,255,255,0.8);
border-radius: 20px;
border: 1px white solid;
margin: 20px 20px;
padding: 5px;
}

h1 {
text-align: center;
font-family: 'Parisienne', cursive;
font-size: 109px;
color: white;
height: 126px;
margin: 10px 20px 1px 20px;
}

#instructionscontainer {
color: white;
font-family: 'Parisienne', cursive;
font-size: 34px;
position: relative;
text-align: center;
}

#instructionslink {
/* font-size: 1.1em; */
padding: 0;
}

#instructionslink:hover {
cursor: pointer;
}

#instructionstext {
background-color: #995129;;
font-family: 'Courgette', cursive;
color: white;
font-size: 0.8em;
display: none;
padding: 0.5% 0;
position: relative;
z-index: 1000;
border-radius: 15px;
}

.wrap {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}

button{
background: rgba(255,255,255,1);
position: absolute;
top: 195px;
border-radius: 28px;
font-family: 'Parisienne', cursive;
color: #D2B895;
font-size: 30px;
padding: 5px 10px;
text-decoration: none;
outline: 0;
border: 2px white solid;
}

button:hover {
background: #685031;
text-decoration: none;
}

.timer{
font-family: 'Parisienne', cursive;
font-size: 25px;
color: #995129;
background: rgba(255,255,255,0.8);
border-radius: 20px;
border: 1px white solid;
margin: 20px 20px;
padding: 5px 30px;
margin-bottom: -69px;
font-weight: 200;
}

.clearfix {
overflow: auto;
}

.playerScoreBoard {
margin-top: -103px;
margin-bottom: -29px;
}

#player1 {
float:left;
margin: -8px 155px;
}

.player1 {
text-align: center;
}

#player2 {
float:right;
margin: -8px 155px;
}

.player2 {
text-align: center;
}

.player2-score, .player1-score {
text-align: center;
margin-top: -0.5em;
}

.playerTurnNow {
margin-bottom: -6px;
margin-top: 105px;
}

#memoryBoard {
width: 764px;
height: 619px;
padding: 10px;
margin-top: 12px;
border-radius: 25px;
box-sizing: border-box;
}

#memoryBoard > div {
display: inline-flex;
width: 130px;
height: 130px;
margin: 8px;
cursor: pointer;
}

img {
border: 5px solid #433220;
border-radius: 10px;
width: 130px;
height: 130px
}

.avoid-clicks {
pointer-events: none;
}
Binary file added assets/img/.DS_Store
Binary file not shown.
Binary file added assets/img/1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/10.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/10a.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/1a.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/2a.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/3a.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/4a.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/5a.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/6.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/6a.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/7.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/7a.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/8.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/8a.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/9.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/9a.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/back.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/background.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/gameflowchart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/gamescreenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/js/.DS_Store
Binary file not shown.
Loading