News
Forums
Code
Logs
Gallery
Specs
Search
bitmap font
Monkey Forums
/
Monkey Code
/
bitmap font
amonite
(Posted 2011)
[#1]
Strict Import mojo Function Main:Int() New Demo Return 0 End Function 'Quick reminder: ' !¨#$%&'()*+,-./ '0123456789:;<=>? '@ABCDEFGHIJKLMNO 'PQRSTUVWXYZ[\]^_ '`abcdefghijklmno 'pqrstuvwxyz{|}~ '... Class Demo Extends App Field f:Font Method OnCreate:Int() SetUpdateRate(60) f = New Font Font.LoadBmpFont(LoadImage("FantasyZone.png",8,8,60,1)) Return 0 End Method Method OnUpdate:Int() Return 0 End Method Method OnRender:Int() Font.Display(Mid("I LOVE ARCADE FONTS !",1),0,20,8) Return 0 End Method End 'Mid function from blitzmax. Function Mid$( str$,pos:Int,size:Int=-1 ) If pos>str.Length() Return "" pos-=1 If( size<0 ) Return str[pos..] If pos<0 size=size+pos pos=0 If pos+size>str.Length() size=str.Length()-pos Return str[pos..pos+size] End Function Class Font Global img:Image Function Display:Void(_string$,_xpos%,_ypos%,_step%) For Local a:Int = 1 To _string.Length() Local frame:Int= Mid(_string,a,1)[0]-32 DrawImage(img,_xpos+a*_step,_ypos,frame) Next End Function Function LoadBmpFont:Void(_img:Image) img = _img End Function End Class