Post by comicnight on Feb 15, 2016 18:15:40 GMT -5
I'm currently adding in a dash hoop, but I'm having one issue. Since a dash hoop and a spring technically work the same, I just copied and pasted the spring object code in stage.bb and renamed it 'hoop'. But I keep getting the error, 'too many parameters'.
Here's the code I created:
Case "hoop"
; Update progress bar
Game_Stage_UpdateProgressBar("Loading object n."+j+": Hoop", Float#(j)/Float#(xmlNodeChildCount(RootChildNode)))
positionX# = 0
positionY# = 0
positionZ# = 0
rotationX# = 0
rotationY# = 0
rotationZ# = 0
; Setup position, rotation and scale.
ScenePosition = xmlNodeFind("position", SceneChildNode)
If (ScenePosition<>0) Then
positionX# = Float(xmlNodeAttributeValueGet(ScenePosition, "x"))
positionY# = Float(xmlNodeAttributeValueGet(ScenePosition, "y"))
positionZ# = Float(xmlNodeAttributeValueGet(ScenePosition, "z"))
End If
SceneRotation = xmlNodeFind("rotation", SceneChildNode)
If (SceneRotation<>0) Then
rotationX# = Float(xmlNodeAttributeValueGet(SceneRotation, "pitch"))
rotationY# = Float(xmlNodeAttributeValueGet(SceneRotation, "yaw"))
rotationZ# = Float(xmlNodeAttributeValueGet(SceneRotation, "roll"))
End If
obj.tObject = Object_Hoop_Create(positionX#, positionY#, positionZ#, rotationX#, rotationY#, rotationZ#)
I also have code for the hoop object in 'Objects.bb'.
; =========================================================================================================
; Object_Hoop_Create
; =========================================================================================================
; Creates a New Hoop Object
Function Object_Hoop_Create.tObject(x#, y#, z#)
o.tObject = New tObject
o\ObjType = OBJTYPE_HOOP
o\Position = New tVector
o\Position\x# = x#
o\Position\y# = y#
o\Position\z# = z#
o\Entity = LoadMesh("Objects\Hoops\hoop.b3d")
;EntityType o\Entity, 2
ScaleEntity o\Entity, 1.1, 1.1, 1.1
TranslateEntity o\Entity, x#, y#, z#
Return o
End Function
; =========================================================================================================
; Object_Hoop_Update
; =========================================================================================================
; Updates the Hoop object
Function Object_Hoop_Update(o.tObject, p.tPlayer, d.tDeltaTime)
If (Abs(EntityX(p\Objects\Entity) - o\Position\x) < 12.5) And (Abs(EntityY(p\Objects\Entity) - o\Position\y) < 12.5) And (Abs(EntityZ(p\Objects\Entity) - o\Position\z) < 12.5) Then
;If Not p\Motion\Ground Then PositionEntity p\Objects\Entity, (EntityX(p\Objects\Entity)*39 + o\Position\x#)/40, (EntityY(p\Objects\Entity)*39 + o\Position\y#)/40, (EntityZ(p\Objects\Entity)*39 + o\Position\z#)/40
If (Abs(EntityX(p\Objects\Entity) - o\Position\x) < 5.5) And (Abs(EntityY(p\Objects\Entity) - o\Position\y) < 5.5) And (Abs(EntityZ(p\Objects\Entity) - o\Position\z) < 5.5) And o\State = 0 Then
o\State = 1
o\FValues[0] = 0.0
; Transform the Speed vector to the Player space
TFormVector 0, 1, 0, o\Entity, p\Objects\Entity
p\Action = ACTION_COMMON
p\Motion\Ground = False
p\Motion\Speed\x = TFormedX()*3
p\Motion\Speed\y = TFormedY()*3
p\Motion\Speed\z = TFormedZ()*3
; Transform the position vector to World space
TFormVector 0, 1, 0, o\Entity, 0
PositionEntity p\Objects\Entity, o\Position\x# + TFormedX()*4, o\Position\y# + TFormedY()*4, o\Position\z# + TFormedZ()*4
; Sproing!
PlaySound Sound_Spring
; Apply motion blur
PostEffect_Create_MotionBlur(0.85)
EndIf
EndIf
Anybody have any idea what I've done wrong? What I need to do? Thanks.
Here's the code I created:
Case "hoop"
; Update progress bar
Game_Stage_UpdateProgressBar("Loading object n."+j+": Hoop", Float#(j)/Float#(xmlNodeChildCount(RootChildNode)))
positionX# = 0
positionY# = 0
positionZ# = 0
rotationX# = 0
rotationY# = 0
rotationZ# = 0
; Setup position, rotation and scale.
ScenePosition = xmlNodeFind("position", SceneChildNode)
If (ScenePosition<>0) Then
positionX# = Float(xmlNodeAttributeValueGet(ScenePosition, "x"))
positionY# = Float(xmlNodeAttributeValueGet(ScenePosition, "y"))
positionZ# = Float(xmlNodeAttributeValueGet(ScenePosition, "z"))
End If
SceneRotation = xmlNodeFind("rotation", SceneChildNode)
If (SceneRotation<>0) Then
rotationX# = Float(xmlNodeAttributeValueGet(SceneRotation, "pitch"))
rotationY# = Float(xmlNodeAttributeValueGet(SceneRotation, "yaw"))
rotationZ# = Float(xmlNodeAttributeValueGet(SceneRotation, "roll"))
End If
obj.tObject = Object_Hoop_Create(positionX#, positionY#, positionZ#, rotationX#, rotationY#, rotationZ#)
I also have code for the hoop object in 'Objects.bb'.
; =========================================================================================================
; Object_Hoop_Create
; =========================================================================================================
; Creates a New Hoop Object
Function Object_Hoop_Create.tObject(x#, y#, z#)
o.tObject = New tObject
o\ObjType = OBJTYPE_HOOP
o\Position = New tVector
o\Position\x# = x#
o\Position\y# = y#
o\Position\z# = z#
o\Entity = LoadMesh("Objects\Hoops\hoop.b3d")
;EntityType o\Entity, 2
ScaleEntity o\Entity, 1.1, 1.1, 1.1
TranslateEntity o\Entity, x#, y#, z#
Return o
End Function
; =========================================================================================================
; Object_Hoop_Update
; =========================================================================================================
; Updates the Hoop object
Function Object_Hoop_Update(o.tObject, p.tPlayer, d.tDeltaTime)
If (Abs(EntityX(p\Objects\Entity) - o\Position\x) < 12.5) And (Abs(EntityY(p\Objects\Entity) - o\Position\y) < 12.5) And (Abs(EntityZ(p\Objects\Entity) - o\Position\z) < 12.5) Then
;If Not p\Motion\Ground Then PositionEntity p\Objects\Entity, (EntityX(p\Objects\Entity)*39 + o\Position\x#)/40, (EntityY(p\Objects\Entity)*39 + o\Position\y#)/40, (EntityZ(p\Objects\Entity)*39 + o\Position\z#)/40
If (Abs(EntityX(p\Objects\Entity) - o\Position\x) < 5.5) And (Abs(EntityY(p\Objects\Entity) - o\Position\y) < 5.5) And (Abs(EntityZ(p\Objects\Entity) - o\Position\z) < 5.5) And o\State = 0 Then
o\State = 1
o\FValues[0] = 0.0
; Transform the Speed vector to the Player space
TFormVector 0, 1, 0, o\Entity, p\Objects\Entity
p\Action = ACTION_COMMON
p\Motion\Ground = False
p\Motion\Speed\x = TFormedX()*3
p\Motion\Speed\y = TFormedY()*3
p\Motion\Speed\z = TFormedZ()*3
; Transform the position vector to World space
TFormVector 0, 1, 0, o\Entity, 0
PositionEntity p\Objects\Entity, o\Position\x# + TFormedX()*4, o\Position\y# + TFormedY()*4, o\Position\z# + TFormedZ()*4
; Sproing!
PlaySound Sound_Spring
; Apply motion blur
PostEffect_Create_MotionBlur(0.85)
EndIf
EndIf
Anybody have any idea what I've done wrong? What I need to do? Thanks.