...

View Full Version : random movement



gencoglu
01-29-2009, 08:20 PM
Hi, I am tring to make an object move across the screen randomly..I want it move up-down left or right acording to the values created..for example I want my object move between value (-5 and +5 ) whats wrong with this ? because it always moves downward ???
thanks ?


on(press)
{
dur=setInterval(kos,200);
function kos(){
var rn1=Math.floor(Math.random()*(5-10))+10;
var rn2=Math.floor(Math.random()*(5-10))+10;


_root.car._x+=rn1;
_root.car._y+=rn2;

kutu.text="..."+rn1+"..."+rn2;
}}

gnomeontherun
01-30-2009, 10:46 AM
Can I see the whole code and maybe an example?

gencoglu
01-30-2009, 12:08 PM
ok.. I solved the problem...as
var rn1=Math.round(Math.random()*-10)+5;
var rn2=Math.round(Math.random()*-10)+5;
thanks..



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum