11. Filling Out the Cases


Can anyone explain why it's not correct?
Mario is moving properly

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

Replace this line with your code.


In the preview did you move up, down, left and right ?


The reason is that you actually have to play it by preessing they keys as you click run.. So do this in sequence.. play run, move with your arrow keys, then press back to editor.. If your code is correct and mario moves properly it should work then.. if it dosent........ reply saying so.


Hei, i've the same problem there. The code is just look like that and when i press the arrow key (right, up and down), it doesn't show the effect. It just show the effect if i press the left key.


2 posts were split to a new topic: 11. Filling Out the Cases