Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ScreenGui = Instance.new("ScreenGui")
- local MainFrame = Instance.new("Frame")
- local TopBar = Instance.new("Frame")
- local CloseButton = Instance.new("TextButton")
- local Bird = Instance.new("Frame")
- local Target = Instance.new("Frame")
- local ScoreFrame = Instance.new("Frame")
- local ScoreLabel = Instance.new("TextLabel")
- local PowerFrame = Instance.new("Frame")
- local PowerBar = Instance.new("Frame")
- local TitleLabel = Instance.new("TextLabel")
- local Ground = Instance.new("Frame")
- local SlingshotBase = Instance.new("Frame")
- local ResetButton = Instance.new("TextButton")
- -- GUI Setup
- ScreenGui.Parent = game.CoreGui
- ScreenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
- MainFrame.Name = "AngryBirdsGame"
- MainFrame.Parent = ScreenGui
- MainFrame.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
- MainFrame.Position = UDim2.new(0.3, 0, 0.3, 0)
- MainFrame.Size = UDim2.new(0, 400, 0, 300)
- TopBar.Name = "TopBar"
- TopBar.Parent = MainFrame
- TopBar.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
- TopBar.Size = UDim2.new(1, 0, 0, 25)
- TopBar.Active = true
- TitleLabel.Name = "TitleLabel"
- TitleLabel.Parent = TopBar
- TitleLabel.BackgroundTransparency = 1
- TitleLabel.Position = UDim2.new(0.02, 0, 0, 0)
- TitleLabel.Size = UDim2.new(0.5, 0, 1, 0)
- TitleLabel.Text = "Angry Birds"
- TitleLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
- TitleLabel.TextSize = 16
- TitleLabel.TextXAlignment = Enum.TextXAlignment.Left
- CloseButton.Name = "CloseButton"
- CloseButton.Parent = TopBar
- CloseButton.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
- CloseButton.Position = UDim2.new(0.95, 0, 0, 0)
- CloseButton.Size = UDim2.new(0, 20, 0, 20)
- CloseButton.Text = "X"
- CloseButton.TextColor3 = Color3.fromRGB(255, 255, 255)
- ScoreFrame.Name = "ScoreFrame"
- ScoreFrame.Parent = MainFrame
- ScoreFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
- ScoreFrame.Position = UDim2.new(0.02, 0, 0.1, 0)
- ScoreFrame.Size = UDim2.new(0, 100, 0, 30)
- ScoreLabel.Name = "ScoreLabel"
- ScoreLabel.Parent = ScoreFrame
- ScoreLabel.BackgroundTransparency = 1
- ScoreLabel.Size = UDim2.new(1, 0, 1, 0)
- ScoreLabel.Text = "Score: 0"
- ScoreLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
- ScoreLabel.TextSize = 16
- PowerFrame.Name = "PowerFrame"
- PowerFrame.Parent = MainFrame
- PowerFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
- PowerFrame.Position = UDim2.new(0.02, 0, 0.2, 0)
- PowerFrame.Size = UDim2.new(0, 100, 0, 10)
- PowerBar.Name = "PowerBar"
- PowerBar.Parent = PowerFrame
- PowerBar.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
- PowerBar.Size = UDim2.new(0, 0, 1, 0)
- Ground.Name = "Ground"
- Ground.Parent = MainFrame
- Ground.BackgroundColor3 = Color3.fromRGB(76, 170, 76)
- Ground.Position = UDim2.new(0, 0, 0.9, 0)
- Ground.Size = UDim2.new(1, 0, 0.1, 0)
- SlingshotBase.Name = "SlingshotBase"
- SlingshotBase.Parent = MainFrame
- SlingshotBase.BackgroundColor3 = Color3.fromRGB(139, 69, 19)
- SlingshotBase.Position = UDim2.new(0.1, -10, 0.7, 0)
- SlingshotBase.Size = UDim2.new(0, 40, 0, 60)
- Bird.Name = "Bird"
- Bird.Parent = MainFrame
- Bird.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
- Bird.Position = UDim2.new(0.1, 0, 0.8, 0)
- Bird.Size = UDim2.new(0, 30, 0, 30)
- Bird.BorderSizePixel = 0
- local UICorner = Instance.new("UICorner")
- UICorner.CornerRadius = UDim.new(1, 0)
- UICorner.Parent = Bird
- Target.Name = "Target"
- Target.Parent = MainFrame
- Target.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
- Target.Position = UDim2.new(0.8, 0, 0.8, 0)
- Target.Size = UDim2.new(0, 40, 0, 40)
- ResetButton.Name = "ResetButton"
- ResetButton.Parent = MainFrame
- ResetButton.BackgroundColor3 = Color3.fromRGB(65, 65, 65)
- ResetButton.Position = UDim2.new(0.85, 0, 0.1, 0)
- ResetButton.Size = UDim2.new(0, 60, 0, 25)
- ResetButton.Text = "Reset"
- ResetButton.TextColor3 = Color3.fromRGB(255, 255, 255)
- -- Dragging functionality
- local dragging, dragInput, dragStart, startPos
- local function updateDrag(input)
- local delta = input.Position - dragStart
- MainFrame.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
- end
- TopBar.InputBegan:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- dragging = true
- dragStart = input.Position
- startPos = MainFrame.Position
- end
- end)
- TopBar.InputEnded:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- dragging = false
- end
- end)
- TopBar.InputChanged:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseMovement then
- dragInput = input
- end
- end)
- game:GetService("UserInputService").InputChanged:Connect(function(input)
- if input == dragInput and dragging then
- updateDrag(input)
- end
- end)
- -- Game Logic
- local initialBirdPosition = Bird.Position
- local isDragging = false
- local startPos = nil
- local score = 0
- local function randomizeTargetPosition()
- local newX = math.random(40, 85) / 100
- local newY = math.random(40, 85) / 100
- Target.Position = UDim2.new(newX, 0, newY, 0)
- Target.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
- end
- local function createTrajectoryPoint()
- local point = Instance.new("Frame")
- point.Size = UDim2.new(0, 4, 0, 4)
- point.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
- point.BorderSizePixel = 0
- local UICorner = Instance.new("UICorner")
- UICorner.CornerRadius = UDim.new(1, 0)
- UICorner.Parent = point
- return point
- end
- local function clearTrajectoryPoints()
- for _, point in pairs(MainFrame:GetChildren()) do
- if point.Name == "TrajectoryPoint" then
- point:Destroy()
- end
- end
- end
- local function updateTrajectory(mousePos)
- clearTrajectoryPoints()
- local force = (startPos - mousePos)
- local points = 20
- for i = 0, points do
- local t = i / points
- local point = createTrajectoryPoint()
- point.Name = "TrajectoryPoint"
- point.Parent = MainFrame
- local x = Bird.Position.X.Scale + (force.X/250) * t
- local y = Bird.Position.Y.Scale + (force.Y/250) * t + (0.5 * t * t)
- point.Position = UDim2.new(x, 0, y, 0)
- end
- end
- local function updatePowerBar(mousePos)
- local force = (startPos - mousePos).Magnitude
- local power = math.min(force / 100, 1)
- PowerBar.Size = UDim2.new(power, 0, 1, 0)
- end
- local function resetBird()
- Bird.Position = initialBirdPosition
- PowerBar.Size = UDim2.new(0, 0, 1, 0)
- end
- local function updateScore()
- score = score + 100
- ScoreLabel.Text = "Score: " .. score
- end
- Bird.InputBegan:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- isDragging = true
- startPos = game:GetService("UserInputService"):GetMouseLocation()
- end
- end)
- game:GetService("UserInputService").InputChanged:Connect(function(input)
- if isDragging and input.UserInputType == Enum.UserInputType.MouseMovement then
- updateTrajectory(input.Position)
- updatePowerBar(input.Position)
- end
- end)
- game:GetService("UserInputService").InputEnded:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 and isDragging then
- isDragging = false
- clearTrajectoryPoints()
- local endPos = game:GetService("UserInputService"):GetMouseLocation()
- local force = (startPos - endPos)
- local pullDistance = (startPos - endPos).Magnitude
- local powerMultiplier = math.min(pullDistance / 100, 3)
- local tween = game:GetService("TweenService"):Create(Bird,
- TweenInfo.new(1, Enum.EasingStyle.Linear),
- {Position = UDim2.new(Bird.Position.X.Scale + (force.X/250) * powerMultiplier, 0,
- Bird.Position.Y.Scale + (force.Y/250) * powerMultiplier, 0)})
- tween:Play()
- tween.Completed:Connect(function()
- if Target and Bird and
- (Bird.Position.X.Scale >= Target.Position.X.Scale - 0.1) and
- (Bird.Position.X.Scale <= Target.Position.X.Scale + 0.1) and
- (Bird.Position.Y.Scale >= Target.Position.Y.Scale - 0.1) and
- (Bird.Position.Y.Scale <= Target.Position.Y.Scale + 0.1) then
- updateScore()
- Target.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
- wait(0.2)
- randomizeTargetPosition()
- end
- wait(0.5)
- resetBird()
- end)
- end
- end)
- ResetButton.MouseButton1Click:Connect(function()
- resetBird()
- score = 0
- ScoreLabel.Text = "Score: 0"
- if not Target then
- Target = Instance.new("Frame")
- Target.Name = "Target"
- Target.Parent = MainFrame
- Target.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
- Target.Position = UDim2.new(0.8, 0, 0.8, 0)
- Target.Size = UDim2.new(0, 40, 0, 40)
- end
- randomizeTargetPosition()
- end)
- CloseButton.MouseButton1Click:Connect(function()
- ScreenGui:Destroy()
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement