Recent

Author Topic: Demo Scene Text Fx  (Read 4481 times)

Gigatron

  • Full Member
  • ***
  • Posts: 105
  • Amiga Rulez !!
Re: Demo Scene Text Fx
« Reply #15 on: May 10, 2024, 04:57:51 pm »
So what is the result ? :)

Oh, it looks really cool!!!

This video needs to be added in #madewithinraylib on discord channel

https://discord.gg/raylib

Ok , let me just learn Raylib quickly i mean Faster than light ;  and improve the demo and then will post it to discord sure :)

Edit : Nice, do someting nice at 1500 times faster than light here ;

https://www.youtube.com/watch?v=qQUGzPRQhoM&t=42s


« Last Edit: May 10, 2024, 07:17:56 pm by Gigatron »
Sub Quantum Technology ! I Am Sure The Brain Is A Quantum Computer !!

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Demo Scene Text Fx
« Reply #16 on: May 10, 2024, 06:34:00 pm »
https://discord.gg/raylib
I was very happy to read about Discord server but a little disappointed on arrival :D
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

Gigatron

  • Full Member
  • ***
  • Posts: 105
  • Amiga Rulez !!
Re: Demo Scene Text Fx
« Reply #17 on: May 23, 2024, 07:03:04 pm »
Hi, just made another intro using BGRA component;


