Mario


#1

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

Codeacademy says everything is fine but Mario won't move to the right. He stops, when i press the right arrow. Why isn't it working? :frowning:


$(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:
				$('img').animate({top: "-=10px"}, 'fast');
				break;
			// Right Arrow Pressed
			case 39:
				$('img').animate({right: "+=10px"}, 'fast');
				break;
			// Down Arrow Pressed
			case 40:
				$('img').animate({top: "+=10px"}, 'fast');
				break;
		}
	});
});

#2

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

you have to use left instead of right.we add 10px to the left(check .css file)


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.