Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix ex7

  • Loading branch information...
commit 0d6515c99093159e2e70afe3f4341723372d950d 1 parent a5ac731
@subelsky subelsky authored
View
17 README.markdown
@@ -4,7 +4,8 @@ These are the solutions for the [HTML5 tutorial](http://en.oreilly.com/rails2011
# PREREQUISITES
-- These instructions were built using the latest version of Chrome, but will also work with the latest version of Safari or Firefox. I have not tested them with IE or Opera but much of the code should still work.
+- These instructions were built using the latest version of Chrome, but will also work with the latest version of Safari or Firefox. Some of the exercises do not work perfectly in Firefox due to limitations in the browser.
+I have not tested them with IE or Opera but much of the code should still work.
- Your browser should have a built-in JavaScript console. If you are using Firefox, be sure to install [Firebug](http://getfirebug.com).
@@ -263,19 +264,9 @@ to the pre-stored field like this: `$("#username").val(nameStr)`.
input { display: block; }
</style>
-2. Also in `index.html`, increase the width and height of your canvas to the maximum comfortable size for your display. You could do something like:
+2. You may also want to increase the width and height of your canvas element.
- var height = $(window).height();
- var width = $(window).width();
-
- $(canvas).height(height);
- $(canvas).width(width);
-
-3. Instead of initializing your player's x and white coordinates to zero, set them to random values within the bounds of your canvas, using something like:
-
- <pre>Math.round(Math.random(width) * 100)</pre>
-
- That will help us avoid bunching up in the same spots. **Be sure to round these numbers**. At least in Chrome, floating point values used for canvas drawing can cause a big performance hit.
+3. Increase the step size for your character so it moves 5 or 10 pixels at a time.
# EXERCISE 8
## Web Sockets
View
4 ex11/js/tutorial.js
@@ -11,8 +11,8 @@ characters.onload = function() {
var height = $(canvas).height();
var width = $(canvas).width();
-var x = Math.round(Math.random(height) * 1000);
-var y = Math.round(Math.random(width) * 1000);
+var x = 0;
+var y = 0;
draw();
View
6 ex7/js/tutorial.js
@@ -11,14 +11,14 @@ characters.onload = function() {
var height = $(canvas).height();
var width = $(canvas).width();
-var x = Math.round(Math.random(height) * 1000);
-var y = Math.round(Math.random(width) * 1000);
+var x = 0;
+var y = 0;
draw();
function move(event) {
switch (event.which) {
case 38:
- if (y > 0) { y -= 5; }
+ if (y > 0) { y -= 10; }
break;
case 40:
if (y < height) { y += 10; }
View
4 ex8/js/tutorial.js
@@ -11,8 +11,8 @@ characters.onload = function() {
var height = $(canvas).height();
var width = $(canvas).width();
-var x = Math.round(Math.random(height) * 1000);
-var y = Math.round(Math.random(width) * 1000);
+var x = 0;
+var y = 0;
draw();
View
4 ex9/js/tutorial.js
@@ -11,8 +11,8 @@ characters.onload = function() {
var height = $(canvas).height();
var width = $(canvas).width();
-var x = Math.round(Math.random(height) * 1000);
-var y = Math.round(Math.random(width) * 1000);
+var x = 0;
+var y = 0;
draw();
Please sign in to comment.
Something went wrong with that request. Please try again.