Raylib version is different : https://www.youtube.com/watch?v=dfoDfmjd1x8



Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls,
  9.   BGRAVirtualScreen, BGRABitmap, BGRABitmapTypes, BGRACanvas2D, Math;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     BGRAVirtualScreen1: TBGRAVirtualScreen;
  17.     Timer1: TTimer;
  18.     procedure BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  19.     procedure FormCreate(Sender: TObject);
  20.     procedure Timer1Timer(Sender: TObject);
  21.   private
  22.  
  23.   public
  24.   procedure drawStar(ctx: TBGRACanvas2D;cx, cy, spikes : integer; outerRadius, innerRadius, rotation : single;style : TBGRAPixel);
  25.    procedure reset;
  26.   end;
  27.  
  28. var
  29.   Form1: TForm1;
  30.   rt : double;
  31.   x_pos,y_pos : integer;
  32.  
  33.   // txt
  34.   x,y,i,j,g_timer,speed  : integer;  // general demo timer
  35.   tx: Array[0..12]  Of String =('+******************+',
  36.                                 '*    GIGATRON      *',
  37.                                 '*                  *',
  38.                                 '*PRESENTS TEXT FX#5*',
  39.                                 '*                  *',
  40.                                 '*  BGRA COMPONENT  *',
  41.                                 '*                  *',
  42.                                 '*@LAZARUS FPC RULEZ*',
  43.                                  '********************',
  44.                                 '*SFX : TDK         *',
  45.                                 '*FONT: DOUGHNUT    *',
  46.                                 '*CODE: GIGATRON    *',
  47.                                 '+******************+');
  48.   dest_y :Array[0..12]  Of integer;
  49.  
  50. implementation
  51.  
  52. {$R *.lfm}
  53.  
  54. { TForm1 }
  55.  
  56. procedure Tform1.DrawStar(ctx: TBGRACanvas2D; cx, cy, spikes: Integer; outerRadius, innerRadius, rotation: single;style : TBGRAPixel);
  57. var
  58.   rot, step, x, y: single;
  59.   i: Integer;
  60. begin
  61.   rot := Pi / 2 * 3 + rotation;
  62.   step := Pi / spikes;
  63.  
  64.   ctx.BeginPath;
  65.   x := cx + cos(rot) * outerRadius;
  66.   y := cy + sin(rot) * outerRadius;
  67.   ctx.MoveTo(x, y);
  68.  
  69.   for i := 0 to spikes - 1 do
  70.   begin
  71.     x := cx + cos(rot) * outerRadius;
  72.     y := cy + sin(rot) * outerRadius;
  73.     ctx.LineTo(x, y);
  74.     rot := rot + step;
  75.     x := cx + cos(rot) * innerRadius;
  76.     y := cy + sin(rot) * innerRadius;
  77.     ctx.LineTo(x, y);
  78.     rot := rot + step;
  79.   end;
  80.  
  81.   x := cx + cos(rot) * outerRadius;
  82.   y := cy + sin(rot) * outerRadius;
  83.   ctx.LineTo(x, y);
  84.   ctx.ClosePath;
  85.  
  86.   ctx.LineWidth := 50;
  87.   ctx.strokeStyle(style);
  88.   ctx.Stroke;
  89.   ctx.fillStyle ('rgba(0,0,0,0)');;
  90.   ctx.Fill;
  91. end;
  92.  
  93. procedure TForm1.FormCreate(Sender: TObject);
  94. begin
  95.   rt := 0.0;
  96.   x_pos :=160;
  97.   y_pos :=50;
  98.  
  99.      x:=10; y:=0; i :=0; j :=0; speed := 40; // speed of fx
  100.      for i:=0 to 12 do
  101.      begin
  102.      dest_y[i] := 800  ; // set ypos for each lines
  103.      end;
  104.      sleep(5000);
  105. end;
  106. procedure TForm1.BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  107. var
  108.   ctx: TBGRACanvas2D;
  109. begin
  110.   ctx := Bitmap.Canvas2D;
  111.   bitmap.FontName:='AmigaDigital8';
  112.   bitmap.FontHeight := 40;
  113.   bitmap.FontAntialias := false;
  114.  
  115.   drawStar(ctx, x_pos+200,y_pos+210, 7, 110.0, 170.0, rt,BGRA(44,55,66));
  116.   drawStar(ctx, x_pos+210,y_pos+220, 7, 110.0, 170.0, rt,BGRA(66,77,88));
  117.   drawStar(ctx, x_pos+220,y_pos+225, 7, 110.0, 170.0, rt,BGRA(77,88,99));
  118.   /// Txt
  119.   for j := 0 to  Min((g_timer div speed), High(tx)) do
  120.   begin
  121.     if g_timer > (j * speed) then
  122.     begin
  123.       for i := 0 to 1 do
  124.       begin
  125.         Bitmap.TextOut(x , dest_y[j] + 6, tx[j], BGRA(68, 85, 102));
  126.         Bitmap.TextOut(x , dest_y[j],     tx[j], BGRA(255, 255, 255));
  127.         dest_y[j] := dest_y[j] - 8;
  128.         if dest_y[j] < (j * 32) then dest_y[j] := j * 32;
  129.       end;
  130.     end;
  131.   end;
  132. end;
  133.  
  134. procedure TForm1.Timer1Timer(Sender: TObject);
  135. begin
  136.          rt := rt + 0.02;
  137.          inc(g_timer);
  138.          if(g_timer>800) then
  139.          begin
  140.           g_timer :=0;
  141.           BGRAVirtualScreen1.Invalidate;
  142.           reset;
  143.         end;
  144.         BGRAVirtualScreen1.RedrawBitmap;
  145. end;
  146.  
  147. procedure TForm1.reset();
  148. begin
  149.     i:=0;
  150.     for i:=0 to 12 do
  151.      begin
  152.        dest_y[i] := 800  ;
  153.      end;
  154. end;
  155.  
  156. end.
  157.  


« Last Edit: May 23, 2024, 07:09:23 pm by Gigatron »
Sub Quantum Technology ! I Am Sure The Brain Is A Quantum Computer !!

Gigatron

  • Full Member
  • ***
  • Posts: 105
  • Amiga Rulez !!
Re: Demo Scene Text Fx
« Reply #18 on: June 19, 2024, 07:38:38 pm »
Hi,
Here is another cool text fx, this one bounce each chars of your text from top to bottom and stop !

The javascript live version here :

