readme update#35
Conversation
| [7,3,3,3,3,8] | ||
| ] | ||
|
|
||
| //array indicating the exits |
There was a problem hiding this comment.
I think it's not necessary to split these two arrays (map and exit), but good that you justify why in the presentation.
| @@ -0,0 +1,76 @@ | |||
| <!DOCTYPE html> | |||
There was a problem hiding this comment.
Good job on separating the concern of each level into different html 👍
I hope you realized that this is tedious, but this is inevitable in unit 1.
| // SET THE MAP | ||
| map.forEach(function(spotY,indexY) { | ||
| spotY.forEach(function(spot, indexX){ | ||
| switch (spot) { |
There was a problem hiding this comment.
One of the few good application of switch :)
| counter=0 | ||
|
|
||
| //playerMovement | ||
| if(!isExit() && clicker){ |
|
Project Workflow: 4 / 5 Glow
Grow
Things to look for
|
| @@ -0,0 +1,76 @@ | |||
| <!DOCTYPE html> | |||
There was a problem hiding this comment.
You can complete your game without split files of html. I believe you will figure that out. Focus on reducing repetition.
|
|
||
| //playerMovement | ||
| if(!isExit() && clicker){ | ||
| switch(e.keyCode){ |
There was a problem hiding this comment.
What will be cons and pros of switch statement with a few case?
if(!isExit() && clicker) {
if(e.keyCode === 37 && !checkXBlockLeft(charPos)) charMoveLeft()
if(e.keyCode === 38 && !checkYBlockTop(charPos)) charMoveUp()
if(e.keyCode === 39 && !checkXBlockRight(charPos)) charMoveRight()
if(e.keyCode === 40 && !checkYBlockBottom(charPos))charMoveDown()
mummyFollowChar()
meetMummy()
}
| @@ -0,0 +1,30 @@ | |||
| //layout for blockage | |||
There was a problem hiding this comment.
Without file splitting and linking to particular html file, I believe you can generate levels with javascript. :) It will be helpful for scalability of levels.
| function mummyFollowChar(){ | ||
| counter = 0 | ||
| mumPos = map[mumY][mumX] | ||
| if(counter <2){ |
There was a problem hiding this comment.
You may reduce some repetition here. How?
| @@ -0,0 +1,23 @@ | |||
| function charMoveLeft(){ | |||
There was a problem hiding this comment.
Your movement functions are called inside of callback function of the keyborad event listener. Then what if I put var position = $('#player').position() line to line 4 of gameplay.js?
| // SET THE MAP | ||
| map.forEach(function(spotY,indexY) { | ||
| spotY.forEach(function(spot, indexX){ | ||
| switch (spot) { |
There was a problem hiding this comment.
Good 'switch approach with many cases. :)
And you may do this with 2-D Array and in statement for replacing each switch statement.
e.g.
var arr = [[1,5,6,9,11,12,14], [ ...... ], [......], .........]
if( spot in arr[0] ) $wrapper.eq(indexY).find('.box').eq(indexX).addClass('top')
|
|
||
| // SET THE MAP | ||
| map.forEach(function(spotY,indexY) { | ||
| spotY.forEach(function(spot, indexX){ |
There was a problem hiding this comment.
What are the cons and pros of forEach()comparing with for-loop?
|
|
||
| //checing relative x-position of mummy to player | ||
| function checkXPos(mumX, charX){ | ||
| if(mumX === charX){ |
There was a problem hiding this comment.
You may refactor here
return mumX === charX
|
|
||
| //checking relative y-position from mummy to player | ||
| function checkYPos(mumY, charY){ | ||
| if(mumY === charY){ |
|
|
||
| //checking x-blockage | ||
| function checkXBlockLeft(x){ | ||
| switch(x){ |
There was a problem hiding this comment.
For your inspiration.
function checkXBlockLeft(x){
var block = [4,5,7,10,11,13,14]
return x in block
}
|
Project Workflow: 4 / 5 GlowStrong understanding of own logic and solid way of thinking. GrowYou can try various method or approach for doing same things. Things to look forClass & Constructor. |
No description provided.