Cooooooool.
Code archives/3D Graphics - Effects/Spinning, exploding titles demo
This code has been declared by its author to be Public Domain code.
Download source code
| Game title made up from cubes spins in a star field and randomly explodes before reconstructing and continuing. |
; ; Spinning, exploding, reconstructing titles demo ; ; by big10p (A.K.A. Chris Chadwick) 2003. ; ; Written with Blitz3D v1.83 ; Graphics3D 800,600,16 SetBuffer BackBuffer() SeedRnd MilliSecs() Type grid_pix Field ent Field x#,y#,z# Field rot# End Type Type part Field ent Field x#,y#,z# End Type Const TOTAL_STARS = 400 ; Number of stars in star field. Const EXPLODE% = 400 ; Number of frames to explode before imploding. Global frame_count% Global fps% Global fps_timeout% Global frame_time% Global slowest_frame% Global frame_start% Global title_state% = 3 Global explode_count% Global cam = CreateCamera() PositionEntity cam,0,0,-14 Global light = CreateLight() Global spiv = CreatePivot() Global piv = CreatePivot() ; Master entity the title grid is constructed from. Global title_ent = CreateCube() EntityShininess title_ent,1 HideEntity title_ent ; Blur sprite. 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 make_titles() make_stars() ; Main loop. While Not KeyHit(1) frame_start = MilliSecs() update_titles() update_stars() UpdateWorld CopyRect 0,0,800,600,0,0,FrontBuffer(),BackBuffer() RenderWorld frame_time = MilliSecs() - frame_start ;show_info() Flip(1) Wend kill_titles() kill_stars() ClearWorld End ; ; Update title animation. ; Function update_titles() Local y# Select title_state Case 0 ; Prepare title pixels for exploding... 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 ; Explode title pixels... For this.grid_pix = Each grid_pix TranslateEntity this\ent,this\x,this\y,this\z ; Pitch, yaw and roll rotations must be done separately so that ; we can reverse the process correctly when reconstructing! 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 ; Implode/reconstruct exploded title... For this.grid_pix = Each grid_pix TranslateEntity this\ent,-this\x,-this\y,-this\z ; Do pitch, yaw and roll rotations separately and in REVERSE order ; from explosion so pixels reconstruct correctly! 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 ; Spin the title... ; Spin faster when showing back and slower when showing front. y = Abs(EntityYaw(piv))/2.0 TurnEntity piv,0,-(.3 + (Sin(y) * (y/20))),0 ; Randomly explode title. If Rand(1,400) = 100 Then title_state = 0 End Select End Function ; ; Create the game title grid. ; 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 pix_size# ; 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 "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 EntityColor pix\ent,100,50,0 End Select EndIf Next Next 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 ; ; Create and initialize stars. ; Function make_stars() For n = 1 To TOTAL_STARS this.part = New part this\ent = CreateSprite() EntityColor this\ent,255,255,255 EntityAutoFade this\ent,200,500 init_star(this) update_stars() Next End Function ; ; Free all mem used by stars. ; Function kill_stars() For this.part = Each part FreeEntity this\ent Delete this Next End Function ; ; Update star field. ; 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 ; ; Spawn/re-spawn star. ; Function init_star(star.part) r#=Rnd(0.0,360.0) star\x = Cos(r)/2.0 star\y = Sin(r)/2.0 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 "." |
Comments
Awesome! Would be interesting to see how this would look if combined with Tokamak to make the little blocks realistically collapse.
Kewl :)
Even faster with a quad instead of a sprite, also what the "Copyrect" between update and renderworld is for ????
here is the code with the quad
; Blur sprite.
; Create a fullscreen sprite
sprite = CreateMesh(Cam)
sf = CreateSurface(sprite)
; Make a quad
AddVertex sf, -1, 1, 0, 0, 0
AddVertex sf, 1, 1, 0, .1, 0
AddVertex sf, -1,-1, 0, 0, .1
AddVertex sf, 1,-1, 0, .1, .1
AddTriangle sf, 0, 1, 2
AddTriangle sf, 3, 2, 1
PositionEntity sprite,0,0,1.01
ScaleEntity sprite,1.5,1.5,1
EntityAlpha sprite,.124
EntityColor sprite,0,0,0
EntityBlend sprite,1
EntityFX sprite,1+8
EntityOrder sprite,1
Dither False
CameraClsMode cam,0,1
and i removed the Copyrect....don't know why it's here...
here is the code with the quad
; Blur sprite.
; Create a fullscreen sprite
sprite = CreateMesh(Cam)
sf = CreateSurface(sprite)
; Make a quad
AddVertex sf, -1, 1, 0, 0, 0
AddVertex sf, 1, 1, 0, .1, 0
AddVertex sf, -1,-1, 0, 0, .1
AddVertex sf, 1,-1, 0, .1, .1
AddTriangle sf, 0, 1, 2
AddTriangle sf, 3, 2, 1
PositionEntity sprite,0,0,1.01
ScaleEntity sprite,1.5,1.5,1
EntityAlpha sprite,.124
EntityColor sprite,0,0,0
EntityBlend sprite,1
EntityFX sprite,1+8
EntityOrder sprite,1
Dither False
CameraClsMode cam,0,1
and i removed the Copyrect....don't know why it's here...
I forgot : Good job big10p !!!
Absolute gem! nice one!
Ooooooooh.....
Cheers all - glad you like!
Olive: basically, without that copyrect, the blur doesnt work correctly and appears too harsh.
Olive: basically, without that copyrect, the blur doesnt work correctly and appears too harsh.
Niice work big10P!
Great stuff big10p!
Looks pretty awesome to me!
No external files either! Great!
IPete2.
Looks pretty awesome to me!
No external files either! Great!
IPete2.
Love it!
This would make a nice credits thingy in a game.... It is a different approch!
Excellent work man!
Excellent work man!
Flat out GROOVY!!!
Wonderful !
Sergio.
Sergio.
nice !
Very impressive.... marvlious... nice bit of code.
Droool... amazing.
ye its fun :)
Modified version of Exploding Title :P
First you need to make an include file.
BLOOMFILTER.bb:
Exploding_title2.bb:
First you need to make an include file.
BLOOMFILTER.bb:
;Bloom / Glow post-process filter by Bouncer ;Using SSwift's excellent texture blurring routine ;Use at your own risk :) may contain bugs ;Warning ... this filter uses LOT of fillrate so it's not for the old gfx-cards ;V1.2 ;Fixed camera bug... ;SSwifts blur routine --------------------- ; This is the location in the world where the camera will reside. ; This location should be far from any other geometry you have in your world. Const BLUR_CAM_X# = 65536.0 Const BLUR_CAM_Y# = 65536.0 Const BLUR_CAM_Z# = 0.0 ;Modified to additive blend in the same time as blur. ;Also modified the copyrecting... so that multiple passes don't cause texture drifting. ;this is just a quick fix... don't actually get why tex texture drifts... ; ------------------------------------------------------------------------------------------------------------------- ; This function blurs a texture using a technique that takes advantage of 3D acceleration. ; ; * You MUST hide all other cameras before calling this function! ; * You MUST reset your texture's blending mode, scale, and position after calling this function! ; ; Texture is the texture you want blurred. ; ; Blur_Quality defines the quality of the blur. 1 = 4 passes, 2 = 8 passes, 3 = 12 passes, etc. ; ; (The reason that the passes are in multiples of four is because interference artifacts are created when ; the number of passes is not a multiple of four... meaning that ten passes will actually look far worse ; than eight.) ; ; Blur_Radius# defines the radius of the blur, in pixels, assuming a map size of 256x256. ; ;(Ie, a radius of 16 will be the same width regardless of whether the texture is 16x16 or 512x512. It will ; only be exactly 16 pixels wide if the map is 256x256.) ; ------------------------------------------------------------------------------------------------------------------- Function BlurTexture(Texture, Blur_Quality, Blur_Radius#) Local BlurMesh[16*4] ; This is used for temporary storage of the meshes used for soft shadow blurring. ; If blurring is enabled... If Blur_Quality > 0 Blur_Cam = CreateCamera() ; Set the camera's range to be very small so as to reduce the possiblity of extra objects making it into the scene. CameraRange Blur_Cam, 0.1, 100 ; Set the camera to zoom in on the object to reduce perspective error from the object being too close to the camera. CameraZoom Blur_Cam, 16.0 ; Aim camera straight down. RotateEntity Blur_Cam, 90, 0, 0, True ; Set the camera viewport to the same size as the texture. CameraViewport Blur_Cam, 0, 0, TextureWidth(Texture), TextureHeight(Texture) ; Set the camera so it clears the color buffer before rendering the texture. CameraClsColor Blur_Cam, 0,0,0 CameraClsMode Blur_Cam, True, True ; Position the blur camera far from other entities in the world. PositionEntity Blur_Cam, BLUR_CAM_X#, BLUR_CAM_Y#, BLUR_CAM_Z# ; Create the sprites to use for blurring the shadow maps. For Loop = 0 To (Blur_Quality*4)-1 BlurMesh[Loop] = CreateSprite() EntityBlend BlurMesh[Loop],3 Next ; Scale the texture down because we scale the sprites up so they fill a larger area of the ; screen. (Otherwise the edges of the texture are darker than the middle because they don't ; get covered. ScaleTexture Texture, 0.5, 0.5 PositionTexture Texture, 0.5, 0.5 ; Blur texture by blitting semi-transparent copies of it on top of it. BlurRadius# = Blur_Radius# * (1.0 / 256.0) BlurAngleStep# = 360.0 / Float(Blur_Quality*4) ; Normally we would just divide 255 by the number of passes so that adding all the passes ; together would not exceed 256. However, if we did that, then we could not have a number of ; passes which does not divide 256 evenly, or else the error would result in the white part of ; the image being slightly less than white. So we round partial values up to ensure that ; white will always be white, even if it ends up being a little whiter than white as a result ; when all the colors are added, since going higher than white just clamps to white. BlurShade = Ceil(255.0 / Float(Blur_Quality*4)) ; Place each of the blur objects around a circle of radius blur_radius. For Loop = 0 To (Blur_Quality*4)-1 EntityTexture BlurMesh[Loop], Texture EntityFX BlurMesh[Loop], 1+8 EntityAlpha BlurMesh[Loop], 1.0 / Float(Loop+1) ScaleSprite BlurMesh[Loop], 2, 2 BlurAngle# = BlurAngleStep# * Float(Loop) + 180.0*(Loop Mod 2) Xoff# = BlurRadius# * Cos(BlurAngle#) Yoff# = BlurRadius# * Sin(BlurAngle#) PositionEntity BlurMesh[Loop], BLUR_CAM_X# + Xoff#, BLUR_CAM_Y# - 16.0, BLUR_CAM_Z# + Yoff#, True Next ; Render the new texture. RenderWorld ; Copy the new texture from the screen buffer to the texture buffer. CopyRect 1, 1, TextureWidth(Texture)-1, TextureHeight(Texture)-1, 0, 0, BackBuffer(), TextureBuffer(Texture) ; Free the blur entities. For Loop = 0 To (Blur_Quality*4)-1 FreeEntity BlurMesh[Loop] Next ; Free the blur camera. FreeEntity Blur_Cam EndIf End Function ;--------------------------------------------------- ;GLOW VARIABLES Global GL_cam Global GL_scenecam ;This stores the pointer to your scene camera Global GL_offset = 65536 ;Offset for the glow camera Global GL_texsize = 256 ;Glow texture resolution (128 or 256 recommended) Global GL_camzoom# = 1.0 ;Change this value if your camzoom differs from the default Global GL_sprite Global GL_tex,GL_texbuffer Global GL_sprite_scene Global GL_timer=1 ;Initializes the filter ;-------------------------- ;camera - your main scene camera ;NOTE - do not change camera rotation before calling this init function. Function InitGlow(camera) GL_scenecam = camera ;SET GLOW CAMERA GL_cam = CreateCamera() PositionEntity GL_cam,GL_offset,0,0 CameraProjMode GL_cam,2 CameraRange GL_Cam, 1, 100 CameraClsMode GL_cam,0,1 CameraViewport GL_cam,0,0,GL_texsize,GL_texsize HideEntity GL_cam ;SET GLOW SPRITE 1 (FOR DARKENING PASSES) GL_sprite = CreateSprite() GL_tex = CreateTexture(GL_texsize,GL_texsize,256+16+32) GL_texbuffer = TextureBuffer(GL_tex) EntityTexture GL_sprite,GL_tex PositionEntity GL_sprite,GL_offset,0,1 EntityOrder GL_sprite,-999 EntityFX GL_sprite,1 ;SET GLOW SPRITE 2 (FINAL OVERLAY) GL_sprite_scene = CreateSprite() EntityTexture GL_sprite_scene,GL_tex ScaleSprite GL_sprite_scene,2*(1.0/GL_camzoom),2*(1.0/GL_camzoom) PositionEntity GL_sprite_scene,EntityX(GL_scenecam),EntityY(GL_scenecam),EntityZ(GL_scenecam)+2 EntityParent GL_sprite_scene,GL_scenecam EntityOrder GL_sprite_scene,-999 EntityFX GL_sprite_scene,1 End Function ;Renders the filter ;-------------------------- ;fade - initial fade value for the scene ;dark_passes - how many multiply passes (darkening) ;glow_passes - how many blur / glow passes ;glare_size - blur radius ;just play with the values until you find a good combination. ;IMPORTANT NOTES ;* The scene camera will be hidden automatically... ; but you must hide every other camera you might be using Before calling this Function. ;* Also if you want to turn the blurring off you MUST HIDE the GL_sprite_scene object and stop calling this function (obviously :) ;* The more dark_passes and glow_passes - the slower the function is ... so beware. ; Also switching to smaller texture size will boost performance. Function RenderGlow(fade#=0.15,dark_passes=2,glow_passes=3,glare_size#=4) ;RENDER THE SCENE WITH MAIN CAMERA AND COPY TO TEXTURE ;Also apply the fade filter HideEntity GL_sprite EntityBlend GL_sprite_scene,1 EntityColor GL_sprite_scene,0,0,0 EntityAlpha GL_sprite_scene,fade CameraViewport GL_scenecam,0,0,GL_texsize,GL_texsize RenderWorld CopyRect 1,1,GL_texsize-1,GL_texsize-1,0,0,BackBuffer(),GL_texbuffer CameraViewport GL_scenecam,0,0,GraphicsWidth(),GraphicsHeight() ShowEntity GL_sprite EntityColor GL_sprite_scene,255,255,255 EntityAlpha GL_sprite_scene,1 ;SWITCH TO GLOW CAMERA AND HIDE MAIN CAMERA HideEntity GL_scenecam ShowEntity GL_cam ;MULTIPLY BLEND WITH BACKBUFFER TO MAKE THE CONTRAST HIGHER ;(RESERVE THE LUMINATED AREAS) EntityBlend GL_sprite,2 For i=1 To dark_passes RenderWorld Next CopyRect 1,0,GL_texsize-1,GL_texsize,0,0,BackBuffer(),GL_texbuffer EntityBlend GL_sprite,1 HideEntity GL_sprite ;BLUR AND PUT SOME GLOW ON THE TEXTURE ;MORE PASSES - MORE GLOW HideEntity GL_cam For i=1 To glow_passes blurtexture(GL_tex,1,glare_size) Next ScaleTexture GL_tex, 1,1 PositionTexture GL_tex,0,0 TextureBlend GL_tex, 2 ;SWITCH BACK TO NORMAL CAMERA ShowEntity GL_scenecam ;BLEND WITH ADDITIVE BLENDING WITH THE SCENE EntityBlend GL_sprite_scene,3 End Function
Exploding_title2.bb:
Include "BLOOMFILTER.bb" ; ; Spinning, exploding, reconstructing titles demo ; ; by big10p (A.K.A. Chris Chadwick) 2003. ; ; Written with Blitz3D v1.83 ; Graphics3D 1024,768,32,1 SetBuffer BackBuffer() SeedRnd MilliSecs() Type grid_pix Field ent Field x#,y#,z# Field rot# End Type Type part Field ent Field x#,y#,z# End Type Const TOTAL_STARS = 250 ; Number of stars in star field. Const EXPLODE% = 360 ; Number of frames to explode before imploding. Global frame_count% Global fps% Global fps_timeout% Global frame_time% Global slowest_frame% Global frame_start% Global explode_count% Global cam = CreateCamera() PositionEntity cam,0,0,-14 Global light = CreateLight() Dim piv(2) piv(1) = CreatePivot() piv(2) = CreatePivot() ; Master entity the title grid is constructed from. Global title_ent = CreateSphere() EntityShininess title_ent,0 HideEntity title_ent Global title_ent2 = CreateCube() EntityShininess title_ent2,1 HideEntity title_ent2 ; Blur sprite. 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 make_stars() initglow(cam) Dim title_state%(2) title_state%(1) = 4 title_state%(2) = 5 Global current_title = 1 Global timer360# = 0 make_title(current_title) ;make_title(2) ; Main loop. While Not KeyHit(1) frame_start = MilliSecs() update_title(current_title) ;update_title(2) update_stars() UpdateWorld renderglow(0.69,2,4,5) CopyRect 0,0,GraphicsWidth(),GraphicsHeight(),0,0,FrontBuffer(),BackBuffer() RenderWorld frame_time = MilliSecs() - frame_start show_info() Flip Cls timer360 = timer360 + 0.25 : If timer360 > 359 Then timer360 = 0 Wend kill_titles(current_title) kill_stars() ClearWorld End ; ; Update title animation. ; Function update_title(title_page) Local s# = title_state(title_page) Local y# Select s# Case 0 ; Prepare title pixels for exploding... title_state(title_page) = 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 ; Explode title pixels... For this.grid_pix = Each grid_pix TranslateEntity this\ent,this\x,this\y,this\z ; Pitch, yaw and roll rotations must be done separately so that ; we can reverse the process correctly when reconstructing! 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(title_page) = 5 explode_count = EXPLODE EndIf Case 2 ; Implode/reconstruct exploded title... For this.grid_pix = Each grid_pix TranslateEntity this\ent,-this\x,-this\y,-this\z ; Do pitch, yaw and roll rotations separately and in REVERSE order ; from explosion so pixels reconstruct correctly! TurnEntity this\ent,0,0,-this\rot TurnEntity this\ent,0,-this\rot,0 TurnEntity this\ent,-this\rot,0,0 Next TurnEntity piv(title_page),0,-4,0 TurnEntity cam,0,-2,0 explode_count = explode_count - 1 If explode_count = 0 Then title_state(title_page) = 3 : timer360 = 0 Case 3 ; Spin the title... ; Spin faster when showing back and slower when showing front. y = Abs(EntityYaw(piv(title_page)))/2.0 TurnEntity piv(title_page),0,-(.3 + (Sin(y) * (y/20))),0 ; Is it time to explode again? If timer360 = 359 Then title_state(title_page) = 0 Case 4 ; Introduce title If timer360 = 0 Then PositionEntity piv(title_page),0,0,360 * 2 Else If timer360 <= 45 Then MoveEntity piv(title_page),0,0,-4 TurnEntity piv(title_page),0,0,title_page * 4 TurnEntity cam,0,0,4 - title_page * 2 Else title_state(title_page) = 3 timer360 = 0 EndIf EndIf Case 5 ; switch title screen If current_title = title_page Then If current_title = 1 Then current_title = 2 Else current_title = 1 kill_titles(title_page) make_title(current_title) title_state(current_title) = 4 timer360 = 0 update_title(current_title) PointEntity(piv(current_title), cam) TurnEntity(piv(current_title),180,0,0) TurnEntity(piv(current_title),0,0,180) EndIf End Select End Function ; ; Create the game title grid. ; Function make_title(title_page) 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 pix_size# ; Find width and height of title grid from DATA If title_page = 1 Then Restore TITLE_DATA Else Restore TITLE_DATA2 EndIf 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(title_page),pix_size,pix_size,pix_size If title_page = 1 Then Restore TITLE_DATA Else Restore TITLE_DATA2 EndIf 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 Select datum$ Case "1" pix\ent = CopyEntity(title_ent2,piv(title_page)) PositionEntity pix\ent,tl_x + ((c-1)*grid_step),tl_y - ((r-1)*grid_step),0,True EntityColor pix\ent,64,64,64 ScaleEntity pix\ent,1,1,1 Case "2" pix\ent = CopyEntity(title_ent2,piv(title_page)) PositionEntity pix\ent,tl_x + ((c-1)*grid_step),tl_y - ((r-1)*grid_step),0,True EntityColor pix\ent,127,127,127 ScaleEntity pix\ent,1,1,1 Case "3" pix\ent = CopyEntity(title_ent2,piv(title_page)) PositionEntity pix\ent,tl_x + ((c-1)*grid_step),tl_y - ((r-1)*grid_step),0,True EntityColor pix\ent,255,127,64 ScaleEntity pix\ent,1.1,1.1,1.1 Case "4" pix\ent = CopyEntity(title_ent2,piv(title_page)) PositionEntity pix\ent,tl_x + ((c-1)*grid_step),tl_y - ((r-1)*grid_step),0,True EntityColor pix\ent,192,192,192 ScaleEntity pix\ent,1,1,1 Default pix\ent = CopyEntity(title_ent,piv(title_page)) PositionEntity pix\ent,tl_x + ((c-1)*grid_step),tl_y - ((r-1)*grid_step),0,True EntityColor pix\ent,64,127,255 End Select EndIf Next Next End Function ; ; Free all mem used by title. ; Function kill_titles(title_page) For this.grid_pix = Each grid_pix FreeEntity this\ent Delete this Next ;piv(title_page) End Function ; ; Backup all mem used by title. ; ;Function backup_titles() ; For this.grid_pix = Each grid_pix ; CopyEntity this\ent ; 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 ; ; Create and initialize stars. ; Function make_stars() For n = 1 To TOTAL_STARS this.part = New part this\ent = CreateSprite() bright_level = Rnd(32,255) EntityColor this\ent,bright_level,bright_level,bright_level EntityAutoFade this\ent,200,500 init_star(this) update_stars() Next End Function ; ; Free all mem used by stars. ; Function kill_stars() For this.part = Each part FreeEntity this\ent Delete this Next End Function ; ; Update star field. ; 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 ; ; Spawn/re-spawn star. ; Function init_star(star.part) r#=Rnd(0.0,360.0) star\x = Cos(r)/2.0 star\y = Sin(r)/2.0 star\z = -Rnd(.1,3) PositionEntity star\ent,star\x*50,star\y*50,500 End Function .TITLE_DATA Data " ttttttttttttttttttttttttttttttttttttttttt " Data "ttttttttttttttttttttttttttttttttttttttttttt" Data "tt tt" Data "tt tt" Data "tt tt" Data "tt 33 33 33333 3333333 3333333 tt" Data "tt 333 333 33 33 33 33 tt" Data "tt 33 3 33 3333333 333 3333 tt" Data "tt 33 33 33 33 33 33 tt" Data "tt 33 33 33 33 3333333 3333333 tt" Data "tt tt" Data "tt 33333 33333 33 33 3333333 tt" Data "tt 33 33 33 33 333 333 33 tt" Data "tt 33 3333333 33 3 33 3333 tt" Data "tt 33 3333 33 33 33 33 33 tt" Data "tt 333333 33 33 33 33 3333333 tt" Data "tt tt" Data "tt tt" Data "tt tt" Data "ttttttttttttttttttttttttttttttttttttttttttt" Data " ttttttttttttttttttttttttttttttttttttttttt " Data "." .TITLE_DATA2 Data " t ttt tt ttt " Data "333333t3333333t3333333t3333333t3333333333t3" Data "3333333t3333333t3333333tt3333t3333333333t33" Data "33 t tt ttt tttt t t 33" Data "33 t tttt 33" Data "33 t 111111 11 11 44444444444 33" Data "33 t 11 11 11 11 44444444444 33" Data "33 t 111111 111 44 33" Data "33 t 11 11 111 444444 33" Data "33t 111111 111 4444 33" Data "33 44 44 33" Data "33 4444 222222 222222 33" Data "33 444444 222 222 33" Data "33 44 2222 2222 33" Data "33 444444444 222 222 33" Data "33 444444444 222222 222222 33" Data "33 t 33" Data "33 tt t ttt tt t33" Data "33333t3333333t3333333333t33333333333333t333" Data "3333t3333333t333333333tt333333333333ttt3333" Data " ttt tt t tt ttt " Data "."
Pretty nice, _33. I only get 20fps on my old crate, tho.
P.S. Can you put your code into code boxes, please (use 'codebox' tag, instead of just 'code').
P.S. Can you put your code into code boxes, please (use 'codebox' tag, instead of just 'code').
Sorry Chris! I left the resolution at 1360x1024! I've lowered to 1024x768 and put the code in the right format.
Cheers.
Cheers.