names of characters over there heads

Blitz3D Forums/Blitz3D Beginners Area/names of characters over there heads

I tried to make a simple example of how to do the name on texture thing and guess what, it didn't work, and I'm not completely sure why. I think it might have something to do with me not using sprites and using quads instead. I'll try to make an example using those soon.

Edit:
Here's the example, there's a sprite and a quad, both work.
One problem, the color for the shadow text for some reason turns black even if you put 255,255,255 so I had to put 254 for red.

Edit2: In the example I forgot to mention that the reason why nothing was showing, was because I tried using the flags 2 and 4, not at the same time though, but they made the texture totally disappear.

InitGraphics(800,600)

Global Light = CreateLight()
	
Global Camera = CreateCamera()
	PositionEntity Camera,0,2,-5
	RotateEntity Camera,20,0,0

Global Plane = CreatePlane()
	
Global Name$ = "GIA"

Global TurnPivot = CreatePivot()

Global Player = CreateCube(TurnPivot)
	PositionEntity Player,0,1,3
	ScaleEntity Player,.5,.5,.5
	EntityColor Player,255,0,0
	


Global Sprite = CreateSprite()
	ScaleSprite Sprite,.5,.25

Global Sprite2 = CreateQuad(.5,.25,0)
	ScaleMesh Sprite2,-1,1,1
	
Global SpriteTexture = CreateNameTexture(Name,1+16+32)
	EntityTexture Sprite,SpriteTexture
	EntityTexture Sprite2,SpriteTexture

EntityParent Sprite,Player
PositionEntity Sprite,1,MeshHeight(Player)/2+.5,0

EntityParent Sprite2,Player
PositionEntity Sprite2,-1,MeshHeight(Player)/2+.5,0

While Not KeyDown(1)
	
	If KeyDown(200) TranslateEntity Camera,0,0,.1
	If KeyDown(208) TranslateEntity Camera,0,0,-.1
	If KeyDown(203) TranslateEntity Camera,-.1,0,0
	If KeyDown(205) TranslateEntity Camera,.1,0,0
	
	TurnEntity TurnPivot,0,1,0
	TurnEntity Sprite2,0,DeltaYaw(Sprite2,Camera)*.8,0
	
	UpdateWorld
	RenderWorld
	
	Flip
	
Wend
End

Function ShadowText(value$,x#,y#,red%=255,green%=255,blue%=255,shadow_red=20,shadow_green=20,shadow_blue=20,center_x=1,center_y=1)
	Color shadow_red,shadow_green,shadow_blue
	Text x+1,y,value,center_x,center_y
	Text x,y+1,value,center_x,center_y
	Text x+1,y+1,value,center_x,center_y
	
	Color red,green,blue
	Text x,y,value,center_x,center_y
End Function

Function InitGraphics(w = 1024, h = 768,title$="Blitz3D Program",exit_message$="")
	Graphics3D w, h, 32, 2
	SetBuffer BackBuffer()
	SeedRnd MilliSecs()
	
	If exit_message <> ""
		AppTitle title,exit_message
			Else
				AppTitle title
	EndIf
End Function

Function CreateNameTexture(name$,flags)
	Local Width% = StringWidth(name)*2
	Local Height% = StringHeight(name)*2
	Local texture = CreateTexture(Width,Height,flags)
	
	SetBuffer TextureBuffer(texture)
		Color 0,255,0
		Rect 0,0,TextureWidth(texture),TextureHeight(texture)*.1
		Rect 0,TextureHeight(texture)*.9,TextureWidth(texture),TextureHeight(texture)*.1
		
		Color 255,255,255
		ShadowText(name,TextureWidth(texture)*.5,TextureHeight(texture)*.5,254)
	SetBuffer BackBuffer()
	
	Return texture
End Function

Function CreateQuad(width#,height#,order%=-1,parent%=False)
	Local v0,v1,v2,v3
	Local Point,Surface
	
	If Not parent = False
		Point = CreateMesh(parent)
			Else
				Point = CreateMesh()
	EndIf
	
	If order <> 0
		EntityOrder Point,order
	EndIf
	
	EntityFX Point,1
	
	Surface = CreateSurface(Point)
	
	v0=AddVertex(Surface,-(width*.5),(height*.5),0 ,0,0)
	v1=AddVertex(Surface,(width*.5),(height*.5),0 ,1,0)
	v2=AddVertex(Surface,-(width*.5),-(height*.5),0 ,0,1)
	v3=AddVertex(Surface,(width*.5),-(height*.5),0 ,1,1)
	
	AddTriangle(Surface,v0,v1,v2)
	AddTriangle(Surface,v1,v3,v2)
	
	Return Point
End Function