Advertisement
xerpi

Take the ball by xerpi

May 29th, 2011
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.19 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+obj1.w <= obj2.x+obj2.w and
  16.     obj1.y >= obj2.y and
  17.     obj1.y+obj1.h <= 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.  
  29. ang=ang+vel
  30. controls.read()
  31. draw.rect(basket.x,basket.y,basket.w,basket.h,color.new(255,0,0))
  32.  
  33. ball.img:blit(ball.x,ball.y)
  34.  
  35. if controls.up() then radius=radius+0.5 end
  36. if controls.down() then radius=radius-0.5 end
  37. if controls.r() then vel=vel+0.1 end
  38. if controls.l() then vel=vel-0.1 end
  39. if controls.analogx()  >100 then vel=vel+0.5 end
  40. if controls.analogx()  <-100 then vel=vel-0.5 end
  41.  
  42. if controls.press("cross") then
  43.     if colision(ball,basket) then
  44.         score=score+10
  45.     end
  46. end
  47.  
  48.  
  49. screen.print(5,5,"Score: "..score.."   Rad: "..radius.."   Vel: "..vel)
  50. screen.print(5,25,"Up-Down radius")
  51. screen.print(5,45,"L-R velocity")
  52.  
  53.  
  54.  
  55. if controls.select() then a() end
  56. screen.flip()
  57. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement