gfont.bmx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. '===============================================================================
  2. ' Little Shooty Test Thing
  3. ' Code & Stuff by Richard Olpin ([email protected])
  4. '==============================================================================
  5. ' Graphic Font
  6. '==============================================================================
  7. Type GFont
  8. Global FontImg, f
  9. Global TypeStr$
  10. ' ---------------------------------------------------------------------------
  11. ' Init() - Load Font Image
  12. ' ---------------------------------------------------------------------------
  13. Function Init()
  14. FontImg = LoadAnimImage("gfx/abduction.png",32,32,0,49, MASKEDIMAGE)
  15. End Function
  16. ' ---------------------------------------------------------------------------
  17. ' DrawString(MsgX,MsgY,Message$)
  18. ' ---------------------------------------------------------------------------
  19. Function DrawString(MsgX,MsgY,Message$,centrex, centrey)
  20. Local MsgCount = Len(Message$)
  21. SetBlend MASKBLEND
  22. SetScale 1,1
  23. SetAlpha 1
  24. SetRotation 0
  25. length =Len(message$)*30
  26. x=msgx
  27. If centrex=1 Then x=msgx-(length/2)
  28. If centrex=-1 Then x=msgx-length
  29. If centrey=1
  30. y=msgy-16
  31. Else
  32. y=msgy
  33. EndIf
  34. For f=0 To MsgCount-1
  35. FontChar = Asc(Lower$(Mid$(Message$,f+1,1)))
  36. imgchar= sortchar(fontchar)
  37. DrawImage FontImg,x+(f*30),MsgY,ImgChar
  38. Next
  39. End Function
  40. ' ---------------------------------------------------------------------------
  41. ' Sortchar
  42. ' ---------------------------------------------------------------------------
  43. Function sortchar(char)
  44. ' Letters
  45. If char>=97 And char<=122 Then c=char-97
  46. ' Numbers
  47. If char>=48 And char<=57 Then c=char-22
  48. ' Special characters
  49. Select Char
  50. Case 63 c = 36
  51. Case 46 c= 37
  52. Case 44 c= 38
  53. Case 39 c= 39
  54. Case 34 c= 40
  55. Case 33 c= 41
  56. Case 40 c= 42
  57. Case 41 c= 43
  58. Case 45 c= 44
  59. Case 58 c= 45
  60. Case 59 c= 46
  61. Case 32 c= 48
  62. End Select
  63. Return c
  64. End Function
  65. End Type