Results 1 to 10 of 15

Thread: BareGame

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Okay Will, here is another quick and dirty video. This is the easings demo which shows how a function prototype is used to animate properties of objects. It also highlights how 2D vector graphics can be rendered transformed in 3D space if so desired.

    Code:
    type 
      TEasing = function(Percent: Float): Float;
    
      TEasings = class(TDictionary<string, TEasing>)
      protected
        {doc off}
        function DefaultValue: TEasing; override;
      public
        procedure RegisterDefaults;
        {doc on}
      end;   
    
    
    class function TEasingDefaults.Linear(Percent: Float): Float;
    begin
      Result := Percent;
    end;
    
    class function TEasingDefaults.Easy(Percent: Float): Float;
    begin
      Result := Percent * Percent * (3 - 2 * Percent);
    end;
    
    class function TEasingDefaults.Boing(Percent: Float): Float;
    begin
      Percent := Power(Percent, 1.5);
      Result := Sin(PI * Power(Percent, 2) * 20 - PI / 2) / 4;
      Result := Result * (1 - Percent) + 1;
      if Percent < 0.2 then
        Result := Result * Easy(Percent / 0.2);
    end;


    You can add your own easings by simply writing Easings.Add('MyCustomEasingName', MyCustomEasingFunc). You can animate an property by writing:

    Code:
    Animations.Add(MySprite.Angle, 90)
      .Easing('MyCustomEasingName')
      .Duration(0.75)
      .Looping(loopReverse, loopInfinite)
    Which causes MySprite to spin on it's Z axis from its current angle to 90 in 0.75 seconds using 'MyCustomEasingName' to interpolate the angle over the animation time frame. The animation will loop infinitely reversing itself every 0.75 seconds until the Angle property is issued a different animation or removed by writing Animations.Remove(MySprite.Angle). Animations can be reused by using a Storyboard class.

    Most every world object has animatable properties. Canvas Brush can animate the width, texture coords, colors, gradient stop locations. Camera position, direction, and field of view can be animated. Sprite color, origin, size, position, scale, and rotation can be animated. Even sound bank volume and 3D space position can be animated. ect

  2. #2
    looks impressive, definitely will try it out

  3. #3
    Just reported bunch of spam messages on BG forums. If I'd be mod there, I could do more.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •