using Godot; using System; using System.Collections; using System.Collections.Generic; using PopTheLockClone; public partial class PaddlePivotTest : Node2D { [Export] public float RotationSpeed = 90; [Export] public Label FPS; [Export] public Label HitsLeft; [Export] public Node2D[] shapes; private List myNums; private Color[] colors = new Color[] { Colors.RebeccaPurple, Colors.SpringGreen, Colors.GreenYellow, Colors.AliceBlue, Colors.AntiqueWhite }; private bool direction = false; private float base_speed = 80; private float max_speed = 200; private int total_hits = 50; private int hits_left; private Color round1 = Color.FromHtml("#7aed00"); private Color currentColor; private GameManager.State state; public override void _Ready() { Engine.MaxFps = 0; hits_left = total_hits; HitsLeft.Text = total_hits.ToString(); myNums = new List(); currentColor = round1; SetShapesColor(); } private void UpdateRotationSpeed() { int hits_done = total_hits - hits_left; float progress = hits_done / (float)total_hits; RotationSpeed = base_speed + (max_speed - base_speed) * progress; } public override void _Process(double delta) { FPS.Text = "FPS: " + Engine.GetFramesPerSecond(); if (GameManager.CurrentState != state) { state = GameManager.CurrentState; OnStateChange(); } if (Input.IsActionJustPressed("Press")) { UpdateRotationSpeed(); direction = !direction; hits_left--; HitsLeft.Text = hits_left.ToString(); } if (GameManager.CurrentState == GameManager.State.PLAY) { Rotation += Mathf.DegToRad((float)delta * (direction ? RotationSpeed : -RotationSpeed)); } } private void SetShapesColor() { for (int i = 0; i < shapes.Length; i++) { shapes[i].Set("color", currentColor); } } private void OnStateChange() { if (state == GameManager.State.IDLE) { currentColor = round1; SetShapesColor(); Rotation = 0; } else if (state == GameManager.State.PLAY) { currentColor = round1; SetShapesColor(); } else if (state == GameManager.State.LOSS) { } else if (state == GameManager.State.WIN) { } } }