jeudi 4 juin 2020

How to randomize a place in array

Im trying to code the game Minesweeper and for that i need to randomize the bombs locations. can someone help change the function a bit so it can be randomized?

THE CODE:

void Createbomb(int*** bord, int size)//size+1
{
    //bomb num.1
    (*bord)[size - 5][size - 1] = 9;
    //bomb num.2
    (*bord)[size - 4][size - 4] = 9;
    //bomb num.3
    (*bord)[size - 3][size - 2] = 9;
    //bomb num.4
    (*bord)[size - 2][size - 2] = 9;
    //bomb num.5
    (*bord)[size - 1][size - 5] = 9;
}



Aucun commentaire:

Enregistrer un commentaire