オブジェクト要素に 1 ~ 50 のランダム値を割り当てています。5 つのオブジェクトがあります。理由はわかりませんが、すべてのオブジェクトが同じランダム値を取得しています...
ここに私のコードがあります:
var SmileyRed = {
radius: 15,
xspeed: 0,
yspeed: 0,
xpos:350, // x-position of smiley
ypos: 65 // y-position of smiley
};
var SmileyReds = new Array();
for (var i=0; i<5; i++){
SmileyReds[i] = SmileyRed;
SmileyReds[i].xspeed = Math.floor((Math.random()*50)+1);
SmileyReds[i].yspeed = Math.floor((Math.random()*50)+1);
}
SmileyReds[0].xspeed と SmileyReds[3].xspeed は同じ値ですが、異なるべきではありませんか?