Ooops
October 28, 2020, 06:34:48 AM

Author Topic: [bb] Funky 3D titlescreen by _33 [ 1+ years ago ]  (Read 1327 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Funky 3D titlescreen by _33 [ 1+ years ago ]
« on: June 29, 2017, 12:28:43 AM »
Title : Funky 3D titlescreen
Author : _33
Posted : 1+ years ago

Description : This is a 3D titlescreen I made for an older project that will never see light of day.  So, I decided to post this code here.  It's a small piece of code that basically stamps your game title as text on a bunch of 3D yellow pucks.  After it ran the 650 frames, it then ends the program.  But in the original code, it was looping between the title screen and the main game menu.

NOTE:  This is old rookie code.


Code :
Code: BlitzBasic
  1. AppTitle "MAZEGAME"
  2.  
  3. ;----------------------------------------------------------------------------------------
  4. ; Define Global things
  5. ;----------------------------------------------------------------------------------------
  6. Graphics3D 1024,768,32,1
  7. Global fontsize# = 168
  8. Global ptr_fnt = LoadFont("Arial",fontsize#/2,True,False,False)
  9. Global scrollcycle = 0
  10.  
  11. Global doing_nothing_fps = 0
  12. Global camera%, ptr_light%
  13.  
  14. Dim sin_tb#(1079),cos_tb#(1079)
  15. For i=0 To 1079: sin_tb#(i)=Sin(i): cos_tb#(i)=Cos(i): Next
  16. ;Dim getcos(3),getsin(3): getcos(0)=1: getcos(2)=-1: getsin(1)=1: getsin(3)=-1
  17.  
  18. init_title_screen()
  19. While GetKey() = 0
  20.    IntitleLoop()
  21.    RenderWorld
  22.    Flip 1
  23.    scrollcycle = scrollcycle + 1 : If scrollcycle > 359 Then scrollcycle = scrollcycle - 360
  24.    If doing_nothing_fps > 650 Then Exit
  25. Wend
  26. close_title_screen()
  27. End
  28.  
  29.  
  30. ;----------------------------------------------------------------------------------------
  31. ; title screen management
  32. ;----------------------------------------------------------------------------------------
  33. Function init_title_screen()
  34.    doing_nothing_fps = 0
  35.    camera = CreateCamera()
  36.  
  37.    ptr_light = CreateLight()
  38.    LightColor ptr_light,0,0,0
  39.    RotateEntity ptr_light,90,0,0
  40.    AmbientLight 0,0,0
  41.  
  42.    t_obj.object_info = New object_info
  43.    t_objptr = CreateTexture(fontsize# * 2,fontsize#,256)
  44.    t_objobject_type = 2
  45.    SetBuffer TextureBuffer(t_objptr)
  46.    ClsColor 255,255,0
  47.    Cls
  48.    Color 255, 0, 0
  49.    SetFont ptr_fnt
  50.    Text fontsize# * 1.5,fontsize# * 0.75,"MAZEGAME",True,True
  51.    t_tex = t_objptr
  52.    SetBuffer BackBuffer()
  53.  
  54.    For z = 1 To 6
  55.       For x = -z To z
  56.          For y = -z To z
  57.             t_obj.object_info = New object_info
  58.             t_objptr = CreateCylinder(36 - z * 4)
  59.             t_objobject_type = 1
  60.             RotateEntity t_objptr,15 * x,0,-15 * y
  61.             ScaleEntity t_objptr,8,2,8
  62.             PositionEntity t_objptr,32 * x, 32 * y,32 * z
  63.             EntityTexture t_objptr,t_tex,0,1
  64.          Next
  65.       Next
  66.    Next
  67.  
  68.    CameraFogMode camera,1
  69.    CameraFogRange camera,64,224
  70.  
  71. End Function
  72.  
  73. Function IntitleLoop()
  74.    Local lc#
  75.    If doing_nothing_fps <= 250 Then
  76.       lc = doing_nothing_fps
  77.       AmbientLight lc,lc,lc
  78.    EndIf
  79.    If doing_nothing_fps >= 400 Then
  80.       lc = (650 - doing_nothing_fps)
  81.       AmbientLight lc,lc,lc
  82.    EndIf
  83.  
  84.    lx = (cos_tb#(scrollcycle * 2) * 30)
  85.    ly = (sin_tb#(scrollcycle * 2) * 30)
  86.    LightColor ptr_light, lx * 8, ly * 8, ly * 8
  87.    PositionEntity ptr_light,lx,ly,0
  88.  
  89.    If doing_nothing_fps < 500 Then
  90.       PositionEntity camera,0,0,(cos_tb#(scrollcycle * 2 + 120) * 15)
  91.       For t_obj.object_info = Each object_info
  92.          If t_objobject_type = 1 Then
  93.             TurnEntity t_objptr,0,sin_tb#(scrollcycle * 2 + 270) * 2, sin_tb#(scrollcycle * 2) * 2.5
  94.          EndIf
  95.       Next
  96.    EndIf
  97.  
  98.    doing_nothing_fps = doing_nothing_fps + 1
  99. End Function
  100.  
  101. Function close_title_screen()
  102.    For t_obj.object_info = Each object_info
  103.       If t_objobject_type = 1 Then
  104.          FreeEntity t_objptr
  105.       ElseIf t_objobject_type = 2 Then
  106.          FreeTexture t_objptr
  107.       EndIf
  108.       Delete t_obj.object_info
  109.    Next
  110.  
  111. End Function
  112.  
  113. Type object_info
  114.    Field ptr
  115.    Field xpos#
  116.    Field ypos#
  117.    Field zpos#
  118.    Field object_type%
  119. End Type


Comments :


Yo! Wazzup?(Posted 1+ years ago)

 No matter what I change the font to, I get an Error Message, "Font does not exist." (I did try saving the file)


Ked(Posted 1+ years ago)

 With mine I had a MAV unless it was in debug mode.


Bankie(Posted 1+ years ago)

 Wot Ked sed. Works in debug mode.


big10p(Posted 1+ years ago)

 I still get a MAV in debug. Moving the Graphics3D call to before the LoadFont command fixed things, though.


_33(Posted 1+ years ago)

 OOps :D  Fixed.  I've also fixed the size of the text appearing on the pucks.


*(Posted 1+ years ago)

 graphics3d in blitz3d always frees up all graphics, textures and fonts


John Blackledge(Posted 1+ years ago)

 1) Change CreateCylinder(.. to CreateSphere(..2) Comment out the EntityTexture... line.3) Add below:EntityColor t_objptr,Rnd(255),Rnd(255),Rnd(255) ! SMARTIES !


_33(Posted 1+ years ago)

 4) modify the ScaleEntity to ...            ScaleEntity t_objptr,8,3,8Neat!


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal