Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Animals/R6_Penguin.txt
1319 views
1
//-----------------Sonic CD Penguin Script--------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.YVelocity
7
#alias Object.Value1 : Object.Hops
8
9
// HUD alias
10
#alias Object[24].PropertyValue : HUD.CurrentTimePeriod
11
12
// States
13
#alias 0 : PENGUIN_HOPRIGHT
14
#alias 1 : PENGUIN_HOPLEFT
15
16
// Collision Side Aliases
17
#alias 0 : CSIDE_FLOOR
18
19
// Time Period Aliases
20
#alias 2 : TIME_GOOD_FUTURE
21
22
23
sub ObjectMain
24
Object.YPos += Object.YVelocity
25
26
// Apply a gravity of about 0.17 pixels per frame
27
Object.YVelocity += 0x2C00
28
29
switch Object.State
30
case PENGUIN_HOPRIGHT
31
32
// Move the Penguin a pixel right
33
Object.XPos += 0x10000
34
35
// Collision is only to be checked when falling faster than 4px a frame
36
if Object.YVelocity > 0x40000
37
ObjectTileCollision(CSIDE_FLOOR, 0, 8, 0)
38
39
if CheckResult == true
40
41
// Bounce back up, at a starting rate of 5px per frame
42
Object.YVelocity = -0x50000
43
44
Object.Hops++
45
if Object.Hops == 2
46
// Turn around
47
48
Object.Hops = 0
49
50
Object.State = PENGUIN_HOPLEFT
51
Object.Direction = FACING_LEFT
52
end if
53
end if
54
end if
55
break
56
57
case PENGUIN_HOPLEFT
58
59
// Move the Penguin a pixel to the left
60
Object.XPos -= 0x10000
61
62
// Only check for colliison when falling, at a rate faster than 4px downwards
63
if Object.YVelocity > 0x40000
64
ObjectTileCollision(CSIDE_FLOOR, 0, 8, 0)
65
66
if CheckResult == true
67
// Bounce right back up, 5px per frame is the starting rate
68
Object.YVelocity = -0x50000
69
70
Object.Hops++
71
if Object.Hops == 2
72
// Turn around
73
74
Object.Hops = 0
75
76
Object.State = PENGUIN_HOPRIGHT
77
Object.Direction = FACING_RIGHT
78
end if
79
end if
80
end if
81
break
82
83
end switch
84
85
end sub
86
87
88
sub ObjectDraw
89
if MetalSonic_Destroyed == true
90
if Object.YVelocity < 0
91
DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)
92
else
93
DrawSpriteFX(1, FX_FLIP, Object.XPos, Object.YPos)
94
end if
95
else
96
97
if HUD.CurrentTimePeriod == TIME_GOOD_FUTURE
98
if Object.YVelocity < 0
99
DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)
100
else
101
DrawSpriteFX(1, FX_FLIP, Object.XPos, Object.YPos)
102
end if
103
end if
104
105
end if
106
107
end sub
108
109
110
sub ObjectStartup
111
LoadSpriteSheet("R6/Objects.gif")
112
113
SpriteFrame(-8, -12, 16, 24, 222, 66)
114
SpriteFrame(-8, -12, 16, 24, 239, 66)
115
116
// Used to be below LoadSpriteSheet, moved here for consistency
117
ArrayPos0 = 32
118
while ArrayPos0 < 1056
119
if Object[ArrayPos0].Type == TypeName[Penguin]
120
121
// Start bouncing up, at a rate of 5px per frame
122
Object[ArrayPos0].YVelocity = -0x50000
123
124
// Start facing right, to correspond with the starting state of PENGUIN_HOPRIGHT
125
Object[ArrayPos0].Direction = FACING_RIGHT
126
127
end if
128
129
ArrayPos0++
130
loop
131
132
end sub
133
134
135
// ========================
136
// Editor Subs
137
// ========================
138
139
sub RSDKDraw
140
DrawSprite(0)
141
end sub
142
143
144
sub RSDKLoad
145
LoadSpriteSheet("R6/Objects.gif")
146
SpriteFrame(-8, -12, 16, 24, 222, 66)
147
148
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
149
end sub
150
151