-
Notifications
You must be signed in to change notification settings - Fork 2
/
screen.monkey2
153 lines (120 loc) · 3.56 KB
/
screen.monkey2
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
Namespace diddy2.screen
Class Screen Abstract
Private
Field _name:String
Field _destinationScreen:Screen
Field _screenBank:ScreenBank
Field _allowUpdatesInFade:Bool = False
Public
Const EMPTY_SCREEN:String = "EmptyScreen"
Const EXIT_SCREEN:String = "ExitScreen"
Const GAME_SCREEN:String = "GameScreen"
Const TITLE_SCREEN:String = "TitleScreen"
Const LEVEL_END_SCREEN:String = "LevelEndScreen"
Const OPTIONS_SCREEN:String = "OptionsScreen"
Const GAME_OVER_SCREEN:String = "GameOverScreen"
Const LEVEL_SELECT_SCREEN:String = "LevelSelectScreen"
Const CREDITS_SCREEN:String = "CreditsScreen"
Const GAME_COMPLETE_SCREEN:String = "GameCompleteScreen"
Property ScreenBank:ScreenBank()
Return _screenBank
Setter(screenBank:ScreenBank)
_screenBank = screenBank
End
Property DiddyApp:DiddyApp()
Return DiddyApp.GetInstance()
End
Property Window:DiddyWindow()
Return DiddyApp.GetInstance().Window
End
Property VirtualResolution:Vec2i()
Return DiddyApp.GetInstance().Window.VirtualResolution
End
Property AssetBank:AssetBank()
Return DiddyApp.GetInstance().AssetBank
End
Property ChannelManager:ChannelManager()
Return DiddyApp.GetInstance().ChannelManager
End
Property Name:String()
Return _name
Setter(name:String)
_name = name
End
Property AllowUpdatesInFade:Bool()
Return _allowUpdatesInFade
Setter(b:Bool)
_allowUpdatesInFade = b
End
Method New(name:String = "")
Self._name = name
End
Method PreStart(fadeType:Int = ScreenFade.FADE_IN, fadeTimeMs:Float = ScreenFade.DefaultFadeTimeMs, fadeSound:Bool = True, fadeMusic:Bool = True, _stopMusicOnFadeIn:Bool = False)
DiddyApp.SetCurrentScreen(Self)
Load()
Window.ScreenFade.Start(fadeType, fadeTimeMs, fadeSound, fadeMusic, _stopMusicOnFadeIn)
DiddyApp.AppInstance.ResetPolledInput()
Start()
End
Method PostFadeIn() Virtual
End
Method Load() Virtual
End
Method Start() Abstract
Method PreRender(canvas:Canvas, tween:Float) Virtual
End
Method Render(canvas:Canvas, tween:Float) Abstract
Method PostRender(canvas:Canvas, tween:Float) Virtual
End
Method Update(fixedRate:Float) Abstract
Method PostFadeOut(fadeSound:Bool = True, fadeMusic:Bool = True, stopMusicOnFadeIn:Bool = False)
Kill()
Window.NextScreen.PreStart(,,fadeSound, fadeMusic, stopMusicOnFadeIn)
End
Method OnKeyEvent( event:KeyEvent ) Virtual
End
Method Kill() Virtual
End
Method SetDestinationScreen(screen:Screen)
_destinationScreen = screen
End
Method MoveToScreen(screen:Screen, fadeTimeMs:Float = ScreenFade.DefaultFadeTimeMs, fadeSound:Bool = True, fadeMusic:Bool = True, stopMusicOnFadeIn:Bool = False)
If Window.ScreenFade.Active Then Return
Window.NextScreen = screen
If fadeTimeMs <= 0
DiddyApp.GetCurrentScreen().PostFadeOut(fadeSound, fadeMusic, stopMusicOnFadeIn)
Else
Window.ScreenFade.Start(ScreenFade.FADE_OUT, fadeTimeMs, fadeSound, fadeMusic, stopMusicOnFadeIn)
End
End
End
Class EmptyScreen Extends Screen
Field cleared:Bool = False
Method New(name:String)
Super.New(name)
End
Method Start() Override
End
Method Update(fixedRate:Float) Override
MoveToScreen(_destinationScreen, 0)
End
Method Render(canvas:Canvas, tween:Float) Override
If Not cleared
canvas.Clear(Color.Black)
cleared = True
End
End
End
Class ExitScreen Extends Screen
Method New(name:String)
Super.New(name)
End
Method Start() Override
AllowUpdatesInFade = True
End
Method Render(canvas:Canvas, tween:Float) Override
End
Method Update(fixedRate:Float) Override
App.Terminate()
End
End