summaryrefslogtreecommitdiff
path: root/imagefont/test.bmx
blob: 4c064c94f07ab3bdff14ace135325ff8b705c40f (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
' $Id$

Import noddybox.bitmapfont

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

Const SCRW=640
Const SCRH=480

Graphics SCRW,SCRH,32,60

fnt:BitmapFont=BitmapFont.Load("incbin::bmaxtest.bmf")

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

While False ' 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
	
	DrawText(MemAlloced(),0,100)

	If KeyHit(KEY_SPACE) Then FlushMem

	Flip
	
Wend

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

While Not KeyHit(KEY_ESCAPE)
	Cls

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

	DrawText("x="+x+"  width="+(-fnt.TextWidth(t[0..1]))+"  mem="+MemAlloced(),0,100)
	DrawText("t="+t,0,110)
	
	SetTransform(0,sc,sc)

	fnt.Draw(t$,x,200)
	
	If Not KeyDown(KEY_P)
		x:-sc
		
		If x<-fnt.TextWidth(t[0..1])
			x:+fnt.TextWidth(t[0..1])
			t=t[1..]+t[0..1]
		EndIf
	EndIf
		
	FlushMem

	Flip
	
Wend