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.HoppingBunny Class Reference

Hopping bunny. More...

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

Public Member Functions

 HoppingBunny ()
 Create a hopping bunny. 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 JumpSpeed = 8f
 Jump speed More...
 
float TailSpeed = 10f
 Tail speed More...
 
float AccelerationFactor = 0.025f
 Acceleration factor More...
 
Color BaseColor = Colors.White
 Base color More...
 
Color EyeColor = Colors.LightBlue
 Eye color More...
 
float EarRotationFactor = 0.01f
 Ear rotation factor More...
 
float TailRotationFactor = 0.05f
 Tail rotation factor 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

Hopping bunny.

Definition at line 397 of file Ecosystem.cs.

Constructor & Destructor Documentation

◆ HoppingBunny()

Ecosystem.Ecosystem.HoppingBunny.HoppingBunny ( )
inline

Create a hopping bunny.

Definition at line 446 of file Ecosystem.cs.

447  {
448  body1 = new SimpleCircleSprite();
449  body2 = new SimpleCircleSprite();
450  paws1 = new SimpleCircleSprite();
451  paws2 = new SimpleCircleSprite();
452  paws3 = new SimpleCircleSprite();
453  paws4 = new SimpleCircleSprite();
454  tail = new SimpleCircleSprite();
455  leftEar1 = new SimpleCircleSprite();
456  leftEar2 = new SimpleCircleSprite();
457  leftEar3 = new SimpleCircleSprite();
458  leftEar4 = new SimpleCircleSprite();
459  leftEar5 = new SimpleCircleSprite();
460  head = new SimpleCircleSprite();
461  eye = new SimpleCircleSprite();
462  nose = new SimpleCircleSprite();
463  rightEar1 = new SimpleCircleSprite();
464  rightEar2 = new SimpleCircleSprite();
465  rightEar3 = new SimpleCircleSprite();
466  rightEar4 = new SimpleCircleSprite();
467  rightEar5 = new SimpleCircleSprite();
468 
469  Color baseColor = BaseColor;
470  Color darkenedColor = baseColor.Darkened(0.1f);
471 
472  // Body
473  body1.Modulate = baseColor;
474  body2.Modulate = baseColor;
475  body1.Radius = 10;
476  body2.Radius = 10;
477 
478  // Paws
479  paws1.Modulate = darkenedColor;
480  paws2.Modulate = darkenedColor;
481  paws3.Modulate = darkenedColor;
482  paws4.Modulate = darkenedColor;
483  paws1.Radius = 2;
484  paws2.Radius = 2;
485  paws3.Radius = 2;
486  paws4.Radius = 2;
487 
488  // Tail
489  tail.Modulate = darkenedColor;
490  tail.Radius = 4;
491 
492  // Left ear
493  leftEar1.Modulate = darkenedColor;
494  leftEar2.Modulate = darkenedColor;
495  leftEar3.Modulate = darkenedColor;
496  leftEar4.Modulate = darkenedColor;
497  leftEar5.Modulate = darkenedColor;
498  leftEar1.Radius = 3;
499  leftEar2.Radius = 3;
500  leftEar3.Radius = 3;
501  leftEar4.Radius = 3;
502  leftEar5.Radius = 3;
503 
504  // Head
505  head.Modulate = baseColor;
506  head.Radius = 8;
507 
508  // Eye
509  eye.Modulate = EyeColor;
510  eye.Radius = 2;
511 
512  // Nose
513  nose.Modulate = baseColor;
514  nose.Radius = 1.5f;
515 
516  // Right ear
517  rightEar1.Modulate = darkenedColor;
518  rightEar2.Modulate = darkenedColor;
519  rightEar3.Modulate = darkenedColor;
520  rightEar4.Modulate = darkenedColor;
521  rightEar5.Modulate = darkenedColor;
522  rightEar1.Radius = 3;
523  rightEar2.Radius = 3;
524  rightEar3.Radius = 3;
525  rightEar4.Radius = 3;
526  rightEar5.Radius = 3;
527  }
Use this to draw a circle. Instead of DrawCircle, it can be batched.
float Radius
Circle radius.

Member Function Documentation

◆ UpdateAcceleration()

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

Update acceleration value.

Reimplemented from Forces.SimpleMover.

Definition at line 529 of file Ecosystem.cs.

530  {
531  Acceleration.y = Mathf.Sin(tJump);
532  Acceleration.x = AccelerationFactor * Mathf.Sign(Scale.x);
533  }
float AccelerationFactor
Acceleration factor
Definition: Ecosystem.cs:406
Vector2 Acceleration
Current acceleration
Definition: SimpleMover.cs:30

Member Data Documentation

◆ AccelerationFactor

float Ecosystem.Ecosystem.HoppingBunny.AccelerationFactor = 0.025f

Acceleration factor

Definition at line 406 of file Ecosystem.cs.

◆ BaseColor

Color Ecosystem.Ecosystem.HoppingBunny.BaseColor = Colors.White

Base color

Definition at line 409 of file Ecosystem.cs.

◆ EarRotationFactor

float Ecosystem.Ecosystem.HoppingBunny.EarRotationFactor = 0.01f

Ear rotation factor

Definition at line 415 of file Ecosystem.cs.

◆ EyeColor

Color Ecosystem.Ecosystem.HoppingBunny.EyeColor = Colors.LightBlue

Eye color

Definition at line 412 of file Ecosystem.cs.

◆ JumpSpeed

float Ecosystem.Ecosystem.HoppingBunny.JumpSpeed = 8f

Jump speed

Definition at line 400 of file Ecosystem.cs.

◆ TailRotationFactor

float Ecosystem.Ecosystem.HoppingBunny.TailRotationFactor = 0.05f

Tail rotation factor

Definition at line 418 of file Ecosystem.cs.

◆ TailSpeed

float Ecosystem.Ecosystem.HoppingBunny.TailSpeed = 10f

Tail speed

Definition at line 403 of file Ecosystem.cs.


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