lundi 20 septembre 2021

Guess the image game, Random Image generator without repetition

I wanna make image guessing android game, there are 150 images, I want the image to be generated randomly, and the user should type the name of character if it is correct the next button will display another image till the 150 are finished

This the code for avoiding image repition

ArrayList<Integer> list = new ArrayList<Integer>();
list.add(R.drawable.myImage);
int position = new Random().nextInt(list.size());
imageViewObject.setImageResource(Integer.intValue(list.get(position)));
list.remove(position);

but how should I compare the user input with character name, should I use image path, or make array for answers and compare it to user input?




Aucun commentaire:

Enregistrer un commentaire