Guest User

Untitled

a guest
Apr 23rd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. x=200
  2. y=130
  3. rojo=color.new(255,0,0)
  4. velocidad=2
  5. --Creamos las variables e iniciamos el Bucle
  6.  
  7. x2=math.random(0,460)
  8. y2=math.random(0,252)
  9.  
  10. while true do
  11. --Lectura de controles
  12. controls.read()
  13.  
  14. --Lectura de botones
  15. if controls.up() then y=y-velocidad elseif controls.down() then y=y+velocidad end
  16. if controls.left() then x=x-velocidad elseif controls.right() then x=x+velocidad end
  17.  
  18. --Dibujamos un rectangulo en las variables
  19. draw.fillrect(x,y,20,20,rojo)
  20. --Dibujamos otro en una zona aleatoria
  21. draw.fillrect(x2,y2,20,20,color.new(0,255,0))
  22.  
  23. --Actualizamos
  24. screen.flip()
  25.  
  26. --Si pulsas START provocarás un error (Para no tener que salir del Homebrew =)
  27. if controls.start() then broke() end
  28. end
Add Comment
Please, Sign In to add comment