Hi
There might be something in this that you can use:
Graphics3D 800,600,16
SetBuffer BackBuffer()
SeedRnd MilliSecs()
Type grid_pix
Field ent
Field x#,y#,z#
Field rot#
End Type
Global frame_count%
Global fps%
Global fps_timeout%
Global frame_time%
Global slowest_frame%
Global frame_start%
Global title_state% = 3
Global cam = CreateCamera()
PositionEntity cam,0,0,-14
;TurnEntity cam,10,0,0
Global light = CreateLight()
Global spiv = CreatePivot()
Global piv = CreatePivot()
;RotateEntity piv,0,180,0
;PositionEntity spiv,0,0,-100
;EntityParent piv,spiv
;PositionEntity spiv,0,100,0
make_titles()
;RotateEntity piv,-20,0,0
If 1
sprite = CreateSprite(cam)
PositionEntity sprite,0,0,1.1
ScaleSprite sprite,1.5,1
SpriteViewMode sprite,1
EntityAlpha sprite,.124
EntityColor sprite,0,0,0
EntityBlend sprite,1
EntityFX sprite,1
EntityOrder sprite,1
Dither False
CameraClsMode cam,0,1
EndIf
Type part
Field ent
Field x#,y#,z#
End Type
Const TOTAL_STARS = 400
make_stars()
WireFrame 0
While Not KeyHit(1)
frame_start = MilliSecs()
If KeyHit(208) Then title_state = 0
update_titles()
update_stars()
UpdateWorld
If Not KeyDown(14) CopyRect 0,0,800,600,0,0,FrontBuffer(),BackBuffer()
RenderWorld
frame_time = MilliSecs() - frame_start
show_info()
Flip(1)
;Delay 50
;WaitKey()
Wend
kill_titles()
End
Global explode_count
Const EXPLODE% = 400
;
; Update title animation
;
Function update_titles()
Local y#
Select title_state
Case 0
title_state = 1
explode_count = EXPLODE
For this.grid_pix = Each grid_pix
this\x = Rnd(-1,1)
this\y = Rnd(-1,1)
this\z = Rnd(-1,1)
this\rot = Rnd(-1,1)
Next
Case 1
For this.grid_pix = Each grid_pix
TranslateEntity this\ent,this\x,this\y,this\z
TurnEntity this\ent,this\rot,0,0
TurnEntity this\ent,0,this\rot,0
TurnEntity this\ent,0,0,this\rot
Next
explode_count = explode_count - 1
If explode_count = 0
title_state = 2
explode_count = EXPLODE
EndIf
Case 2
For this.grid_pix = Each grid_pix
TranslateEntity this\ent,-this\x,-this\y,-this\z
TurnEntity this\ent,0,0,-this\rot
TurnEntity this\ent,0,-this\rot,0
TurnEntity this\ent,-this\rot,0,0
Next
TurnEntity piv,0,-1,0
explode_count = explode_count - 1
If explode_count = 0 Then title_state = 3
Case 3
y = Abs(EntityYaw(piv))/2.0
TurnEntity piv,0,-(.3 + (Sin(y) * (y/20))),0
If Rand(1,400)=100 Then title_state = 0
End Select
End Function
;
; Create the game title grid of cubes
;
Function make_titles()
Local title_rows% = 0
Local title_cols% = 0
Local grid_row$, datum$
Local pix.grid_pix
Local grid_step#
Local tl_x#, tl_y#
Local title_width# = 18.0
Local title_height#
Local title_ent
Local pix_size#
title_ent = CreateCube()
EntityShininess title_ent,1
; Find width and height of title grid from DATA
Restore TITLE_DATA
Read grid_row$
title_cols = Len(grid_row$)
Repeat
title_rows = title_rows + 1
Read grid_row$
Until grid_row$ = "."
title_height = title_rows * (title_width/title_cols)
grid_step = title_width/(title_cols-1)
tl_x = -title_width/2.0
tl_y = title_height/2.0
pix_size# = grid_step/2.0 - 0.04
ScaleEntity piv,pix_size,pix_size,pix_size
Restore TITLE_DATA
For r = 1 To title_rows
Read grid_row$
For c = 1 To title_cols
datum$ = Mid$(grid_row$,c,1)
If datum$ <> " "
pix = New grid_pix
pix\ent = CopyEntity(title_ent,piv)
PositionEntity pix\ent,tl_x + ((c-1)*grid_step),tl_y - ((r-1)*grid_step),0,True
Select datum$
;Case " "
; EntityColor pix\ent,0,0,0
Case "1"
EntityColor pix\ent,150,50,0
ScaleEntity pix\ent,1,1,4
Case "2"
EntityColor pix\ent,0,150,0
ScaleEntity pix\ent,1,1,6
Case "3"
EntityColor pix\ent,150,150,0
ScaleEntity pix\ent,1,1,2
Case "4"
EntityColor pix\ent,150,0,0
ScaleEntity pix\ent,1,1,4
Default
rgb_step# = 255.0/19.0
val = Asc(datum$) - Asc("a")
;DebugLog val
;DebugLog 255-val*rgb_step#
EntityColor pix\ent,100,50,0;255,0,255 - val*rgb_step#
End Select
EndIf
Next
Next
FreeEntity title_ent
End Function
;
; Free all mem used by title
;
Function kill_titles()
For this.grid_pix = Each grid_pix
FreeEntity this\ent
Delete this
Next
End Function
;
; Show debug info
;
Function show_info()
frame_count = frame_count + 1
If MilliSecs() > fps_timeout Then
fps_timeout = MilliSecs() + 1000
fps = frame_count
frame_count = 0
EndIf
If frame_time > slowest_frame Then slowest_frame = frame_time
Color 0,0,100
Rect 0,0,200,80,1
Color 255,255,255
Text 10,10," Triangles: " + TrisRendered()
Text 10,25," Millisecs: " + frame_time
Text 10,40," slowest: " + slowest_frame
Text 10,55," FPS: " + fps
End Function
Function make_stars()
For n = 1 To TOTAL_STARS
this.part = New part
this\ent = CreateSprite()
;ScaleSprite this\ent,5,5
EntityColor this\ent,255,255,255
EntityAutoFade this\ent,200,500
init_star(this)
update_stars()
Next
End Function
Function kill_stars()
For this.part = Each part
FreeEntity this\ent
Delete this
Next
End Function
Function update_stars()
For this.part = Each part
If Not EntityInView(this\ent,cam)
init_star(this)
Else
TranslateEntity this\ent,this\x,this\y,this\z
EndIf
Next
End Function
Function init_star(star.part)
r#=Rnd(0.0,360.0)
star\x = Cos(r)/2
star\y = Sin(r)/2
star\z = -Rnd(.01,.5)
PositionEntity star\ent,star\x*50,star\y*50,500
End Function
.TITLE_DATA
Data " ttttttttttttttttttttttttttttttttttttttttt "
Data "t t"
Data "t 111 111 111 111 111 111 1 1 1 111 t"
Data "t 1 1 1 1 1 1 1 1 1 11 11 1 t"
Data "t 111 111 111 1 11 111 1 1 1 1 1 11 t"
Data "t 1 1 1 1 1 1 1 1 1 1 1 t"
Data "t 111 1 1 1 111 111 1 1 1 1 111 t"
Data "t 2222 t"
Data "t 1 1 1 1 1 22222222 11 111 111 111 t"
Data "t 1 11 1 1 1 2244224422 1 1 1 1 1 1 t"
Data "t 1 1 11 1 1 2222222222 1 1 11 11 111 t"
Data "t 1 1 1 1 1 22 22 1 1 1 1 1 1 t"
Data "t 1 1 1 1 22 22 22 111 111 1 1 111 t"
Data "t 2 2 t"
Data " ttttttttttttt 3 tttttttttttttttt "
Data " 3 "
Data " 3 "
Data " 3 "
Data "."
...then again, I've been to the pub and am a bit p@~#ed. Something i knocked up aged ago.
|