Mario Won't Move


#1



https://www.codecademy.com/courses/web-beginner-en-JwhI1/2/3?curriculum_id=50a3fad8c7a770b5fd0007a1


The picture will move left and up, but not down or right.


$(document).ready(function() {
    $(document).keydown(function(key) {
        switch(parseInt(key.which,10)) {
			// Left arrow key pressed
			case 37:
				$('img').animate({left: "-=10px"}, 'fast');
				break;
			// Up Arrow Pressed
			case 38:
				// Put our code here
				$('img').animate({top: "-=10px"}, 'fast');
				break;
			// Right Arrow Pressed
			case 39:
				// Put our code here
				$('img').animate({right: "-=10px"}, 'fast');
				break;
			// Down Arrow Pressed
			case 40:
				// Put our code here
				$('img').animate({bottom: "-=10px"}, 'fast');
				break;
		}
	});
});


#2

animate() takes its reference from the top/left of the window. We cannot use right or bottom.

$('img').animate({left: "+=10px"}, 'fast');

$('img').animate({top: "+=10px"}, 'fast');

#3

A post was split to a new topic: Controller of this exercise is broken


#4

thank you that was really useful..

why does codecademy not mention that in its tutorials? that really confuses people...


#5

That is something I cannot answer. This question comes up a few times a year so is well documented in the forums.


#8