summaryrefslogtreecommitdiff
path: root/imagefont/test.bmx
blob: b17278a8c2b9e1834cd8a4202893ae437fb63d28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
' $Id$

Import noddybox.bitmapfont

'Import "BitmapFont.bmx"
Incbin "bmaxtest.bmf"

Const SCRW=640
Const SCRH=480

SetGraphicsDriver GLMax2DDriver()
Graphics SCRW,SCRH,32,60' Or HARDSYNC
fnt:TBitmapFont=TBitmapFont.Load("incbin::bmaxtest.bmf",0)

If fnt=Null
	RuntimeError "Failed to open font"
EndIf

c=255
ci=-5

Type Star
	Field x
	Field y,sp
	
	Function Create:Star()
		Local s:Star=New Star
		s.x=Rand(0,SCRW)
		s.y=Rand(0,SCRH)
		s.sp=Rand(1,3)
		Return s
	End Function
	
	Method Update()
		Plot(x,y)
		y:+sp
		y:Mod SCRH
	End Method
End Type

Const NO=10000

Local st:Star[]=New Star[NO]

For f=0 Until NO
	st[f]=Star.Create()
Next

SetBlend(ALPHABLEND)

While Not KeyHit(KEY_ESCAPE)
	Cls

	For f=0 Until NO
		st[f].Update()
	Next
	
	SetTransform(0,2,2)
	fnt.DrawColoured("DRAWCOLOURED",0,10,c/2,c/2,c)
	fnt.Draw("DRAW",c-120,30)
	fnt.CentreColoured("CENTRECOLOURED",50,c/2,c/2,c)
	fnt.Centre("CENTRE",70)

	If Not KeyDown(KEY_P)
		c:+ci
		
		If (c=100 Or c=255) ci=-ci
	EndIf
	
	fnt.DrawColoured(MemAlloced(),0,300,255,0,0)

	If KeyHit(KEY_SPACE) Then FlushMem

	Flip
	
Wend

sc=10
t$="THIS IS SOME VERY, VERY, *VERY* ~~LARGE SCROLLING TEXT....."
x#=0
ang#=0
angi#=0.2

While Not KeyHit(KEY_ESCAPE)
	Cls

	For f=0 Until NO
		st[f].Update()
	Next
	
	SetTransform(0,1,1)

	Rem
	DrawText("x="+x+"  width="+(-fnt.TextWidth(t[0..1]))+"  mem="+MemAlloced(),0,100)
	DrawText("t="+t,0,110)
	EndRem
	
	SetTransform(ang,sc,sc)
	
	ang:+angi
	
	If ang<=-10 Or ang>=10 Then angi=-angi

	fnt.DrawColoured(t$,x,0,255,255,255)'128,128)
	
	If Not KeyDown(KEY_P)
		x:-5
		
		If x<-fnt.TextWidth(t[0..1])
			x:+fnt.TextWidth(t[0..1])
			t=t[1..]+t[0..1]
		EndIf
	EndIf
		
	FlushMem

	Flip
	
Wend

EndGraphics