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 update #35

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Binary file added .DS_Store
Binary file not shown.
256 changes: 162 additions & 94 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,96 +1,164 @@
# Project Name (Start editing here)
<!---
Read Me Contents
-->
# ![](https://ga-dash.s3.amazonaws.com/production/assets/logo-9f88ae6c9c3871690e33280fcf557f33.png) Project #1: Mummy Maze

You are trapped in a chamber with a mummy. The mummy seemed to follow around the chamber with your every single move. There are barriers within the chamber which can temporary block the mummy's moves.

Your quest is to be able to exit the room before the mummy reaches you. Quick! Your Time is running out!

Play it here
https://thamjieying.github.io/project-1/

# ![](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!
Basic Layout
------------
<img src="./img/basicLayout2.png" width=300px>

* 6X6 grid layout
* Walls as barriers
* 1 Player
* 1 Mummy
* Exit


### Sample Game Layout
<img src="./img/sampleLayout1.png" width=300px>

Instructions
---------
### Goal
Reach the exit without being caught by the mummy

### Game Play
1. Player Starts First
2. Player gets to move by 1 grid in any direction
<br><img src="./img/playerMoves.png" width=100px>
3. Each move the player makes, the mummy moves towards the player by 2 moves towards the player
<img src="./img/mummyMoves.png" width=200px>
4. The walls prevents the mummy from moving towards the player while the player moves towards the exit
<img src="./img/barrierMoves.png" width=200px>
5. Once the player gets to the exit, the play is completed, Player proceeds to the next level.

### How does the mummy moves?

1. If the mummy can move horizontally (side to side) to get closer to the player, it will first make a horizontal move
2. Else, the mummy will make a vertical move (up or down) to get closer to the player
3. if the mummy is unable to make any move due to the barriers, it will remain at the same spot.

You can "trick" the mummy into walking into the barriers to buy you some "moves" to get to the exit.

Building the Game
-----------------
### Flow Chart of the Game Logic
<img src="./img/flowChart.png">


### Placing the Barriers on the board
##### Representation of Barriers
![FlowChart](/img/tileRepresentation.jpg "Game Logic")

##### Sample Representation of the Board Layout using a 2D Array
Empty Board (no barrier)
```javascript
var map = [
[5,1,1,1,1,6],
[4,0,0,0,0,2],
[4,0,0,0,0,2],
[4,0,0,0,0,2],
[4,0,0,0,0,2],
[7,3,3,3,3,8]]
```

### Initialisation of the Game
Setting up the map and exit using a 2D array

```javascript
var map = [
[5,1,9,1,1,6],
[4,0,6,0,3,2],
[10,4,0,2,5,2],
[4,3,0,0,3,2],
[4,6,4,2,5,0],
[7,3,3,3,3,8]]

var exit = [
[0,0,0,0,0,0],
[0,0,0,0,0,0],
[0,0,0,0,0,0],
[0,0,0,0,0,0],
[0,0,0,0,0,2],
[0,0,0,0,0,0],
]

```

Setting the starting position of the player, mummy and the exit
```javascript
var charX //x position of the player
var charY //y position of the player

var mumX //x position of the mummy
var mumY //y position of the mummy

var exitX //x position of the exit
var exitY //y position of the exit
```

### Checking Valid Movement
#### Checking Blockage

Using a switch case to check the tile corresponding each wall. The function returns a true if the movement is blocked and a false if the movement is allowed

example: checking if moving up is valid
```javascript
function checkYBlockTop(x){
switch(x){
case 1://top blocked
case 5://top and left blocked
case 6://top and right blocked
case 9://top and bottom blocked
case 11:// top, left and right blocked
case 12:// top, right and bottom blocked
case 14:// top, left and bottom blocked
return true;//movement is blocked
break;
default:
return false;//movement is NOT blocked
}
}
```

### Mummy's movement
Mummy needs to get closer to the player. With the player's every move, it will move 2 step closer.

We control's the mummy movement by first checking the relative position of the mummy to the player.
* check relative x position
* move horizontally(if possible)
* check relative y position
* move vertically (if possible)
* if both mummy and player are in the same position, this means that it has reached the end of the game.

###### Deciding to move left or Right
Mummy (x-position) - Player(x-position) = positive (left)
<br>Mummy (x-position) - Player(x-position) = negative (right)

###### Deciding to move Up or Down
Mummy (y-position) - Player(y-position) = positive (up)
<br>Mummy (y-position) - Player(y-position) = negative (down)

### Number of Levels
There are a total of 6 level with increasing difficulty.

### Ending the Game
There are 2 ways that will led to the end of the game
1. Mummy meets the player
2. Player exits the maze

### Challenges
* Linking the movement of the characters with the javascript
* mapping all the combinations of the barriers and representing it on a 2D array.
* Ensuring that the mummies follows the player with the defined logic.

### Improvement
* Creating random levels without presetting the map, character position and mummy position.
* Creating animation for the character.
* Creating more enemies to increase the difficulty of the game.
* Making sure that the character move within the grids
Binary file added audio/footsteps.mp3
Binary file not shown.
Binary file added audio/scary.mp3
Binary file not shown.
47 changes: 47 additions & 0 deletions css/menu.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

.container{
width: 800px;
height: 500px;
margin: 0 auto;
background: url(../img/background_2.jpg) no-repeat;
background-size: cover;
}

h1{
text-align: center;
font-family: 'Creepster', cursive;
font-size: 150px;
color: #8E4A49;
margin: 0;
}
button{
display: block;
margin: auto;
height: 100px;
margin-top: 5px;
font-family: 'Creepster', cursive;
font-size: 50px;
opacity: 0.5;
}

.wrapperLeft{
display: inline-block;
width: 39%;
text-align: center;
}
.wrapperRight{
display: inline-block;
width: 50%;
/*text-align: center;*/
}

li{
font-family: "Arial Rounded MT Bold";
}
#menu{
font-family: arial;
font-size: 20px;
padding; 10px;
height: 50px;
opacity: 1;
}
Loading