Version 0.1 - 0.3.1
Added the World Added Mobs, and spawning those mobs at runtime Added simple camera movement Added simple UI/HUD
This commit is contained in:
64
scenes/entities/fly/Fly.cs
Normal file
64
scenes/entities/fly/Fly.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using Math = Ecosystem.utility.Math;
|
||||
|
||||
public partial class Fly : BaseEntity
|
||||
{
|
||||
[Export] public float _tx = 0;
|
||||
[Export] public float _ty = 10000f;
|
||||
[Export] public float StepSizeX = .01f;
|
||||
[Export] public float StepSizeY = .1f;
|
||||
|
||||
// private Perlin perlin = new Perlin();
|
||||
|
||||
private FastNoiseLite noise = new FastNoiseLite();
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
base._Ready();
|
||||
|
||||
noise.SetSeed(GD.RandRange(int.MinValue, int.MaxValue));
|
||||
|
||||
// Position = ScreenSize / 2;
|
||||
animationPlayer.Play("fly");
|
||||
}
|
||||
|
||||
public void CreateRandom()
|
||||
{
|
||||
float randomTX = GD.Randf() % 10000;
|
||||
float randomTY = GD.Randf() % 10000;
|
||||
float randomStepSizeX = GD.Randf() % .1f;
|
||||
float randomStepSizeY = GD.Randf() % .1f;
|
||||
|
||||
_tx = randomTX;
|
||||
_ty = randomTY;
|
||||
StepSizeX = randomStepSizeX;
|
||||
StepSizeY = randomStepSizeY;
|
||||
}
|
||||
|
||||
private void step()
|
||||
{
|
||||
// double xNoise = perlin.Noise(_tx);
|
||||
// double yNoise = perlin.Noise(_ty);
|
||||
//
|
||||
|
||||
var xNoise = noise.GetNoise1D(_tx);
|
||||
var yNoise = noise.GetNoise1D(_ty);
|
||||
// var noiseVal = noise.GetNoise2D(_tx, _ty);
|
||||
|
||||
float x = Math.Map(xNoise, 0, 1, 0, ScreenSize.X);
|
||||
float y = Math.Map(yNoise, 0, 1, 0, ScreenSize.Y);
|
||||
|
||||
Position = new Vector2(
|
||||
x: Mathf.Clamp(x, 0, ScreenSize.X),
|
||||
y: Mathf.Clamp(y, 0, ScreenSize.Y));
|
||||
|
||||
_tx += StepSizeX;
|
||||
_ty += StepSizeY;
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
step();
|
||||
}
|
||||
}
|
||||
1
scenes/entities/fly/Fly.cs.uid
Normal file
1
scenes/entities/fly/Fly.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cjf04oa55b5sb
|
||||
67
scenes/entities/fly/fly.tscn
Normal file
67
scenes/entities/fly/fly.tscn
Normal file
@@ -0,0 +1,67 @@
|
||||
[gd_scene load_steps=8 format=3 uid="uid://imihi2lpdd0r"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://b0q03xfp1iy6t" path="res://scenes/entities/BaseEntity.tscn" id="1_dir30"]
|
||||
[ext_resource type="Texture2D" uid="uid://bcb027pj21is2" path="res://art/mobs/fly/fly_spritesheet.png" id="2_vd504"]
|
||||
[ext_resource type="Script" uid="uid://cjf04oa55b5sb" path="res://scenes/entities/fly/Fly.cs" id="2_wo7w7"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_k060o"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [0]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_wo7w7"]
|
||||
resource_name = "fly"
|
||||
length = 0.0593
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.0333333),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 1,
|
||||
"values": [0, 1]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_88wi0"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_k060o"),
|
||||
&"fly": SubResource("Animation_wo7w7")
|
||||
}
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_8dfjp"]
|
||||
radius = 5.0
|
||||
height = 10.0
|
||||
|
||||
[node name="Fly" instance=ExtResource("1_dir30")]
|
||||
script = ExtResource("2_wo7w7")
|
||||
_tx = 0.0
|
||||
_ty = 10000.0
|
||||
StepSizeX = 0.01
|
||||
StepSizeY = 0.1
|
||||
|
||||
[node name="Sprite2D" parent="." index="0"]
|
||||
texture_filter = 1
|
||||
texture = ExtResource("2_vd504")
|
||||
hframes = 2
|
||||
|
||||
[node name="AnimationPlayer" parent="Sprite2D" index="0"]
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_88wi0")
|
||||
}
|
||||
|
||||
[node name="CollisionShape2D" parent="." index="1"]
|
||||
shape = SubResource("CapsuleShape2D_8dfjp")
|
||||
Reference in New Issue
Block a user