i did this one, adding more an if for when the car has the same stone's postion. but it doenst work again.
it moves but doesnt have less 10px on top.
- /**
- * @author Stenio Ramos
- */
- $(document).ready(function(){
- var car = $("#car, #front, .wheel");
-
- $(document).keydown(function(key) {
- switch(parseInt(key.which, 10)) {
- case 65:
- car.animate({left: "-=10px"}, 'fast');
- break;
- case 83:
- car.animate({top: "+=10px"}, 'fast');
- break;
- case 87:
- car.animate({top: "-=10px"}, 'fast');
- break;
- case 68:
- car.animate({left: "+=10px"}, 'fast');
- break;
- default:
- break;
- }
- });
- var carpos = car.css(["top", "top"]);
- var stonepos = $('#stone').css(["top", "top"]);
-
- if(carpos === stonepos){
- car.animate({top: "-=10px"}, 'fast');
- }
- //$('#car').css('height', '300px');
-
- });
css() without the value, only with the property returns its value, right?