Advertisement
Smartdumgood

😡 agery

Dec 23rd, 2024 (edited)
454
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.01 KB | None | 0 0
  1. local ScreenGui = Instance.new("ScreenGui")
  2. local MainFrame = Instance.new("Frame")
  3. local TopBar = Instance.new("Frame")
  4. local CloseButton = Instance.new("TextButton")
  5. local Bird = Instance.new("Frame")
  6. local Target = Instance.new("Frame")
  7. local ScoreFrame = Instance.new("Frame")
  8. local ScoreLabel = Instance.new("TextLabel")
  9. local PowerFrame = Instance.new("Frame")
  10. local PowerBar = Instance.new("Frame")
  11. local TitleLabel = Instance.new("TextLabel")
  12. local Ground = Instance.new("Frame")
  13. local SlingshotBase = Instance.new("Frame")
  14. local ResetButton = Instance.new("TextButton")
  15.  
  16. -- GUI Setup
  17. ScreenGui.Parent = game.CoreGui
  18. ScreenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
  19.  
  20. MainFrame.Name = "AngryBirdsGame"
  21. MainFrame.Parent = ScreenGui
  22. MainFrame.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
  23. MainFrame.Position = UDim2.new(0.3, 0, 0.3, 0)
  24. MainFrame.Size = UDim2.new(0, 400, 0, 300)
  25.  
  26. TopBar.Name = "TopBar"
  27. TopBar.Parent = MainFrame
  28. TopBar.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
  29. TopBar.Size = UDim2.new(1, 0, 0, 25)
  30. TopBar.Active = true
  31.  
  32. TitleLabel.Name = "TitleLabel"
  33. TitleLabel.Parent = TopBar
  34. TitleLabel.BackgroundTransparency = 1
  35. TitleLabel.Position = UDim2.new(0.02, 0, 0, 0)
  36. TitleLabel.Size = UDim2.new(0.5, 0, 1, 0)
  37. TitleLabel.Text = "Angry Birds"
  38. TitleLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
  39. TitleLabel.TextSize = 16
  40. TitleLabel.TextXAlignment = Enum.TextXAlignment.Left
  41.  
  42. CloseButton.Name = "CloseButton"
  43. CloseButton.Parent = TopBar
  44. CloseButton.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
  45. CloseButton.Position = UDim2.new(0.95, 0, 0, 0)
  46. CloseButton.Size = UDim2.new(0, 20, 0, 20)
  47. CloseButton.Text = "X"
  48. CloseButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  49.  
  50. ScoreFrame.Name = "ScoreFrame"
  51. ScoreFrame.Parent = MainFrame
  52. ScoreFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
  53. ScoreFrame.Position = UDim2.new(0.02, 0, 0.1, 0)
  54. ScoreFrame.Size = UDim2.new(0, 100, 0, 30)
  55.  
  56. ScoreLabel.Name = "ScoreLabel"
  57. ScoreLabel.Parent = ScoreFrame
  58. ScoreLabel.BackgroundTransparency = 1
  59. ScoreLabel.Size = UDim2.new(1, 0, 1, 0)
  60. ScoreLabel.Text = "Score: 0"
  61. ScoreLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
  62. ScoreLabel.TextSize = 16
  63.  
  64. PowerFrame.Name = "PowerFrame"
  65. PowerFrame.Parent = MainFrame
  66. PowerFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
  67. PowerFrame.Position = UDim2.new(0.02, 0, 0.2, 0)
  68. PowerFrame.Size = UDim2.new(0, 100, 0, 10)
  69.  
  70. PowerBar.Name = "PowerBar"
  71. PowerBar.Parent = PowerFrame
  72. PowerBar.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
  73. PowerBar.Size = UDim2.new(0, 0, 1, 0)
  74.  
  75. Ground.Name = "Ground"
  76. Ground.Parent = MainFrame
  77. Ground.BackgroundColor3 = Color3.fromRGB(76, 170, 76)
  78. Ground.Position = UDim2.new(0, 0, 0.9, 0)
  79. Ground.Size = UDim2.new(1, 0, 0.1, 0)
  80.  
  81. SlingshotBase.Name = "SlingshotBase"
  82. SlingshotBase.Parent = MainFrame
  83. SlingshotBase.BackgroundColor3 = Color3.fromRGB(139, 69, 19)
  84. SlingshotBase.Position = UDim2.new(0.1, -10, 0.7, 0)
  85. SlingshotBase.Size = UDim2.new(0, 40, 0, 60)
  86.  
  87. Bird.Name = "Bird"
  88. Bird.Parent = MainFrame
  89. Bird.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
  90. Bird.Position = UDim2.new(0.1, 0, 0.8, 0)
  91. Bird.Size = UDim2.new(0, 30, 0, 30)
  92. Bird.BorderSizePixel = 0
  93.  
  94. local UICorner = Instance.new("UICorner")
  95. UICorner.CornerRadius = UDim.new(1, 0)
  96. UICorner.Parent = Bird
  97.  
  98. Target.Name = "Target"
  99. Target.Parent = MainFrame
  100. Target.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
  101. Target.Position = UDim2.new(0.8, 0, 0.8, 0)
  102. Target.Size = UDim2.new(0, 40, 0, 40)
  103.  
  104. ResetButton.Name = "ResetButton"
  105. ResetButton.Parent = MainFrame
  106. ResetButton.BackgroundColor3 = Color3.fromRGB(65, 65, 65)
  107. ResetButton.Position = UDim2.new(0.85, 0, 0.1, 0)
  108. ResetButton.Size = UDim2.new(0, 60, 0, 25)
  109. ResetButton.Text = "Reset"
  110. ResetButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  111.  
  112. -- Dragging functionality
  113. local dragging, dragInput, dragStart, startPos
  114.  
  115. local function updateDrag(input)
  116. local delta = input.Position - dragStart
  117. MainFrame.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
  118. end
  119.  
  120. TopBar.InputBegan:Connect(function(input)
  121. if input.UserInputType == Enum.UserInputType.MouseButton1 then
  122. dragging = true
  123. dragStart = input.Position
  124. startPos = MainFrame.Position
  125. end
  126. end)
  127.  
  128. TopBar.InputEnded:Connect(function(input)
  129. if input.UserInputType == Enum.UserInputType.MouseButton1 then
  130. dragging = false
  131. end
  132. end)
  133.  
  134. TopBar.InputChanged:Connect(function(input)
  135. if input.UserInputType == Enum.UserInputType.MouseMovement then
  136. dragInput = input
  137. end
  138. end)
  139.  
  140. game:GetService("UserInputService").InputChanged:Connect(function(input)
  141. if input == dragInput and dragging then
  142. updateDrag(input)
  143. end
  144. end)
  145.  
  146. -- Game Logic
  147. local initialBirdPosition = Bird.Position
  148. local isDragging = false
  149. local startPos = nil
  150. local score = 0
  151.  
  152. local function randomizeTargetPosition()
  153. local newX = math.random(40, 85) / 100
  154. local newY = math.random(40, 85) / 100
  155. Target.Position = UDim2.new(newX, 0, newY, 0)
  156. Target.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
  157. end
  158.  
  159. local function createTrajectoryPoint()
  160. local point = Instance.new("Frame")
  161. point.Size = UDim2.new(0, 4, 0, 4)
  162. point.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  163. point.BorderSizePixel = 0
  164.  
  165. local UICorner = Instance.new("UICorner")
  166. UICorner.CornerRadius = UDim.new(1, 0)
  167. UICorner.Parent = point
  168.  
  169. return point
  170. end
  171.  
  172. local function clearTrajectoryPoints()
  173. for _, point in pairs(MainFrame:GetChildren()) do
  174. if point.Name == "TrajectoryPoint" then
  175. point:Destroy()
  176. end
  177. end
  178. end
  179.  
  180. local function updateTrajectory(mousePos)
  181. clearTrajectoryPoints()
  182. local force = (startPos - mousePos)
  183. local points = 20
  184.  
  185. for i = 0, points do
  186. local t = i / points
  187. local point = createTrajectoryPoint()
  188. point.Name = "TrajectoryPoint"
  189. point.Parent = MainFrame
  190.  
  191. local x = Bird.Position.X.Scale + (force.X/250) * t
  192. local y = Bird.Position.Y.Scale + (force.Y/250) * t + (0.5 * t * t)
  193.  
  194. point.Position = UDim2.new(x, 0, y, 0)
  195. end
  196. end
  197.  
  198. local function updatePowerBar(mousePos)
  199. local force = (startPos - mousePos).Magnitude
  200. local power = math.min(force / 100, 1)
  201. PowerBar.Size = UDim2.new(power, 0, 1, 0)
  202. end
  203.  
  204. local function resetBird()
  205. Bird.Position = initialBirdPosition
  206. PowerBar.Size = UDim2.new(0, 0, 1, 0)
  207. end
  208.  
  209. local function updateScore()
  210. score = score + 100
  211. ScoreLabel.Text = "Score: " .. score
  212. end
  213.  
  214. Bird.InputBegan:Connect(function(input)
  215. if input.UserInputType == Enum.UserInputType.MouseButton1 then
  216. isDragging = true
  217. startPos = game:GetService("UserInputService"):GetMouseLocation()
  218. end
  219. end)
  220.  
  221. game:GetService("UserInputService").InputChanged:Connect(function(input)
  222. if isDragging and input.UserInputType == Enum.UserInputType.MouseMovement then
  223. updateTrajectory(input.Position)
  224. updatePowerBar(input.Position)
  225. end
  226. end)
  227.  
  228. game:GetService("UserInputService").InputEnded:Connect(function(input)
  229. if input.UserInputType == Enum.UserInputType.MouseButton1 and isDragging then
  230. isDragging = false
  231. clearTrajectoryPoints()
  232. local endPos = game:GetService("UserInputService"):GetMouseLocation()
  233. local force = (startPos - endPos)
  234. local pullDistance = (startPos - endPos).Magnitude
  235. local powerMultiplier = math.min(pullDistance / 100, 3)
  236.  
  237. local tween = game:GetService("TweenService"):Create(Bird,
  238. TweenInfo.new(1, Enum.EasingStyle.Linear),
  239. {Position = UDim2.new(Bird.Position.X.Scale + (force.X/250) * powerMultiplier, 0,
  240. Bird.Position.Y.Scale + (force.Y/250) * powerMultiplier, 0)})
  241. tween:Play()
  242.  
  243. tween.Completed:Connect(function()
  244. if Target and Bird and
  245. (Bird.Position.X.Scale >= Target.Position.X.Scale - 0.1) and
  246. (Bird.Position.X.Scale <= Target.Position.X.Scale + 0.1) and
  247. (Bird.Position.Y.Scale >= Target.Position.Y.Scale - 0.1) and
  248. (Bird.Position.Y.Scale <= Target.Position.Y.Scale + 0.1) then
  249.  
  250. updateScore()
  251. Target.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
  252. wait(0.2)
  253. randomizeTargetPosition()
  254. end
  255. wait(0.5)
  256. resetBird()
  257. end)
  258. end
  259. end)
  260.  
  261. ResetButton.MouseButton1Click:Connect(function()
  262. resetBird()
  263. score = 0
  264. ScoreLabel.Text = "Score: 0"
  265. if not Target then
  266. Target = Instance.new("Frame")
  267. Target.Name = "Target"
  268. Target.Parent = MainFrame
  269. Target.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
  270. Target.Position = UDim2.new(0.8, 0, 0.8, 0)
  271. Target.Size = UDim2.new(0, 40, 0, 40)
  272. end
  273. randomizeTargetPosition()
  274. end)
  275.  
  276. CloseButton.MouseButton1Click:Connect(function()
  277. ScreenGui:Destroy()
  278. end)
  279.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement