Added berries
This commit is contained in:
1 parent
0f1d574da3
commit
bee846c3ba
10 files changed
+145
-1
No files matched your search
@@ -0,0 +1,29 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class Berries : Node2D {
|
||||
private float SpawnBerryTimer = 0f;
|
||||
|
||||
public override void _Process(double delta) {
|
||||
Vector2 Pos = Position;
|
||||
Pos.Y += 500f * (float)delta;
|
||||
|
||||
SpawnBerryTimer += (float)delta;
|
||||
|
||||
int ScreenWidth = DisplayServer.WindowGetSize().X;
|
||||
|
||||
if (SpawnBerryTimer > 1.0) {
|
||||
SpawnBerryTimer = 0f;
|
||||
|
||||
PackedScene Berry = GD.Load<PackedScene>("res://Prefabs/Berries/Berry.tscn");
|
||||
|
||||
Node2D BerryInstance = Berry.Instantiate<Node2D>();
|
||||
|
||||
BerryInstance.Position = new Vector2(x: new Random().Next(-(ScreenWidth / 2), ScreenWidth / 2), y: -100 - Position.Y);
|
||||
|
||||
AddChild(BerryInstance);
|
||||
}
|
||||
|
||||
Position = Pos;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user