My effort.
Only three stars.
the premiere, so I have indulged.
Code: Select all
#include "windows.bi"
#include "fbgfx.bi"
Type pt
As Single x,y,z
As Single rd,gr,bl,al
End Type
Type _float As pt
Dim Shared As pt eyepoint=Type(400,300,800)
'Fonts concise from Mysoft's
Const FS_BOLD = 2
Const FS_ITALIC = 4
Sub DrawFont(Byref BUFFER As Any Ptr=0,Byval POSX As Long, Byval POSY As Long, _
Byref FTEXT As String, Byref FNAME As String,Byval FSIZE As Long, _
Byval FCOLOR As Ulong=Rgb(255,255,255),Byval FSTYLE As Long=0,Byval CHARSET As Long=DEFAULT_CHARSET )
Static FINIT As Long
Static As hdc THEDC
Static As hbitmap THEBMP
Static As Any Ptr THEPTR
Static As fb.image Ptr FBBLK
Static As Long TXTSZ,RESU,RESUU
Static As hfont THEFONT
Static As Long FW,FI,TXYY
Static DSKWND As hwnd, DSKDC As hdc
Static MYBMPINFO As BITMAPINFO
Static As TEXTMETRIC MYTXINFO
Static As SIZE TXTSIZE
Static As RECT RCT
Static As Ubyte Ptr ubp
ubp=Cptr(Ubyte Ptr,@FCOLOR)
Swap ubp[0],ubp[2]
Dim As Ubyte alphaval =ubp[3]
ubp[3]=0
#define FontSize(PointSize) -MulDiv(PointSize, GetDeviceCaps(THEDC, LOGPIXELSY), 72)
If FINIT = 0 Then
FINIT = 1
With MYBMPINFO.bmiheader
.biSize = Sizeof(BITMAPINFOHEADER)
.biWidth = 2048
.biHeight = -513
.biPlanes = 1
.biBitCount = 32
.biCompression = BI_RGB
End With
DSKWND = GetDesktopWindow()
DSKDC = GetDC(DSKWND)
THEDC = CreateCompatibleDC(DSKDC)
THEBMP = CreateDIBSection(THEDC,@MYBMPINFO,DIB_RGB_COLORS,@THEPTR,null,null)
ReleaseDC(DSKWND,DSKDC)
End If
If (FSTYLE And FS_BOLD) Then FW = FW_BOLD Else FW = FW_NORMAL
If (FSTYLE And FS_ITALIC) Then FI = True Else FI = False
THEFONT = CreateFont(FontSize(FSIZE),0,0,0,FW,FI,0,0,CHARSET,0,0,0,0,Cast(Any Ptr,Strptr(FNAME)))
SelectObject(THEDC,THEBMP)
SelectObject(THEDC,THEFONT)
GetTextMetrics(THEDC,@MYTXINFO)
GetTextExtentPoint32(THEDC,Strptr(FTEXT),Len(FTEXT),@TXTSIZE)
TXTSZ = TXTSIZE.CX
TXYY = TXTSIZE.CY
If (FSTYLE And FS_ITALIC) Then
If MYTXINFO.tmOverhang Then
TXTSZ += MYTXINFO.tmOverhang
Else
TXTSZ += 1+(FSIZE/2)
End If
TXYY += 1+(FSIZE/8)
End If
RCT.LEFT = 0
RCT.TOP = 1
RCT.RIGHT = TXTSZ
RCT.BOTTOM = TXYY+1
TXTSZ -= 1
TXYY -= 1
SetBkColor(THEDC,Rgba(255,0,255,0))
SetTextColor(THEDC,FCOLOR)
SystemParametersInfo(SPI_GETFONTSMOOTHING,null,@RESU,null)
If RESU Then SystemParametersInfo(SPI_SETFONTSMOOTHING,False,@RESUU,null)
ExtTextOut(THEDC,0,1,ETO_CLIPPED Or ETO_OPAQUE,@RCT,Strptr(FTEXT),Len(FTEXT),null)
If RESU Then SystemParametersInfo(SPI_SETFONTSMOOTHING,True,@RESUU,null)
FBBLK = THEPTR+(2048*4)-Sizeof(fb.image)
FBBLK->Type = 7
FBBLK->bpp = 4
FBBLK->Width = 2048
FBBLK->height = 512
FBBLK->pitch = 2048*4
Put BUFFER,(POSX,POSY),FBBLK,(0,0)-(TXTSZ-1,TXYY),Alpha,alphaval
DeleteObject(THEFONT)
End Sub
Sub getarray(a() As pt,i As Any Ptr)
Dim As String Text(22) = { "It is a period of civil war.", _
"Rebel spaceships, striking", _
"from a hidden base, have", _
"won their first victory", _
"against the evil Galactic", _
"Empire.", _
"During the battle, rebel", _
"spies managed to steal", _
"secret plans to the Empire's", _
"ultimate weapon, the", _
"Death Star, an armored space", _
"station with enough", _
"power to destroy an entire", _
"planet.", _
"Pursued by the Empire's", _
"sinister agents, Princess", _
"Leia races home aboard her", _
"starship, custodian of the", _
"stolen plans that can save", _
"her people and restore", _
"freedom to the galaxy....", _
"Coded by UEZ"}
For n As Long=0 To 22
drawfont (i,10,70*n,text(n),"Verdana",40,Rgb(0,200,0))
Next
Dim As Long counter
Dim As Ulong clr
For z As Long=1 To 2
For x As Long=0 To 849
For y As Long=0 To 40*40-1
clr=Point(x,y,i)
If clr<>Rgb(255,0,255) Then
counter+=1
If z=2 Then
With a(counter)
.x=x
.y=y
.rd=Cast(Ubyte Ptr,@clr)[2]
.gr=Cast(Ubyte Ptr,@clr)[1]
.bl=Cast(Ubyte Ptr,@clr)[0]
.al=255
End With
End If
End If
Next
Next
If z=1 Then Redim a(1 To counter):counter=0
Next z
End Sub
Sub star(starx As Long,stary As Long,size As Long,col As Ulong,rot As Single)
Var count=0,rad=0.0,_px=0.0,_py=0.0,pi=4*Atn(1),prime=Rgb(255,254,253)
For x As Integer=1 To 2
For z As Single=0+.28 +rot To 2*pi+.1+.28 +rot Step 2*pi/10
count=count+1
If count Mod 2=0 Then rad=size Else rad=.4*size
_px=starx+rad*Cos(z)
_py=stary+rad*Sin(z)
If count=1 Then Pset (_px,_py)Else Line -(_px,_py),prime
Next z
Paint (starx,stary),prime,prime
count=0:prime=col
Next x
End Sub
Sub RotateArray(wa() As pt,result() As pt,angle As _float,centre As pt,flag As Long=1,s As Single=1)
Dim As Single dx,dy,dz,w
Dim As Single SinAX=Sin(angle.x)
Dim As Single SinAY=Sin(angle.y)
Dim As Single SinAZ=Sin(angle.z)
Dim As Single CosAX=Cos(angle.x)
Dim As Single CosAY=Cos(angle.y)
Dim As Single CosAZ=Cos(angle.z)
Redim result(Lbound(wa) To Ubound(wa))
For z As Long=Lbound(wa) To Ubound(wa)
dx=wa(z).x-centre.x
dy=wa(z).y-centre.y
dz=wa(z).z-centre.z
Result(z).x=(((Cosay*Cosaz)*dx+(-Cosax*Sinaz+Sinax*Sinay*Cosaz)*dy+(Sinax*Sinaz+Cosax*Sinay*Cosaz)*dz))+centre.x
result(z).y=(((Cosay*Sinaz)*dx+(Cosax*Cosaz+Sinax*Sinay*Sinaz)*dy+(-Sinax*Cosaz+Cosax*Sinay*Sinaz)*dz))+centre.y
result(z).z=(((-Sinay)*dx+(Sinax*Cosay)*dy+(Cosax*Cosay)*dz))+centre.z
#macro perspective()
w = 1 + (result(z).z/eyepoint.z)
result(z).x = s*(result(z).x-eyepoint.x)/w+eyepoint.x
result(z).y = s*(result(z).y-eyepoint.y)/w+eyepoint.y
result(z).z = s*(result(z).z-eyepoint.z)/w+eyepoint.z
#endmacro
If flag Then: perspective():End If
result(z).rd=wa(z).rd
result(z).gr=wa(z).gr
result(z).bl=wa(z).bl
result(z).al=wa(z).al
Next z
End Sub
Function Regulate(Byval MyFps As Long,Byref fps As Long) As Long
Static As Double timervalue,_lastsleeptime,t3,frames
frames+=1
If (Timer-t3)>=1 Then t3=Timer:fps=frames:frames=0
Var sleeptime=_lastsleeptime+((1/myfps)-Timer+timervalue)*1000
If sleeptime<1 Then sleeptime=1
_lastsleeptime=sleeptime
timervalue=Timer
Return sleeptime
End Function
Sub preview
Dim As Long fps
Dim As String g(1 To 3)={"A long time ago.", "In a galaxy far,","far away...."}
Dim As Any Ptr i2=Imagecreate(800,400)
For n As Long=1 To 3
drawfont (i2,10,80*n,g(n),"Comic Sans MS",70,Rgb(0,100,200))
Next n
Dim As Single al=255
Do
al-=.75
Screenlock
Cls
Put(0,0),i2,Alpha,al
Screenunlock
Sleep regulate(60,fps),1
Loop Until al<10
Imagedestroy i2
End Sub
'=========================================
Screen 19,32,,64
Dim As Any Ptr i=Imagecreate(850,40*40)
Redim As pt a()
getarray(a(),i)
Redim As pt b(1 To Ubound(a))
Imagedestroy(i)
Dim As _float angle
angle.x=-1.25
Dim As pt centre=Type(400,400,-400)
Dim As Long fps
preview 'the start screen
Do
Randomize 13
angle.x-=.0001*2
centre.z+=1*2
centre.y+=.7*2
rotatearray(a(),b(),angle,centre,,1.2)
Screenlock
Cls
For n As Long=1 To 3
star(Rnd*800,Rnd*600,5+Rnd*5,Rgb(255,255,255-20*n),50*angle.x)
Next n
For n As Long=Lbound(b) To Ubound(b)
If b(n).z<1500 Then
b(n).al-=b(n).z/4
If b(n).al<1 Then b(n).al=0
Pset(b(n).x,b(n).y+5*Sin(n/5000+300*angle.x)),Rgba(b(n).rd,b(n).gr,b(n).bl,b(n).al)
End If
Next n
Draw String(50,50),"FPS "&fps,Rgb(100,100,100)
Screenunlock
Sleep regulate(25,fps),1
Loop Until Len(Inkey)
Sleep