Godot Nature of Code  1.2.0
Nature of Code implemented in Godot Engine
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
Ecosystem.Ecosystem.SwimmingFish Class Reference

Swimming fish. More...

Inheritance diagram for Ecosystem.Ecosystem.SwimmingFish:
Ecosystem.Ecosystem.Lifeform Forces.SimpleMover

Public Member Functions

 SwimmingFish ()
 Create a swimming fish. More...
 
- Public Member Functions inherited from Forces.SimpleMover
 SimpleMover ()
 Create a simple wrapping mover with a circle mesh. More...
 
 SimpleMover (WrapModeEnum wrapMode)
 Create a simple mover with a custom wrap mode and a circle mesh. More...
 
virtual void ApplyForce (Vector2 force)
 Apply force on mover. More...
 
virtual void ApplyAngularForce (float force)
 Apply angular force on mover. More...
 
virtual void ApplyFriction (float coef)
 Apply friction on mover. More...
 
virtual void ApplyAngularFriction (float coef)
 Apply angular friction on mover. More...
 
virtual void ApplyDrag (float coef)
 Apply drag on mover. More...
 
virtual void ApplyDamping (float coef)
 Apply damping on mover. More...
 

Public Attributes

float TailSpeed = 10f
 Tail speed More...
 
Color BaseColor = Colors.CadetBlue
 Base color More...
 
float ForwardAcceleration = 0.25f
 Forward acceleration More...
 
float SideOffsetAcceleration = 0.1f
 Side offset acceleration More...
 
- Public Attributes inherited from Ecosystem.Ecosystem.Lifeform
bool DebugDrawEnabled
 Debug draw enabled? More...
 
- Public Attributes inherited from Forces.SimpleMover
Vector2 Velocity = Vector2.Zero
 Current velocity More...
 
Vector2 Acceleration = Vector2.Zero
 Current acceleration More...
 
float AngularVelocity
 Current angular velocity More...
 
float AngularAcceleration
 Current angular acceleration More...
 
float MaxVelocity = 10
 Max velocity More...
 
float MaxAngularVelocity = 0.1f
 Max angular velocity More...
 
float Mass = 1
 Mass More...
 
WrapModeEnum WrapMode
 Wrapping mode More...
 
bool DisableForces
 Disable forces More...
 
bool SyncRotationOnVelocity
 Synchronize rotation on velocity More...
 
SimpleMesh Mesh
 Mesh More...
 

Protected Member Functions

override void UpdateAcceleration ()
 Update acceleration value. More...
 

Additional Inherited Members

- Public Types inherited from Forces.SimpleMover
enum class  WrapModeEnum { Wrap , Bounce , None }
 Wrapping mode enum. More...
 
- Protected Attributes inherited from Forces.SimpleMover
CollisionShape2D collisionShape2D
 Collision shape More...
 
- Properties inherited from Forces.SimpleMover
bool Drawing [get, set]
 Draw mesh More...
 
Vector2 MeshSize [get, set]
 Mesh size More...
 
float Radius [get, set]
 Mesh radius More...
 

Detailed Description

Swimming fish.

Definition at line 282 of file Ecosystem.cs.

Constructor & Destructor Documentation

◆ SwimmingFish()

Ecosystem.Ecosystem.SwimmingFish.SwimmingFish ( )
inline

Create a swimming fish.

Definition at line 310 of file Ecosystem.cs.

311  {
312  MaxVelocity = 1f;
313 
314  tail1 = new SimpleCircleSprite();
315  tail2 = new SimpleCircleSprite();
316  tail3 = new SimpleCircleSprite();
317  body1 = new SimpleCircleSprite();
318  body2 = new SimpleCircleSprite();
319  body3 = new SimpleCircleSprite();
320  body4 = new SimpleCircleSprite();
321  leftWing = new SimpleCircleSprite();
322  rightWing = new SimpleCircleSprite();
323 
324  Color colorToUse = BaseColor;
325  Color lightenedColor = colorToUse.Lightened(0.25f);
326  Color lowDarkenedColor = colorToUse.Darkened(0.1f);
327  Color midDarkenedColor = colorToUse.Darkened(0.25f);
328  tail1.Modulate = colorToUse.Darkened(0.5f);
329  tail2.Modulate = midDarkenedColor;
330  tail3.Modulate = lowDarkenedColor;
331  tail1.Radius = 2;
332  tail2.Radius = 2;
333  tail3.Radius = 2;
334  body1.Modulate = colorToUse;
335  body2.Modulate = colorToUse;
336  body3.Modulate = colorToUse;
337  body4.Modulate = colorToUse;
338  body1.Radius = 3;
339  body2.Radius = 4;
340  body3.Radius = 5;
341  body4.Radius = 4;
342  leftWing.Modulate = lightenedColor;
343  rightWing.Modulate = lightenedColor;
344  leftWing.Radius = 1.5f;
345  rightWing.Radius = 1.5f;
346  }
Use this to draw a circle. Instead of DrawCircle, it can be batched.
float Radius
Circle radius.
float MaxVelocity
Max velocity
Definition: SimpleMover.cs:39

Member Function Documentation

◆ UpdateAcceleration()

override void Ecosystem.Ecosystem.SwimmingFish.UpdateAcceleration ( )
inlineprotectedvirtual

Update acceleration value.

Reimplemented from Forces.SimpleMover.

Definition at line 348 of file Ecosystem.cs.

349  {
350  var forward = Vector2.Right.Rotated(Rotation).Normalized() * ForwardAcceleration;
351  var offset = new Vector2(MathUtils.SignedRandf(), MathUtils.SignedRandf()) * SideOffsetAcceleration;
352  Acceleration = forward + offset;
353  }
float ForwardAcceleration
Forward acceleration
Definition: Ecosystem.cs:291
float SideOffsetAcceleration
Side offset acceleration
Definition: Ecosystem.cs:294
Vector2 Acceleration
Current acceleration
Definition: SimpleMover.cs:30
Math utility functions
Definition: MathUtils.cs:7
static float SignedRandf()
Return a signed Randf, between -1 and 1.
Definition: MathUtils.cs:46

Member Data Documentation

◆ BaseColor

Color Ecosystem.Ecosystem.SwimmingFish.BaseColor = Colors.CadetBlue

Base color

Definition at line 288 of file Ecosystem.cs.

◆ ForwardAcceleration

float Ecosystem.Ecosystem.SwimmingFish.ForwardAcceleration = 0.25f

Forward acceleration

Definition at line 291 of file Ecosystem.cs.

◆ SideOffsetAcceleration

float Ecosystem.Ecosystem.SwimmingFish.SideOffsetAcceleration = 0.1f

Side offset acceleration

Definition at line 294 of file Ecosystem.cs.

◆ TailSpeed

float Ecosystem.Ecosystem.SwimmingFish.TailSpeed = 10f

Tail speed

Definition at line 285 of file Ecosystem.cs.


The documentation for this class was generated from the following file: