Basically, I have a purple box. I want to animate it and make it move left by 250px, and i want it to then move down by 50px, then go right, and repeat that cycle. Here is what i have so far :
<!DOCTYPE html>
<html>
<body>
<div id="goodbox" style="height:50px;width:40px;background-color:purple;position:absolute"> </div>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js">
</script>
<script>
$(document).ready(function(){
$("#goodbox").animate({left:"300px"},5000)
$("#goodbox").animate({bottom:"300px"},5000)
})
</script>
</body>
</html>
You see after it animates left, it then moves to the bottom of the screen and then animates, but i want it to move from where it left off. So basically: move left 250px; move down 20px; move right 250px; move up 20px; then to repeat
How do I do this? And lets just say I have this other blue box. Lets say I give this box functions, so if i press the left key it'll move left, right key right. down key down and up key up. How could i then make the purple box stop moving if these two boxes make contact. Thanks in advance to anyone willing to answer this.