I need save values the list points and sum new values without sum id

Hi, I need save the last values for sum new values in points to show the cards in the same position the player. But i have a problem when try first time the position is correct and the same numbers of dices, but when try second time show other card because is lots the value of dice.
the number {1:0} in list represent the id of player

I try this solution but not working.

let dice;
let points = {1:0};

var x = Math.floor(Math.random() * ((6 - 1) + 1) + 1);
var y = Math.floor(Math.random() * ((6 - 1) + 1) + 1);

dice = x+y;
points = {1: dice};
console.log(points, “teste de dados”);
movePlayers(points);
updatePlayers();
createCards(points);
updateRound();
}

function createCards(points) {

let n= 0;
let c = {1:n};

backImg = loadImage(’./assets/images/back.png’);
for (let i = 0; i < deckcards.length; i++){
for (let j = 0; j < points[i]; j++){
console.log(points[i]);
for (let k = 0; k < c[i]; k++){
image(cardsImg[c[i]], 310, 130, 250,350);
//console.log(cardsImg[points[i]],“teste de casas”);
n = n + points[i];
}
}
}
}

Hi,

First of all, please format your code by using the </> button in the message editor. (Tip : you can auto indent your code by pressing Ctrl+T in the Processing IDE)

Could you be more precise? Try to explain your problem more clearly. Are you building a card game?
Maybe a screenshot would also help :slight_smile:

1 Like

Please don’t load this image here

Better load it in setup()

1 Like