Moved movement speed to globals

idk why I didnt do this already but whatever
This commit is contained in:
Puppet committed 2025-10-07 19:22:10 -07:00
1 parent 03c6381e34
commit 80646fadbf
2 files changed
+4 -3

No files matched your search

+2
View File
@@ -6,6 +6,8 @@ public partial class Globals : Node {
public static string AccessLevel = ""; public static string AccessLevel = "";
public static bool VersionChecked = false; public static bool VersionChecked = false;
public static float MovementSpeed = 800f;
public static int Score = 0; public static int Score = 0;
public static int HighScore = 0; public static int HighScore = 0;
} }
+2 -3
View File
@@ -2,7 +2,6 @@ using Godot;
using System; using System;
public partial class Player : Node2D { public partial class Player : Node2D {
private float MovementSpeed = 800f;
private float ScreenBorders = 120f; private float ScreenBorders = 120f;
public override void _Ready() { public override void _Ready() {
@@ -19,13 +18,13 @@ public partial class Player : Node2D {
if ((Input.IsKeyPressed((Key)Key.Left) || Input.IsKeyPressed((Key)Key.A)) && Pos.X > ScreenBorders) { if ((Input.IsKeyPressed((Key)Key.Left) || Input.IsKeyPressed((Key)Key.A)) && Pos.X > ScreenBorders) {
GetNode<Sprite2D>("Texture").FlipH = false; GetNode<Sprite2D>("Texture").FlipH = false;
Pos.X -= MovementSpeed * (float)delta; Pos.X -= Globals.MovementSpeed * (float)delta;
} }
float ScreenWidth = (WindowSize.X / WindowScale.X) - ScreenBorders; float ScreenWidth = (WindowSize.X / WindowScale.X) - ScreenBorders;
if ((Input.IsKeyPressed((Key)Key.Right) || Input.IsKeyPressed((Key)Key.D)) && Pos.X < ScreenWidth) { if ((Input.IsKeyPressed((Key)Key.Right) || Input.IsKeyPressed((Key)Key.D)) && Pos.X < ScreenWidth) {
GetNode<Sprite2D>("Texture").FlipH = true; GetNode<Sprite2D>("Texture").FlipH = true;
Pos.X += MovementSpeed * (float)delta; Pos.X += Globals.MovementSpeed * (float)delta;
} }
Position = Pos; Position = Pos;