Hello, first apologize for my English "google translator", the library is great, thank you very much for her. But playing a bit I have a question.
By creating various groups with an elasticity type "ice block" I see that taper to stack, how can solve this behavior?. Thank you.
----------------------------------------------------------------------------------
Hola, primero disculparme por mi ingles "google traductor", la libreria es buenisima, muchas gracias por ella. Pero jugando un poco tengo una duda.
Al crear varios grupos con una elasticidad tipo "bloque de hielo" veo que se estrechan al apilarlos, ¿como se puede solventar este comportamiento?. Gracias.
The code I use:
Sub Globals
Dim ph As ABPhysicsEngine
Dim group(10) As ABGroup
Dim part(10) As ABParticle
Dim GendBot As ABGroup
Dim PendBot As ABParticle
Dim bucle,bucle2 As Int
Dim f As ABForce
Dim t As Timer
Dim c As Int
Dim ca As Canvas
End Sub
Sub Activity_Create(FirstTime As Boolean)
ca.Initialize(Activity)
ph.Initialize (1)
f.Initialize(False,0,.3,0,"grav")
ph.AddGlobalForce(f)
ph.Damping = 1
'Stop down to screen out
GendBot.Initialize("GendBot",True)
GendBot.AddParticle(creaParticle(part(0).RECTANGLE,50%x,100%y,100%x,40,0,True,True,0,0,0,111,True,"GendBot"))
ph.AddGroup(GendBot)
c = 0
t.Initialize ("t",100)
t.Enabled = True
End Sub
Sub t_tick
ph.Step()
Dim lGrupos As List
Dim lParticulas As List
Dim rD As Rect
Dim p As ABParticle
Dim g As ABGroup
ca.DrawColor(Colors.Black)
lGrupos=ph.GetGroups
For bucle = 0 To lGrupos.Size -1
g=lGrupos.Get(bucle)
lParticulas= g.GetParticles
For bucle2 = 0 To lParticulas.Size -1
p=lParticulas.Get(bucle2)
If p.name = "C" Then
rD.Initialize((p.CenterX - (p.Width/2)), (p.CenterY - (p.Height/2)), (p.CenterX + (p.Width/2)), (p.CenterY+ (p.Height/2)))
ca.DrawRectRotated(rd,Colors.Blue,True,2,0)
ca.DrawRectRotated(rd,Colors.Yellow,False,2,0)
Else
rD.Initialize((p.CenterX - (p.Width/2)), (p.CenterY - (p.Height/2)), (p.CenterX + (p.Width/2)), (p.CenterY+ (p.Height/2)))
ca.DrawRectRotated(rd,Colors.Red,True,2,0)
End If
Next
Next
Activity.Invalidate
End Sub
Sub Activity_Click
'Add a box each time you tap the screen, the elasticity is TYPE "ICE CUBE"
Dim bb As Int
If c < 10 Then
group(c).AddParticle(creaParticle(part(c).RECTANGLE,50%x,32,32,32,0,True,True,0,0,0,1,False,"C" ))
group(c).AddCollidable(GendBot)
For bb = 0 To c-1
group(c).AddCollidable(group(bb))
Next
ph.AddGroup(Group(c))
c= c+1
End If
End Sub
Sub addGroups(a() As ABGroup)
Dim l As List
l.Initialize2(a)
ph.AddListOfGroups(l)
End Sub
Sub creaParticle(TypeP As Int,centerX As Double, centerY As Double, Width As Double, Height As Double, Radius As Double, Collidable As Boolean,seeCollisionAsHit As Boolean, rotation As Double, elasticity As Double, friction As Double, mass As Double, isFixed As Boolean, Name As String) As ABParticle
Dim p As ABParticle
p.Initialize(TypeP,centerX,centerY,width,height,radius,collidable, seeCollisionAsHit, rotation,name)
p.Elasticity = elasticity
p.Friction = friction
p.isFixed = isfixed
p.Mass = mass
Return p
End Sub