Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R1/DPlatform.txt
1319 views
1
//--------------Sonic CD Diagonal Platform Script-------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value1 : Object.XOriginPos
7
#alias Object.Value2 : Object.XPlayerFloor
8
#alias Object.Value3 : Object.YOriginPos
9
#alias Object.Value4 : Object.YPlayerFloor
10
#alias Object.Value5 : Object.Angle
11
#alias Object.Value6 : Object.Amplitude
12
13
// Property Values
14
// This property values only cover the starting position
15
#alias 0 : START_MOVING_LEFT_DOWN
16
#alias 1 : START_MOVING_RIGHT_DOWN
17
// On a map editor this would rather be (0)Left-Down, (1)Right-Down, (2)Left-Up and (3)Right-Up
18
// But here we only cover what's useful for the script itself
19
20
21
sub ObjectMain
22
Object.Angle = Oscillation
23
Object.Angle <<= 1
24
if Object.PropertyValue == START_MOVING_RIGHT_DOWN
25
Object.Angle += 256
26
end if
27
28
Cos(Object.XPlayerFloor, Object.Angle)
29
Object.XPlayerFloor *= 0x1800
30
Object.XPlayerFloor += Object.XPos
31
Object.XPlayerFloor &= 0xFFFF0000 // Truncate the value
32
Object.XPlayerFloor -= Object.XOriginPos
33
34
Cos(Object.YPlayerFloor, Object.Angle)
35
FlipSign(Object.YPlayerFloor)
36
Object.YPlayerFloor *= Object.Amplitude
37
Object.YPlayerFloor += Object.YPos
38
Object.YPlayerFloor &= 0xFFFF0000 // Truncate the value
39
Object.YPlayerFloor -= Object.YOriginPos
40
end sub
41
42
43
sub ObjectPlayerInteraction
44
TempValue0 = Object.XPos
45
Object.XPos = Object.XOriginPos
46
47
TempValue1 = Object.YPos
48
Object.YPos = Object.YOriginPos
49
50
PlayerObjectCollision(C_PLATFORM, -32, -9, 32, 12)
51
if CheckResult == true
52
Player.XPos += Object.XPlayerFloor
53
Player.YPos += Object.YPlayerFloor
54
end if
55
56
Object.XPos = TempValue0
57
Object.YPos = TempValue1
58
end sub
59
60
61
sub ObjectDraw
62
Cos(Object.XOriginPos, Object.Angle)
63
Object.XOriginPos *= 0x1800
64
Object.XOriginPos += Object.XPos
65
Object.XOriginPos &= 0xFFFF0000
66
67
Cos(Object.YOriginPos, Object.Angle)
68
FlipSign(Object.YOriginPos)
69
Object.YOriginPos *= Object.Amplitude
70
Object.YOriginPos += Object.YPos
71
Object.YOriginPos &= 0xFFFF0000
72
73
DrawSpriteXY(0, Object.XOriginPos, Object.YOriginPos)
74
end sub
75
76
77
sub ObjectStartup
78
LoadSpriteSheet("R1/Objects.gif")
79
80
SpriteFrame(-32, -16, 64, 32, 101, 109) // #0 - Platform
81
82
ArrayPos0 = 32
83
while ArrayPos0 < 1056
84
if Object[ArrayPos0].Type == TypeName[Diag Platform]
85
if Object[ArrayPos0].PropertyValue > 1
86
Object[ArrayPos0].Amplitude = -0x1800
87
Object[ArrayPos0].PropertyValue -= 2
88
else
89
Object[ArrayPos0].Amplitude = 0x1800
90
end if
91
end if
92
ArrayPos0++
93
loop
94
end sub
95
96
97
// ========================
98
// Editor Subs
99
// ========================
100
101
sub RSDKDraw
102
DrawSprite(0)
103
end sub
104
105
106
sub RSDKLoad
107
LoadSpriteSheet("R1/Objects.gif")
108
109
SpriteFrame(-32, -16, 64, 32, 101, 109) // #0 - Platform
110
111
AddEditorVariable("startDir")
112
SetActiveVariable("startDir")
113
AddEnumVariable("Left, Down", 0)
114
AddEnumVariable("Right, Down", 1)
115
AddEnumVariable("Left, Up", 2)
116
AddEnumVariable("Right, Up", 3)
117
end sub
118
119