On the other side#28
Conversation
| var jumpLimit = true // switch for jump | ||
| var start1 = [] // indicates ball1 starting position, index position increases with level | ||
| var start2 = [] | ||
| var currentLevel |
There was a problem hiding this comment.
What does this variable for?
| } | ||
| } | ||
| function wallCheck1Right () { | ||
| if (($ball1.position().left + $ball1.width() >= $('.wall1').eq(0).position().left) && |
There was a problem hiding this comment.
How would you rectified this repetitions?
| **1** | _Does not meet expectations._ | ||
| **2** | _Meets expectations, good job!_ | ||
| **3** | _Exceeds expectations, you wonderful creature, you!_ | ||
| I also used wikipedia for the gravity formula, but it seems the page no longer looks the same, or I can't find it. But [here's](http://www.school-for-champions.com/science/gravity_equations_falling_displacement.htm#.WdXiRROCzVo) another resource you can use to see the gravity displacement. |
There was a problem hiding this comment.
The general equation is from kinematics, for displacement with constant acceleration.
See http://www.physicsclassroom.com/class/1DKin/Lesson-6/Kinematic-Equations.
Where d is the displacement, v(i) is initial velocity, a is acceleration (in this case, a = g) and t is time
| <body> | ||
| <script src="js/script.js" charset="utf-8"></script> | ||
| <h1> On The Other Side </h1> | ||
| <h3> <br> </h3> |
There was a problem hiding this comment.
I had put it to push down the game halves lower from the h1 element
| <div id = "clear"></div> | ||
|
|
||
| </div> | ||
| <button type="button" id = "mute" class="mute"> I like sounds (M)</button> |
There was a problem hiding this comment.
no space please => id="mute"
| <p> Help steer Blue and Red into the grey boxes to win. <br> | ||
| <strong>You can only move Blue directly</strong> with W,A,D or ↑,←,→. <br> | ||
| Red will go opposite in the horizontal plane.<br></p> | ||
| <br><br> |
There was a problem hiding this comment.
please group your html into a more logical grouping
| @@ -0,0 +1,548 @@ | |||
| var $ball1 = $('#ball1') | |||
There was a problem hiding this comment.
Line 1 to line 18 should be after $(function () {
| function ballMove (e) { | ||
| var unit = 20 // 20 | ||
| if (e.key === 'd' || e.key === 'D' || e.key === 'ArrowRight') { | ||
| if (ball1Goal() === false && (borderCheck1Right()) && (wallCheck1Right()) && (!$('.fade').length)) ball1Hori(unit) // if ball1 doesn't exceed right border |
There was a problem hiding this comment.
that's a really long condition, can we shorten this instead in a function?
| } | ||
| if (e.key === 'w' || e.key === 'W' || e.key === 'ArrowUp') { | ||
| if (jumpLimit) { | ||
| if (!ball1Goal()) ball1Jump() |
There was a problem hiding this comment.
Why can't just there be one function that checks goal for both balls?
There was a problem hiding this comment.
This is to let both balls be independent from each other, when a single ball goes into the goal, it will be frozen, while the other ball can still move/jump.
| }) | ||
|
|
||
| // this controls horizontal ball movement | ||
| function ball1Hori (a) { |
There was a problem hiding this comment.
indentation, and repeated.
What is a?
There was a problem hiding this comment.
a represents an argument that we eventually use, e.g.: in line, 31: var unit = 20 to indicate the amount of pixels moved per keyboard move:
ball1Hori(unit) to indicate movement to the right
ball1Hori(-unit) to indicate movement to the left
| document.getElementById('ball1').style.left = (Number($ball1.css('left').replace('px', '')) + a).toString() + 'px' | ||
| } | ||
| function ball2Hori (a) { | ||
| document.getElementById('ball2').style.left = (Number($ball2.css('left').replace('px', '')) - a).toString() + 'px' |
There was a problem hiding this comment.
mixing jquery with document.getElementById(), choose one and stick with it.
There was a problem hiding this comment.
Hmm i remember for this one, .css(top) and .position.top actually represent different values on the screen, so used .style to edit the ball placement,which seems to be only for non jquery manipulators ( i might be wrong!)
| return true | ||
| } | ||
| } | ||
| function wallCheck2Right () { |
There was a problem hiding this comment.
Refactor, refactor, refactor
| break | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
whew. what just happened
There was a problem hiding this comment.
this section of code represents when the user wins the current level. The logic which checks the winning condition is actually on a set interval, which also populates a nextLevel button. So in order to stop adding multiple buttons continously, we clear this interval, while adding a button which leads to the next level.
|
Project Workflow: 4 / 5 Glow
Grow & Things to look out for
|
Glow
Grow & Things to look out for
|
Readme and flowchart edit