-
Notifications
You must be signed in to change notification settings - Fork 50
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
base: master
Are you sure you want to change the base?
readme update #35
Conversation
[7,3,3,3,3,8] | ||
] | ||
|
||
//array indicating the exits |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the few good application of switch
:)
counter=0 | ||
|
||
//playerMovement | ||
if(!isExit() && clicker){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation issue here
Project Workflow: 4 / 5 Glow
Grow
Things to look for
|
@@ -0,0 +1,76 @@ | |||
<!DOCTYPE html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may reduce some repetition here. How?
@@ -0,0 +1,23 @@ | |||
function charMoveLeft(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may refactor here
return mumX === charX
|
||
//checking relative y-position from mummy to player | ||
function checkYPos(mumY, charY){ | ||
if(mumY === charY){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as line 110
|
||
//checking x-blockage | ||
function checkXBlockLeft(x){ | ||
switch(x){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.