Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 1/Scripts/SYZ/MovingBlock.txt
1483 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Moving Block Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
// Push Button aliases
13
private alias object.propertyValue : pushButton.stood
14
15
private alias object.value0 : object.movePos
16
17
private alias 0 : MOVINGBLOCK_WAITFORBUTTON
18
private alias 1 : MOVINGBLOCK_MOVING
19
private alias 2 : MOVINGBLOCK_FINISHED
20
21
// Player Aliases
22
private alias object.xpos : player.xpos
23
private alias object.ypos : player.ypos
24
25
26
// ========================
27
// Function Declarations
28
// ========================
29
30
reserve function MovingBlock_DebugDraw
31
reserve function MovingBlock_DebugSpawn
32
33
34
// ========================
35
// Tables
36
// ========================
37
38
private function MovingBlock_DebugDraw
39
DrawSprite(0)
40
end function
41
42
43
private function MovingBlock_DebugSpawn
44
CreateTempObject(TypeName[Moving Block], 0, object.xpos, object.ypos)
45
end function
46
47
48
// ========================
49
// Events
50
// ========================
51
52
event ObjectUpdate
53
switch object.state
54
case MOVINGBLOCK_WAITFORBUTTON
55
if pushButton[-1].stood == true
56
object.state = MOVINGBLOCK_MOVING
57
object.priority = PRIORITY_ACTIVE
58
end if
59
break
60
61
case MOVINGBLOCK_MOVING
62
if object.movePos < 0x38A0000
63
object.movePos += 0x10000
64
object.xpos += 0x10000
65
object.xvel = 0x10000
66
else
67
object.xvel = 0
68
object.priority = PRIORITY_BOUNDS
69
object.state++
70
end if
71
break
72
73
case MOVINGBLOCK_FINISHED
74
break
75
76
end switch
77
78
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
79
BoxCollisionTest(C_SOLID, object.entityPos, -32, -26, 32, 26, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
80
if checkResult == COL_TOP
81
player[currentPlayer].xpos += object.xvel
82
end if
83
next
84
end event
85
86
87
event ObjectDraw
88
DrawSprite(0)
89
end event
90
91
92
event ObjectStartup
93
LoadSpriteSheet("SYZ/Objects.gif")
94
SpriteFrame(-32, -26, 64, 52, 119, 99)
95
96
SetTableValue(TypeName[Moving Block], DebugMode_ObjCount, DebugMode_TypesTable)
97
SetTableValue(MovingBlock_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
98
SetTableValue(MovingBlock_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
99
DebugMode_ObjCount++
100
end event
101
102
103
// ========================
104
// Editor Events
105
// ========================
106
107
event RSDKDraw
108
DrawSprite(0)
109
110
if editor.showGizmos == true
111
editor.drawingOverlay = true
112
113
// Draw an arrow from this object's activator button
114
DrawArrow(object[-1].xpos, object[-1].ypos, object.xpos, object.ypos, 255, 255, 255)
115
116
editor.drawingOverlay = false
117
end if
118
end event
119
120
121
event RSDKLoad
122
LoadSpriteSheet("SYZ/Objects.gif")
123
SpriteFrame(-32, -26, 64, 52, 119, 99)
124
125
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
126
end event
127
128