It stacks just like in normal bd btw. So if you get 2 ultra berries you will have the effect for 20 seconds. Also this was surprisingly easy to add.
49 lines
1.6 KiB
C#
49 lines
1.6 KiB
C#
using Godot;
|
|
using System;
|
|
|
|
public partial class Player : Node2D {
|
|
private float ScreenBorders = 120f;
|
|
|
|
public override void _Ready() {
|
|
Position = new Vector2(x: DisplayServer.WindowGetSize().X / 2, y: 0);
|
|
}
|
|
|
|
public override void _Process(double delta) {
|
|
var ScreenSize = GetViewport().GetVisibleRect().Size;
|
|
var WindowSize = DisplayServer.WindowGetSize();
|
|
var WindowScale = WindowSize / ScreenSize;
|
|
|
|
Vector2 Pos = Position;
|
|
Pos.Y = (WindowSize.Y / WindowScale.Y) - 100;
|
|
|
|
if ((Input.IsKeyPressed((Key)Key.Left) || Input.IsKeyPressed((Key)Key.A)) && Pos.X > ScreenBorders) {
|
|
GetNode<Sprite2D>("Texture").FlipH = false;
|
|
Pos.X -= Globals.MovementSpeed * (float)delta;
|
|
}
|
|
|
|
float ScreenWidth = (WindowSize.X / WindowScale.X) - ScreenBorders;
|
|
if ((Input.IsKeyPressed((Key)Key.Right) || Input.IsKeyPressed((Key)Key.D)) && Pos.X < ScreenWidth) {
|
|
GetNode<Sprite2D>("Texture").FlipH = true;
|
|
Pos.X += Globals.MovementSpeed * (float)delta;
|
|
}
|
|
|
|
Position = Pos;
|
|
|
|
// Effect handling
|
|
if (Globals.ActiveEffect != "none") {
|
|
Globals.EffectTimer -= (float)delta;
|
|
}
|
|
|
|
if (Globals.EffectTimer < 0f) {
|
|
Globals.EffectTimer = 0f;
|
|
Globals.ActiveEffect = "none";
|
|
}
|
|
|
|
if (Globals.ActiveEffect == "none") {
|
|
Globals.MovementSpeed = Globals.DefaultMovementSpeed;
|
|
} if (Globals.ActiveEffect == "ultra") {
|
|
Globals.MovementSpeed = Globals.DefaultMovementSpeed * 2f;
|
|
}
|
|
}
|
|
}
|