forked from adamredwoods/minib3d-monkey
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.monkey
118 lines (88 loc) · 1.51 KB
/
app.monkey
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
Import minib3d
Class Minib3dApp Extends App
Global Resumed:Bool = False
Field init:Int=0
' used by fps code
Field old_ms:Int
Field renders:Int
Field fps:Int
Field timer:Int =0
Field preload_list:StringList = New StringList
Method PreLoad(f$)
preload_list.AddLast(f)
End
Method PreLoad(f$[])
For Local s$ = Eachin f
preload_list.AddLast(s)
Next
End
Method OnCreate()
SetRender()
SetUpdateRate 30
PreLoad("mojo_font.png")
Create()
Minib3dInit()
End
Method Create()
End
Method Minib3dInit:Void()
If init Then Return
If Not TPixmap.PreLoadPixmap(preload_list.ToArray()) Then Return
init=1
Init()
init=2
End
Method Init()
End
Method OnUpdate()
If Not init
Minib3dInit()
Return
Endif
If Resumed
Graphics3DInit ()
ReloadAllSurfaces ()
ReloadAllTextures ()
Resumed = False
Endif
Update()
' calculate fps
If Millisecs()-old_ms >= 1000
old_ms=Millisecs()
fps=renders
renders=0
'Print "fps "+fps
Endif
End
Method Update()
End
Method OnRender()
Render()
RenderWorld
renders=renders+1
End
Method Render()
End
Method OnSupsend()
Suspend()
End
Method Suspend()
End
Method OnResume()
Resumed = True
Resume()
End
Method Resume()
End
End
'' TO USE
'' extend the Minib3dApp
'' and overload Methods
''
'' Method Create ()
'' SetUpdateRate 30
'' AddPreLoad(files) here
'' End
'' Method Init ()
'' Add camera, light, and model loading, creation, texture modifying here
'' End