Mario doesn't move right, up or down


#1

Mario moves left but not in any other direction.

My code is below. Does the problem have anything to do with me using a MacBook Pro.

$(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({up: "-=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({down: "+=10px"}, 'fast');
				break;
		}
	});
});

#2

Hi Nigelleeinvicta,

You need to animate Mario in the top and left directions, and control right, left, up, and down, with either -= or += the number of pixels :)

Edit:
& no, your using a MBP shouldn't be affecting anything.


#3

I thought the code I have there is correct and complete. Could you point out what's wrong / missing.

Thanks


#4

@nigelleeinvicta I already told you what's wrong with your code, see my post above.
Or do you want me to be more specific?


#5

you have to write use the top and left keywords only. read the lesson more carefully. I had the same issue.

basically it says that if you type: ("item").animate({top: '+=10px},100) this particular code will move the image down if you want to move the image to the right then you use left: '+=10px'
hopefully this made some sense.


#6

I have the same problem: the img move only to the left.
If you know how to move image to the different direction would you please show it in the code.
thanks.


#8