unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls,
BGRAVirtualScreen, BGRABitmap,BGRABitmapTypes, BGRAGradientScanner,mmsystem;
const
NUM_STARS = 3000;
type
{ TForm1 }
TForm1 = class(TForm)
BGRAVirtualScreen1: TBGRAVirtualScreen;
Timer1: TTimer;
procedure BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
public
MyAudio_File: AnsiString;
WavStream : TMemoryStream;
procedure drawSineScroll;
function drawFontChar(charek: Char; x: Integer): Integer;
end;
var
Form1: TForm1;
sin1: Single;
tempx, tempy: Single;
sx, sy: Integer;
sz: Single;
strz: array[0..NUM_STARS * 3 - 1] of Single;
rotate_dir,r_timer : integer;
bitmap_font,tx_scroll_bitmap,logo,mess_bitmap : TBGRABitmap; // images
radians ,sine_counter: single;
fonts_width, fonts_height,pos_y: Integer;
sxx, tx : Integer;
alfa : byte;
charek : char;
offset: Char;
sine_height,scroll_speed : Integer;
charSet: String;
s_text : string = 'GIGATRON !!! ON 04.06.2024 PRESENTS BGRA 3D ROTATING STARFIELD GREETINGS TO : THE LIGHTFORCE - CIRCULAR - LAINZ - TRON - JOSH - KODEZWERG - HUKKA - GUVACODE - RAYSAN5 - MATTIAS - MARCOV - MARTIN-FR - PASCALDRAGON AND ALL MEMBERS ON LAZARUS FORUM SEE YOU ON NEXT PRODUCTION ........ ';
message_1: Array[0..24] Of String =(' ',
' CODE : GIGATRON ',
' ',
' FONT : THE LIGHTFORCE ',
' ',
'SFX: JOURNEY TROUGH GALAXY',
' MARK II ',
' ',
' DESIGN : TRONIC-SYSTEM ',
' ',
' CONTACT GIGATRON ',
' BP : 3300 68000 ',
' COLMAR FRANCE ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ');
message_2: Array[0..24] Of String =(' ',
' TECH INFOS : ',
' 320 LINES OF PASCAL CODE ',
' BGRA COMPONENT ',
' 68000 LIKE TEXT FX CODE ',
' 2 DAYS OF WORK ',
' FULL 60 FPS ',
' AMD 8 CORES CPU ',
' 64 GIGABYTE OF RAM ',
' FREE PASACAL LAZARUS 3.2 ',
' FPC 3.2.2 ',
' THX TO THE TEAM LAZARUS ',
' ---------- ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ');
mess_id,mess_chr : integer;
mess_timer : integer;
char_pos : integer;
mess_page : integer;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
var
i,j : integer;
begin
Randomize;
j:= 0;
for i:=0 to NUM_STARS - 1 do
begin
j:= j + 1;
strz[j] := strz[j] + Round(random()* (900 div 2))-900 div 2 ;
strz[j] := strz[j] + Round(random()* (900 div 2))-900 div 2 ;
strz[j] := strz[j] + random()*1800;
end;
rotate_dir := 0;
r_timer := 0;
// audio stream
//MyAudio_File := 'jtg.wav';
//WavStream := TMemoryStream.Create;
//WavStream.LoadFromFile(MyAudio_File);
//PlaySound(WavStream.Memory, 0, SND_NODEFAULT or SND_ASYNC or SND_MEMORY);
logo := TBGRABitmap.Create('logo.png');
bitmap_font := TBGRABitmap.Create('lffont2.png');
tx_scroll_bitmap := TBGRABitmap.Create(640,23); // 240
mess_bitmap := TBGRABitmap.Create(640,480); // 240
radians := PI / 180;
fonts_width :=16;
fonts_height := 22;
sxx := 600; // start scroll pos x right
charek :=' '; // void always !
offset := ' '; // the first char on s_text = ' ' = space
sine_height := 0; // no-sinus height
scroll_speed := 1;
pos_y := 0;
//// Message
mess_timer :=0;
alfa :=0;
mess_chr := 0;
mess_id :=0; // message line index
char_pos :=0;
mess_page :=0;
alfa :=0;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
inc(r_timer);
if(r_timer>300) then
begin
rotate_dir := 0+ Random(3);
r_timer :=0;
end;
if(rotate_dir=0) then sin1 += 0.00;
if(rotate_dir=1) then sin1 += 0.01;
if(rotate_dir=2) then sin1 -= 0.01;
inc(alfa);
if (alfa>=55) then alfa :=0;
BGRAVirtualScreen1.RedrawBitmap;
end;
procedure TForm1.BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
var
// st
i,j : integer;
col: TBGRAPixel;
grad: TBGRAGradientScanner;
begin
// font to display message !
mess_Bitmap.FontName:='AmigaDigital8';
mess_Bitmap.FontHeight:=36;
grad := TBGRAGradientScanner.Create(BGRA(255,255,255),BGRA(0,0,200+alfa), gtLinear,PointF(0,0),PointF(0,35),True,True);
for i := 0 to NUM_STARS - 1 do
begin
j := i * 3;
sz := strz[j + 2];
if sz <= 0 then
strz[j + 2] := 1600
else
strz[j + 2] -= 10;
tempx := strz[j+0] * Cos(sin1) - strz[j + 1] * Sin(sin1);
tempy := strz[j+0] * Sin(sin1 + 0.2) + strz[j + 1] * Cos(sin1);
// stz stars z pos depth!
if sz >= 1200 then Col := BGRA(50,50,50)
else if (sz >= 1000) and (sz < 1200) then Col := BGRA(75, 75, 75)
else if (sz >= 800) and (sz < 1000) then Col := BGRA(100, 100, 100)
else if (sz >= 700) and (sz < 800) then Col := BGRA(125, 125, 125)
else if (sz >= 600) and (sz < 700) then Col := BGRA(150, 150, 150)
else if (sz >= 500) and (sz < 600) then Col := BGRA(175, 175, 175)
else if (sz >= 400) and (sz < 500) then Col := BGRA(200, 200, 200)
else if (sz >= 300) and (sz < 400) then Col := BGRA(225, 225, 225)
else Col := BGRA(255, 255, 255);
sx := Round((tempx * 500) / (sz + 250) + 640 div 2);
sy := Round((tempy * 500) / (sz + 250) + 480 div 2 );
sz -= 1;
if ((sx > 0) and (sx < 640)) and ((sy > 0) and (sy < 480)) then
Bitmap.Rectangle(Rect(sx, sy,sx+2, sy+2),col,dmSet);
// end stars !!
end;
logo.AlphaFill(alfa,0,1);
bitmap.StretchPutImage(Rect(25,-35,25+600,-35+200),logo,dmDrawWithTransparency); // Logo
bitmap.StretchPutImage(Rect(0,420,640+1000,420+48),tx_scroll_bitmap,dmDrawWithTransparency); // scroll text simple
// Message display
inc(mess_timer,2);
if (mess_timer >= 16) then
begin
if mess_page=0 then mess_Bitmap.TextOut(mess_chr*20,char_pos*22,message_1[mess_id][mess_chr],grad);
if mess_page=1 then mess_Bitmap.TextOut(mess_chr*20,char_pos*22,message_2[mess_id][mess_chr],grad);
mess_timer :=0;
mess_chr := mess_chr + 1;
if mess_chr>=27 then
begin
mess_chr :=0;
mess_id := mess_id +1 ;
char_pos := char_pos +1;
if mess_id>=18 then
begin
char_pos := 0;
mess_id := 0;
mess_Bitmap.FillRect(0,0,640,480,BGRA(255,192,0,0),dmSet);
mess_page := mess_page + 1;
if mess_page>=2 then mess_page:=0;
end;
end;
end;
Bitmap.StretchPutImage(Rect(20,90,740,90+520),mess_bitmap,dmDrawWithTransparency);
drawSineScroll; // normal text scrolling
end;
function TForm1.drawFontChar(charek: Char; x: Integer): Integer;
var
p, cx, cy, l,r: Integer;
begin
if (x > width) and (x > 0) then
begin
Result := 0;
Exit;
end;
// 16 x 22 pixel bitmap font scroller !! nothing else
p := Ord(charek) ;
r := (p - Ord(offset)) div 10 ;
cx := (p - Ord(offset) -r * 10 ) * fonts_width;
cy := 0+(r * fonts_height); // 0 if bitmap font pix is aligned or cy + fonts_height !
for l := 0 to fonts_width-1 do
begin
// if (cx >= 0) and (x <= width) and (x + fonts_width >= 0) then
if (cx >= 0) and (x + l <= width) then
begin
tx_scroll_bitmap.PutImagePart(x + l , pos_y , bitmap_font, Rect(cx + l, cy-1, cx + l + 1, cy + fonts_height-1), dmSet); // 2 = m
end;
end;
Result := 1;
end;
procedure TForm1.drawSineScroll;
var
last_char: Char;
x, i: Integer;
koda: Char;
xLimit: Integer;
begin
dec(sxx, scroll_speed);
x := sxx;
xLimit := width + fonts_width;
for i := 1 to Length(s_text) do
begin
koda := s_text[i];
x := x + fonts_width-4;
if (x > -fonts_width) and (x < xLimit) then
begin
if drawFontChar(koda, x) = 0 then
Break;
last_char := koda;
end;
end;
if x < 0 then sxx := xLimit;
end;
// Libere et vire tout , Free all
procedure TForm1.FormDestroy(Sender: TObject);
begin
bitmap_font.free;
tx_scroll_bitmap.Free;
logo.free;
mess_bitmap.free;
end;
end.