Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 2/Scripts/LevelSelect/BGAnimation.txt
1478 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: BG Animation Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
private alias object.propertyValue : object.hide // set from editor
13
private alias object.value0 : object.timer
14
15
// Priority
16
public alias 0 : PRIORITY_BOUNDS
17
public alias 1 : PRIORITY_ACTIVE
18
public alias 2 : PRIORITY_ALWAYS
19
public alias 3 : PRIORITY_XBOUNDS
20
public alias 4 : PRIORITY_XBOUNDS_DESTROY
21
public alias 5 : PRIORITY_INACTIVE
22
public alias 6 : PRIORITY_BOUNDS_SMALL
23
public alias 7 : PRIORITY_ACTIVE_SMALL
24
25
// Ink Effects
26
public alias 0 : INK_NONE
27
public alias 1 : INK_BLEND
28
public alias 2 : INK_ALPHA
29
public alias 3 : INK_ADD
30
public alias 4 : INK_SUB
31
32
// Flip Directions
33
public alias 0 : FLIP_NONE
34
public alias 1 : FLIP_X
35
public alias 2 : FLIP_Y
36
public alias 3 : FLIP_XY
37
38
39
// ========================
40
// Static Values
41
// ========================
42
43
public value BGAnimation_currentPreview = 0
44
45
46
// ========================
47
// Events
48
// ========================
49
50
event ObjectUpdate
51
object.timer++
52
object.timer &= 0x1FF
53
54
Sin(temp0, object.timer)
55
if temp0 > 0
56
if temp0 < 32
57
screen.yoffset = 256
58
else
59
screen.yoffset = 0
60
end if
61
else
62
if temp0 > -32
63
screen.yoffset = 512
64
else
65
screen.yoffset = 768
66
end if
67
end if
68
end event
69
70
71
event ObjectDraw
72
if object.hide == false
73
// This script doesn't only do BG animation, it also deals with drawing the zone preview at the bottom right of the screen
74
// BGAnimation_currentPreview is set by the Menu Control object
75
temp0 = screen.xcenter
76
temp0 -= 180
77
if temp0 > 0
78
temp0 = 0
79
end if
80
temp0 += screen.xcenter
81
DrawSpriteScreenXY(14, temp0, 198)
82
DrawSpriteScreenXY(BGAnimation_currentPreview, temp0, 198)
83
end if
84
end event
85
86
87
event ObjectStartup
88
LoadSpriteSheet("LevelSelect/Icons.gif")
89
90
// Set all BG Animation objects to active
91
// (There should only ever be one in a scene, though)
92
foreach (TypeName[BG Animation], arrayPos0, ALL_ENTITIES)
93
object[arrayPos0].priority = PRIORITY_ACTIVE
94
next
95
96
SpriteFrame(56, -12, 32, 24, 0, 50) // Sonic vibin' - #0
97
98
// Zone previews
99
SpriteFrame(56, -12, 32, 24, 1, 85) // EHZ - #1
100
SpriteFrame(56, -12, 32, 24, 34, 85) // CPZ - #2
101
SpriteFrame(56, -12, 32, 24, 67, 85) // ARZ - #3
102
SpriteFrame(56, -12, 32, 24, 100, 85) // CNZ - #4
103
SpriteFrame(56, -12, 32, 24, 133, 85) // HTZ - #5
104
SpriteFrame(56, -12, 32, 24, 166, 85) // MCZ - #6
105
SpriteFrame(56, -12, 32, 24, 199, 85) // HPZ - #7
106
SpriteFrame(56, -12, 32, 24, 180, 1) // OOZ - #8
107
SpriteFrame(56, -12, 32, 24, 213, 1) // MTZ - #9
108
SpriteFrame(56, -12, 32, 24, 180, 26) // SCZ - #10
109
SpriteFrame(56, -12, 32, 24, 213, 26) // WFZ - #11
110
SpriteFrame(56, -12, 32, 24, 180, 51) // DEZ - #12
111
SpriteFrame(56, -12, 32, 24, 213, 51) // Special Stage - #13
112
113
SpriteFrame(32, -24, 80, 50, 0, 0) // Selection frame - #14
114
115
// Default to the EHZ icon
116
BGAnimation_currentPreview = 1
117
end event
118
119
120
// ========================
121
// Editor Events
122
// ========================
123
124
event RSDKEdit
125
if editor.returnVariable == true
126
switch editor.variableID
127
case EDIT_VAR_PROPVAL // property value
128
checkResult = object.propertyValue
129
break
130
131
case 0 // hidden
132
checkResult = object.propertyValue
133
break
134
135
end switch
136
else
137
switch editor.variableID
138
case EDIT_VAR_PROPVAL // property value
139
object.propertyValue = editor.variableValue
140
break
141
142
case 0 // hidden
143
object.propertyValue = editor.variableValue
144
break
145
146
end switch
147
end if
148
end event
149
150
151
event RSDKDraw
152
DrawSprite(1)
153
DrawSprite(0)
154
end event
155
156
157
event RSDKLoad
158
LoadSpriteSheet("LevelSelect/Icons.gif")
159
SpriteFrame(56, -12, 32, 24, 0, 50)
160
SpriteFrame(32, -24, 80, 50, 0, 0)
161
162
AddEditorVariable("hidden")
163
SetActiveVariable("hidden")
164
AddEnumVariable("false", false)
165
AddEnumVariable("true", true)
166
end event
167
168