samedi 21 janvier 2017

Random bubble in jQuery

Hi I made something to generate random bubble with Coffeescript:

creaBolla = ->
bolla = $("<div>").addClass("bolla")
vx = Math.random()*0.3-0.15
vy = Math.random()*0.3-0.15
x = Math.random()*1200; 
y = Math.random()*600;
step = ->
  x += vx; y += vy
  bolla.css({top:y, left:x})
bolla.click ->
  vx = 0; vy = 2
$("#universe").append(bolla)
setInterval(step, 10)

setInterval(creaBolla, 1000)

Can someone help me have the same result just with jQuery?




Aucun commentaire:

Enregistrer un commentaire