samedi 15 juin 2019

How to get one of random index from an array in love2d

I am working on a project that i have select a random index from an array that i created. Here the array

kotak = { 
    love.graphics.newImage('images/1.png'),
    love.graphics.newImage('images/2.png')
  }

And i want to get one of the index of this array, and my code like this

randomKotak = love.math.random(#kotak)  
love.graphics.draw(kotak[randomKotak], 200,200, 0.05 , 1, 1, 16, 16)

but i get the result is value of index is always changing. how i can get only one of the index. no changing.




Aucun commentaire:

Enregistrer un commentaire