Font issue

Blitz3D Forums/Blitz3D Beginners Area/Font issue

JapaneseGameDev3000(Posted 2016) [#1]
Hy! I'm making a star trek video game, it will start off as a prototype where you will pilot the starship enterprise and the fight Borg in space. Basically I am having an issue loading font files and displaying them. The text does not show up for one, and two a couple of times when I tried to fix my code it just crashed. And three it crashes when I go to my QUITSTATE by pressing escape. Is there a way around this? By the way I am using Hybrid, It is a modern version of Blitz3D that I got on the forums.

Global MENUSTATE
Global PLAYSTATE
Global QUITSTATE
Global STATE
Global Font

Font = LoadFont("Final Frontier Shipside.ttf", 24, False, False, False)

Function STATE(STATE)

STATE = MENUSTATE

If STATE= MENUSTATE Then
ElseIf KeyHit(1) Then
STATE= QUITSTATE
ElseIf KeyHit(57) Then
STATE = PLAYSTATE
End If

If STATE = PLAYSTATE Then
ElseIf KeyHit(1) Then
STATE = MENUSTATE
End If 

If STATE = QUITSTATE Then
End
End If

End Function

If STATE = MENUSTATE Then

Graphics3D 640,480,16, 1

  SetBuffer BackBuffer()

 camera=CreateCamera()
  CameraViewport camera,0,0,800,600

  light=CreateLight()

Music = PlayMusic ("Star Trek.wav")

SetFont Font
Text 800, 0, "Hy! This is my Star Trek video game prototype, this is property of DonVito Napolitano.", True
Text 600, 0, "Press space to play or otherwise press the escape key to be assimilated.", True 

End If 

 







 While Not KeyHit(1)

			UpdateWorld
      RenderWorld

Flip

  Wend

If STATE = QUITSTATE Then
FreeFont Font
End If 

End 



RustyKristi(Posted 2016) [#2]
Basic rule in any engine or framework, if you invoke commands before you initialize the graphics system (Graphics3D in this case), it will be ignored.

Try placing the LoadFont command after Graphics3D.

Check the example code on how to use it as intended.

http://www.blitzbasic.com/b3ddocs/command.php?name=loadfont&ref=goto

Screen updates in a game like displaying text or sprites requires constantly animating or flipping/switching between frames so 2D and text commands should be inside your main game loop with Flip command (see again example above).


JapaneseGameDev3000(Posted 2016) [#3]
Ok Thank you RustyKristi, I shall take a look.