I'm currently trying to create brick breaker using love2d but the problem is whenever is used math.random() to generate random bricks the love application keeps running it multiple times and the brick moves constantly. So I changed and I tried initializing a random variable in load function and in the draw function if the value equates then it draws the bricks
My code
if math.random(2) == 1 then
line2 = 1
end
this in the load function
for y = 0, VIRTUAL_HEIGHT- 4, 10 do
if line2 == 1 then
love.graphics.rectangle('line', VIRTUAL_WIDTH - 10, y, 5, 10)
end
end
and this in the draw function NOTE- line2 is initialized to 0 in the start. Please Help!!!
Aucun commentaire:
Enregistrer un commentaire