Advertisement
xerpi

lol

May 29th, 2011
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.10 KB | None | 0 0
  1. ang=0
  2. vel=1
  3. basket = {x=210,y=20,w=60,h=40}
  4.  
  5. ball = {img=image.load("SYSTEM/resources/balls/usedball/ball.png"),x=240,y=136}
  6. ball.w= ball.img:width()
  7. ball.h= ball.img:height()
  8.  
  9.  
  10. radius=20
  11. score=0
  12.  
  13. function colision(obj1,obj2)
  14. if obj1.x>= obj2.x and
  15.     obj1.x <= obj2.x+obj2.w and
  16.     obj1.y >= obj2.y and
  17.     obj1.y <= obj2.y+obj2.h  then
  18.     return true else return false
  19. end
  20. end
  21.  
  22.  
  23.  
  24. while true do
  25. ball.x=240+math.cos(math.rad(ang))*radius
  26. ball.y=136+math.sin(math.rad(ang))*radius
  27.  
  28. ang=ang+vel
  29. controls.read()
  30. draw.rect(basket.x,basket.y,basket.w,basket.h,color.new(255,0,0))
  31.  
  32. ball.img:blit(ball.x,ball.y)
  33.  
  34. if controls.up() then radius=radius+0.5 end
  35. if controls.down() then radius=radius-0.5 end
  36. if controls.r() then vel=vel+0.1 end
  37. if controls.l() then vel=vel-0.1 end
  38. if controls.analogx()  >100 then vel=vel+0.5 end
  39. if controls.analogx()  <-100 then vel=vel-0.5 end
  40.  
  41. if controls.press("cross") then
  42.     if colision(ball,basket) then
  43.         score=score+10
  44.     end
  45. end
  46.  
  47.  
  48. screen.print(5,5,"Score: "..score.."   Rad: "..radius.."   Vel: "..vel)
  49.  
  50. if controls.select() then a() end
  51. screen.flip()
  52. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement