jinc0930 / Clue

A game
2 stars 0 forks source link

player character always spawns in the same room #14

Closed jinc0930 closed 2 years ago

jinc0930 commented 2 years ago

as the title suggests, the character needs to spawn more randomized.

mishimalisa commented 2 years ago

I don't know if it's intended, but every character is always in the same room. Only the rooms position are random, but the room name is always paired with the same character, that also pairs with the same item.

The solution is probably shuffle every single array. Maybe even a better solution is using our already created Pool structure.

// make a pool (characters) using our existing function
// -1 is the index we want to exclude which is none
// 9 is size of the pool
// 1 is how many times an item should be taken to be removed from the pool
struct pool = makePool(-1, 9, 1);

// loop 9 times, getting a random index 
for (size_t i = 0; i < 9; i++) {
  // takes a random index from the pool
  int rnd_idx = poolGet(pool, 1);
  addChar ( charrarr[rnd_idx] );
}