http://gigatron3k.free.fr/laz/bounce.html

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls,
  9.   BGRAVirtualScreen, BGRABitmap, BGRABitmapTypes;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     BGRAVirtualScreen1: TBGRAVirtualScreen;
  17.     Timer1: TTimer;
  18.     procedure BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  19.     procedure FormCreate(Sender: TObject);
  20.     procedure Timer1Timer(Sender: TObject);
  21.   private
  22.   Positions: array of record
  23.       y: Integer;     // yposition for each chars !
  24.       vy: Single;     // yposition speed
  25.     end;
  26.     g: Single;   // gravity
  27.     groundLevel: Integer;
  28.  
  29.   public
  30.  
  31.   end;
  32.  
  33. var
  34.   Form1: TForm1;
  35.   Texte : String = 'GIGATRON PRESENTS';    // text
  36.  
  37. implementation
  38.  
  39. {$R *.lfm}
  40.  
  41. { TForm1 }
  42.  
  43. procedure TForm1.FormCreate(Sender: TObject);
  44. var
  45.   i: Integer;
  46. begin
  47.   SetLength(Positions, Length(Texte));
  48.   g := 0.3;
  49.   groundLevel := 500;
  50.   // fill table y and vy for each char !
  51.   for i := 0 to High(Positions) do
  52.   begin
  53.     Positions[i].y := -140 - i * 40;
  54.     Positions[i].vy := 0;
  55.   end;
  56.  
  57. end;
  58.  
  59. procedure TForm1.Timer1Timer(Sender: TObject);
  60. var
  61.   i: Integer;
  62. begin
  63.   for i := 0 to High(Positions) do
  64.   begin
  65.     Positions[i].vy := Positions[i].vy + Frac(g);
  66.     Positions[i].y := Positions[i].y + Round(Positions[i].vy);
  67.  
  68.     if Positions[i].y > groundLevel then
  69.     begin
  70.       Positions[i].y := groundLevel;
  71.       Positions[i].vy := Positions[i].vy * Frac(-0.8);
  72.     end;
  73.   end;
  74.    BGRAVirtualScreen1.RedrawBitmap;
  75. end;
  76.  
  77. procedure TForm1.BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  78. var
  79.     i,x, y: Integer;
  80. begin
  81.  
  82.   Bitmap.FontName := 'AmigaDigital8';  // your ttf font
  83.   Bitmap.FontHeight := 80;
  84.  
  85.   for i := 1 to Length(Texte) do
  86.   begin
  87.     x := 60 + (i - 1) * 40; // space between char * 40
  88.     y := Positions[i - 1].y;
  89.     Bitmap.TextOut(x+2, y+4, Texte[i],BGRA(105,105,105));
  90.     Bitmap.TextOut(x, y, Texte[i],BGRA(255,255,255));
  91.   end;
  92. end;
  93.  
  94. end.
  95.  
« Last Edit: June 19, 2024, 08:53:46 pm by Gigatron »
Sub Quantum Technology ! I Am Sure The Brain Is A Quantum Computer !!

Gigatron

  • Full Member
  • ***
  • Posts: 105
  • Amiga Rulez !!
Re: Demo Scene Text Fx
« Reply #19 on: June 25, 2024, 08:26:27 pm »
Hi all;

Here is another cool demo of bounce text ; sfx from MAF64 ;
Try to improve this nice cool fx for your production used the best component on this galaxy for lazarus BGRA !!

https://www.youtube.com/watch?v=3-TwsuXJ4HA

