Don't understand where value begins..

BlitzMax Forums/BlitzMax Beginners Area/Don't understand where value begins..

Amon(Posted 2005) [#1]
Type dizzyfontg

	Field x:Int, y:Int
	Field alpha:Float
	Field angle:Float
	Field fFrame:Int
	 
	Global xp:Int = 185, yp:Int = 185
	Global angleTemp:Float = 0
	Global alphaTemp:Float = 0
	Global tempframe:Int
	
	Global iter:Int
	
	Function createFont()
		
		tempframe = 0		
		For iter:Int = 0 To 9
		Local f:dizzyfontg = New dizzyfontg
		ListAddLast fontlist,(f)
		f.x = xp
		f.y = yp
		f.alpha = alphaTemp
		f.angle = angleTemp
		f.fFrame = tempframe
		
		
		
		xp:+50
		angleTemp:+45
		
		If iter = 0 Then tempframe = 0
		If iter = 1 Then tempframe = 1
		If iter = 2 Then tempframe = 2
		If iter = 3 Then tempframe = 2
		If iter = 4 Then tempframe = 3
		If iter = 5 Then tempframe = 4
		If iter = 6 Then tempframe = 5
		If iter = 7 Then tempframe = 6
		If iter = 8 Then tempframe = 1
		If iter = 9 Then tempframe = 7
		

		Next
		
	End Function

	Method drawFont()
	
			DrawImage dizzyfont,x,y,fFrame
			
	End Method
	
End Type


This is my type. I'm trying to use objects to create letters for text I want to display. I have a createFont function which creates and assigns the values to the new objects. The problem is that I can't seem to get the values correct for the images frame number. I end up with 2 D's. The exe will show you what I mean.

http://www.amon-interactive.com/storage/maindebug.zip


REDi(Posted 2005) [#2]
Maybe this might help...

!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{}~¦


If you arrange the characters in your image in that order, all you need to do is minus 33 from the Asc() value of the character you want.


Amon(Posted 2005) [#3]
Dont' have a clue what your talking about. :/


Eikon(Posted 2005) [#4]
He means if you align your letters in that order, you can pass the function a string, then do something like this:

Function DrawText(txt$, x, y)

For i = 1 to Len(txt$)
    DrawImage imgText, x, y, Asc(Mid(txt$, i, 1)) - 33
    x:+16
next

End Function
If you don't have all those characters you can still use A-Z and adjust the value by subtracting more or less.

A-Z, 26 frames would be:
Asc(Upper(Mid(txt$, i, 1))) - 65

http://www.lookuptables.com/