** Edit : add plot fx and code optimization , all calculation are now much faster !!
 
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls,
  9.   BGRAVirtualScreen, BGRABitmap, BGRABitmapTypes,BGRATransform,mmsystem;
  10.  
  11. type
  12.   TWaveScanner = class(TBGRAAffineBitmapTransform)
  13.     Time: integer;
  14.     function GetOffset({%H-}X, Y: Single): Single;
  15.     { fast integer scanning (used by PutImage) }
  16.     procedure ScanMoveTo(X, Y: Integer); override;
  17.     { slow floating point scanning }
  18.     function ScanAt(X, Y: Single): TBGRAPixel; override;
  19.     constructor Create(ASource: TBGRACustomBitmap; ARepeatX,ARepeatY: boolean);
  20.   end;
  21.  
  22.   { TForm1 }
  23.  
  24.   TForm1 = class(TForm)
  25.     BGRAVirtualScreen1: TBGRAVirtualScreen;
  26.     Timer1: TTimer;
  27.     procedure BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  28.     procedure FormCreate(Sender: TObject);
  29.     procedure Timer1Timer(Sender: TObject);
  30.   private
  31.  
  32.   public
  33.  
  34.   MyAudio_File: AnsiString;
  35.   WavStream : TMemoryStream;
  36.   gtr_scanner,phx_scanner: TWaveScanner;
  37.  
  38.   end;
  39.  
  40. var
  41.   Form1: TForm1;
  42.   ddr_table: Array[0..15] of integer =(0,1,2,3,4,5,6,7,8,7,6,5,4,3,2,1);   // sinus movement factor table
  43.  
  44.   tx: Array[0..13]  Of String =('                           ',
  45.                                 '      GIGATRON PRESENTS    ',
  46.                                 '  THE GREAT GIANA SISTERS  ',
  47.                                 '   CRACKED ON 08/06/2024   ',
  48.                                 '   GREETING TO MEMBERS OF  ',
  49.                                 ' TRONIC-SYSTEM AND SUB-SERO',
  50.                                 ' ALL LAZARUS AND FPC TEAM  ',
  51.                                 '   SFX BY : MAF64  R.I.P   ',
  52.                                 '      GFX BY : RED-MAX     ',
  53.                                 '   @ LAZARUS FPC RULEZ @   ',
  54.                                 '  THE BEST COMPONENT BGRA  ',
  55.                                 '     THANX TO CIRCULAR     ',
  56.                                 ' SEE YOU ON NEXT PRODUCTION',
  57.                                 '      GOTO SUB-QUANTUM     ');
  58.  
  59.   // attention tx vars !
  60.   tm,tx_id,dir,x,y,vx  : integer ;
  61.   g,vy : single ;
  62.   groundLevel : integer;
  63.   // logo  phenix,gtr
  64.   phenix,gtr : TBGRABitmap;
  65.  
  66.   // ddr  table index !
  67.   ddr : integer;
  68.  
  69.   // dot plot
  70.   s,a : single;
  71.  
  72.  
  73. implementation
  74.  
  75. {$R *.lfm}
  76.  
  77. { TForm1 }
  78.  
  79. procedure TForm1.FormCreate(Sender: TObject);
  80. begin
  81.    // init text vars
  82.     tm := 0;
  83.     tx_id := 0;
  84.     dir := 1; // vers la droite
  85.     g := 0.6; // acceleration gravity
  86.     x := 0; // initial horizontal position
  87.     y := -400; // initial vertical position out of scene
  88.    vx := 0; // initial horizontal speed   in case ; unused !!
  89.    vy := 0; // initial vertical speed
  90.    groundLevel := 500;
  91.  
  92.    ddr := 0; // table index
  93.  
  94.    // plot fx
  95.    s := 255/sqrt(3)*2/30;
  96.    a := 0.0;  // angle
  97.  
  98.  
  99.    BGRAVirtualScreen1.Color := $00776655;
  100.  
  101.    phenix := TBGRABitmap.Create('phex.png');
  102.    gtr    := TBGRABitmap.Create('gtr.png');
  103.  
  104.    gtr_scanner := TWaveScanner.Create(gtr,false, false); // bitmap
  105.    gtr_scanner.Translate(140,-40);
  106.  
  107.    phx_scanner := TWaveScanner.Create(phenix,false, false); // bitmap
  108.    phx_scanner.Translate(110,80);
  109.  
  110.    // audio
  111.    // audio stream
  112.    // MyAudio_File := 'pp2.wav';
  113.    // WavStream    := TMemoryStream.Create;
  114.    // WavStream.LoadFromFile(MyAudio_File);
  115.    // PlaySound(WavStream.Memory, 0, SND_NODEFAULT or SND_LOOP or SND_ASYNC or SND_MEMORY);
  116.  
  117. end;
  118.  
  119. procedure TForm1.BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  120. var
  121.   xx,yy : integer;
  122.   r,z,x1,x2,y1,y2 : single;
  123. begin
  124.       // plot fx
  125.       for xx:=15 downto -15 do
  126.        begin
  127.        for yy:=15 downto -15 do
  128.         begin
  129.  
  130.        r := (sqrt(xx*xx+yy*yy))+2;
  131.        z := 40*sin(r+a*0.6)/r*0.8;
  132.  
  133.        x2 := xx*cos(a*PI/180)-yy*sin(a*PI/180);
  134.        y2 := xx*sin(a*PI/180)+yy*cos(a*PI/180);
  135.  
  136.        x1 := round(360+(y2-x2)*s*sqrt(3)/2);
  137.        y1 := round(360+z-(y2+x2)*s/2);
  138.  
  139.        bitmap.Rectangle(Rect(Round(x1), Round(y1),Round(x1+2), Round(y1+2)),BGRA(25+round(x2),255,255),dmSet);
  140.  
  141.         end;
  142.        end;
  143.  
  144.        a := a - 0.4;
  145.  
  146.        //***********************************
  147.        // le logo phenix en premier
  148.        Bitmap.Fill(phx_scanner,dmFastBlend);
  149.        dec(phx_scanner.Time,1);
  150.        // puis le logo gtr
  151.        inc(gtr_scanner.Time,1);
  152.        Bitmap.Fill(gtr_scanner,dmFastBlend);
  153.  
  154.        // puis le texte ligne par ligne !
  155.        Bitmap.FontName := 'AmigaDigital';  // your ttf font
  156.        Bitmap.FontHeight := 60;
  157.        Bitmap.TextOut(x+4, y+2, tx[tx_id],BGRA(50,50,50));
  158.        Bitmap.TextOut(x, y, tx[tx_id],BGRA(255,255,255));
  159.  
  160.  
  161. end;
  162.  
  163. procedure TForm1.Timer1Timer(Sender: TObject);
  164. begin
  165.        vy := vy + Frac(g);
  166.         y := y + Round(vy);
  167.  
  168.        if (y >= groundLevel ) then // if text hits the ground
  169.        begin
  170.          y  := groundLevel;         // reposition it at the ground
  171.          vy := vy * Frac(-0.6);    // then reverse and reduce its vertical speed
  172.        end;
  173.  
  174.        if( y = groundLevel) then
  175.        begin
  176.        tm := tm +1;
  177.           if(tm>=80) then
  178.            begin
  179.  
  180.               if (dir=1) then x := x + 20 ;   // on va aller vite !!
  181.               if (dir=2) then x := x - 20 ;
  182.  
  183.  
  184.               if( x>= 800)  Or (x <=-800 ) then
  185.                begin              // si x >< sort de l'ecran reset all vars ;
  186.                    tm := 0;
  187.                    x  := 0;
  188.                    y  := -400;
  189.  
  190.                    ddr := ddr +1;   // commence le sinus movement !
  191.                    if(ddr>=14) then ddr := 1;
  192.  
  193.                         dir := dir + 1;
  194.                         if(dir>2) then dir := 1;
  195.  
  196.                         tx_id := tx_id +1;
  197.                         if(tx_id>=14 ) then tx_id := 0;
  198.  
  199.                end;
  200.  
  201.             end;
  202.  
  203.        end;
  204.  
  205.        BGRAVirtualScreen1.RedrawBitmap;
  206. end;
  207.  
  208. { TWaveScanner }
  209.  
  210. function TWaveScanner.GetOffset(X, Y: Single): Single;
  211. begin
  212.   result := ddr_table[ddr] * sin((Y + Time) * 30/5 * PI / 180);
  213. end;
  214.  
  215. procedure TWaveScanner.ScanMoveTo(X, Y: Integer);
  216. begin
  217.   inherited ScanMoveTo(X + round(GetOffset(X, Y)), Y);
  218. end;
  219.  
  220. function TWaveScanner.ScanAt(X, Y: Single): TBGRAPixel;
  221. begin
  222.   Result:=inherited ScanAt(X + GetOffset(X, Y), Y);
  223. end;
  224.  
  225. constructor TWaveScanner.Create(ASource: TBGRACustomBitmap;
  226.   ARepeatX,ARepeatY: boolean);
  227. begin
  228.   inherited Create(ASource, ARepeatX, ARepeatY);
  229.   Time := 0;
  230. end;
  231.  
  232. end.
  233.  
« Last Edit: June 26, 2024, 01:53:53 am by Gigatron »
Sub Quantum Technology ! I Am Sure The Brain Is A Quantum Computer !!

Gigatron

  • Full Member
  • ***
  • Posts: 105
  • Amiga Rulez !!
Re: Demo Scene Text Fx
« Reply #20 on: June 26, 2024, 06:29:58 pm »
Hi,

Here is the final code before something new !

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls,
  9.   BGRAVirtualScreen, BGRABitmap, BGRABitmapTypes,BGRATransform,mmsystem;
  10.  
  11. type
  12.   TWaveScanner = class(TBGRAAffineBitmapTransform)
  13.     Time: integer;
  14.     function GetOffset({%H-}X, Y: Single): Single;
  15.     { fast integer scanning (used by PutImage) }
  16.     procedure ScanMoveTo(X, Y: Integer); override;
  17.     { slow floating point scanning }
  18.     function ScanAt(X, Y: Single): TBGRAPixel; override;
  19.     constructor Create(ASource: TBGRACustomBitmap; ARepeatX,ARepeatY: boolean);
  20.   end;
  21.  
  22.   { TForm1 }
  23.  
  24.   TForm1 = class(TForm)
  25.     BGRAVirtualScreen1: TBGRAVirtualScreen;
  26.     Timer1: TTimer;
  27.     procedure BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  28.     procedure FormCreate(Sender: TObject);
  29.     procedure Timer1Timer(Sender: TObject);
  30.     function cs(agl : Single)  : Single;
  31.  
  32.   private
  33.  
  34.   public
  35.  
  36.   MyAudio_File: AnsiString;
  37.   WavStream : TMemoryStream;
  38.   gtr_scanner,phx_scanner: TWaveScanner;
  39.  
  40.  
  41.   end;
  42.  
  43. var
  44.   Form1: TForm1;
  45.   ddr_table: Array[0..15] of integer =(0,1,2,3,4,5,6,7,8,7,6,5,4,3,2,1);   // sinus movement factor table
  46.  
  47.   tx: Array[0..13]  Of String =('                           ',
  48.                                 '      GIGATRON PRESENTS    ',
  49.                                 '  THE GREAT GIANA SISTERS  ',
  50.                                 '   CRACKED ON 08/06/2024   ',
  51.                                 '  GREETINGS TO MEMBERS OF  ',
  52.                                 ' TRONIC-SYSTEM AND SUB-SERO',
  53.                                 ' ALL LAZARUS AND FPC TEAM  ',
  54.                                 ' SFX BY : KARSTEN OBARSKI  ',
  55.                                 '      GFX BY : RED-MAX     ',
  56.                                 '   @ LAZARUS FPC RULEZ @   ',
  57.                                 '  THE BEST COMPONENT BGRA  ',
  58.                                 '     THANX TO CIRCULAR     ',
  59.                                 ' SEE YOU ON NEXT PRODUCTION',
  60.                                 '      GOTO SUB-QUANTUM     ');
  61.  
  62.   // attention tx vars !
  63.   tm,tx_id,dir,x,y,vx  : integer ;
  64.   g,vy : single ;
  65.   groundLevel : integer;
  66.   // logo  phenix,gtr
  67.   phenix,gtr : TBGRABitmap;
  68.  
  69.   // ddr  table index !
  70.   ddr : integer;
  71.  
  72.   // dot plot
  73.   s,a,a2 : single;
  74.   rot : Boolean;
  75.   rot_dir,rot_timer : integer;
  76.  
  77.  
  78. implementation
  79.  
  80. {$R *.lfm}
  81.  
  82. { TForm1 }
  83.  
  84. procedure TForm1.FormCreate(Sender: TObject);
  85. begin
  86.    // init text vars
  87.     tm := 0;
  88.     tx_id := 0;
  89.     dir := 1; // vers la droite
  90.     g := 0.6; // acceleration gravity
  91.     x := 0; // initial horizontal position
  92.     y := -400; // initial vertical position out of scene
  93.    vx := 0; // initial horizontal speed   in case ; unused !!
  94.    vy := 0; // initial vertical speed
  95.    groundLevel := 500;
  96.  
  97.    ddr := 0; // table index
  98.  
  99.    // plot fx
  100.    s := 255/sqrt(3)*2/30;
  101.    a := 0.0;  // angle
  102.    a2:= 0.0;
  103.    rot := false;
  104.    rot_dir := 0;
  105.    rot_timer :=0;
  106.  
  107.    BGRAVirtualScreen1.Color := $00776655;
  108.  
  109.    phenix := TBGRABitmap.Create('phex.png');
  110.    gtr    := TBGRABitmap.Create('gtr.png');
  111.  
  112.    gtr_scanner := TWaveScanner.Create(gtr,false, false); // bitmap
  113.    gtr_scanner.Translate(140,-40);
  114.  
  115.    phx_scanner := TWaveScanner.Create(phenix,false, false); // bitmap
  116.    phx_scanner.Translate(110,80);
  117.  
  118.    // audio
  119.    // audio stream
  120.     MyAudio_File := 'blueberry.wav';
  121.     WavStream    := TMemoryStream.Create;
  122.     WavStream.LoadFromFile(MyAudio_File);
  123.     PlaySound(WavStream.Memory, 0, SND_NODEFAULT or SND_LOOP or SND_ASYNC or SND_MEMORY);
  124.  
  125. end;
  126.  
  127. procedure TForm1.BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  128. var
  129.   xx,yy : integer;
  130.   z,x1,x2,y1,y2 : single;
  131.  
  132. begin
  133.  
  134.     // plot fx
  135.       for xx:=15 downto -15 do
  136.        begin
  137.        for yy:=15 downto -15 do
  138.         begin
  139.  
  140.        z := cs(sqrt(xx*xx+yy*yy)/30-a)*30;
  141.  
  142.        x2 := xx*cos(2*a2*PI/180)-yy*sin(a2*PI/180);
  143.        y2 := xx*sin(2*a2*PI/180)+yy*cos(a2*PI/180);
  144.  
  145.        x1 := round(360+(y2-x2)*s*sqrt(3)/2);
  146.        y1 := round(360+z-(y2+x2)*s/2);
  147.  
  148.        bitmap.Rectangle(Rect(Round(x1), Round(y1),Round(x1+2), Round(y1+2)),BGRA(255,255,255),dmSet);
  149.  
  150.         end;
  151.        end;
  152.  
  153.        a := a + 0.005;
  154.        if(rot) and (rot_dir=1) then a2 := a2 + 0.2;
  155.        if(rot) and (rot_dir=2) then a2 := a2 - 0.2;
  156.  
  157.        //***********************************
  158.        // le logo phenix en premier
  159.        Bitmap.Fill(phx_scanner,dmFastBlend);
  160.        dec(phx_scanner.Time,1);
  161.        // puis le logo gtr
  162.        inc(gtr_scanner.Time,1);
  163.        Bitmap.Fill(gtr_scanner,dmFastBlend);
  164.  
  165.        // puis le texte ligne par ligne !
  166.        Bitmap.FontName := 'AmigaDigital';  // your ttf font
  167.        Bitmap.FontHeight := 60;
  168.        Bitmap.TextOut(x+4, y+2, tx[tx_id],BGRA(50,50,50));
  169.        Bitmap.TextOut(x, y, tx[tx_id],BGRA(255,255,255));
  170.  
  171. end;
  172.  
  173. procedure TForm1.Timer1Timer(Sender: TObject);
  174. begin
  175.        vy := vy + Frac(g);
  176.         y := y + Round(vy);
  177.  
  178.        if (y >= groundLevel ) then // if text hits the ground
  179.        begin
  180.          y  := groundLevel;         // reposition it at the ground
  181.          vy := vy * Frac(-0.6);    // then reverse and reduce its vertical speed
  182.        end;
  183.  
  184.        if( y = groundLevel) then
  185.        begin
  186.        tm := tm +1;
  187.           if(tm>=80) then
  188.            begin
  189.  
  190.               if (dir=1) then x := x + 20 ;   // on va aller vite !!
  191.               if (dir=2) then x := x - 20 ;
  192.  
  193.  
  194.               if( x>= 800)  Or (x <=-800 ) then
  195.                begin              // si x >< sort de l'ecran reset all vars ;
  196.                    tm := 0;
  197.                    x  := 0;
  198.                    y  := -400;
  199.                    rot := true;
  200.                    ddr := ddr +1;   // commence le sinus movement !
  201.                    if(ddr>=14) then ddr := 1;
  202.  
  203.                         dir := dir + 1;
  204.                         if(dir>2) then dir := 1;
  205.  
  206.                         tx_id := tx_id +1;
  207.                         if(tx_id>=14 ) then tx_id := 0;
  208.  
  209.                end;
  210.  
  211.             end;
  212.  
  213.        end;
  214.  
  215.        inc(rot_timer);
  216.        if(rot_timer>=1000) then rot_dir   := 1;
  217.        if(rot_timer>=2000) then rot_dir   := 2;
  218.        if(rot_timer>=3000) then rot_timer :=0;
  219.  
  220.        BGRAVirtualScreen1.RedrawBitmap;
  221. end;
  222.  
  223. function TForm1.cs(agl : single)  : single;
  224. begin
  225.      result := cos(2*PI*agl);
  226. end;
  227.  
  228. { TWaveScanner }
  229.  
  230. function TWaveScanner.GetOffset(X, Y: Single): Single;
  231. begin
  232.   result := ddr_table[ddr] * sin((Y + Time) * 30/5 * PI / 180);
  233. end;
  234.  
  235. procedure TWaveScanner.ScanMoveTo(X, Y: Integer);
  236. begin
  237.   inherited ScanMoveTo(X + round(GetOffset(X, Y)), Y);
  238. end;
  239.  
  240. function TWaveScanner.ScanAt(X, Y: Single): TBGRAPixel;
  241. begin
  242.   Result:=inherited ScanAt(X + GetOffset(X, Y), Y);
  243. end;
  244.  
  245. constructor TWaveScanner.Create(ASource: TBGRACustomBitmap;
  246.   ARepeatX,ARepeatY: boolean);
  247. begin
  248.   inherited Create(ASource, ARepeatX, ARepeatY);
  249.   Time := 0;
  250. end;
  251. // end of demo
  252. end.
  253.  
Sub Quantum Technology ! I Am Sure The Brain Is A Quantum Computer !!

 

TinyPortal © 2005-2018