Alice 3.3: различия между версиями
Содержимое удалено Содержимое добавлено
Строка 2: | Строка 2: | ||
==Движение в одном направлении== |
==Движение в одном направлении== |
||
<source lang="c++"> |
<source lang="c++"> |
||
constant DecimalNumber Force |
constant DecimalNumber Force = 0.25 |
||
constant DecimalNumber Duration |
constant DecimalNumber Duration = 0.25 |
||
Boolean MoveForward |
Boolean MoveForward = true |
||
Boolean MoveRight |
Boolean MoveRight = true |
||
while true is true |
while (true) is true |
||
{ |
{ |
||
each Sphere sphere in new Sphere[] {this.sphere, this.sphere2, this.sphere3} together |
each (Sphere sphere) in new Sphere[] {this.sphere, this.sphere2, this.sphere3} together |
||
do together |
do together |
||
{ |
{ |
||
if (MoveForward) is true then |
if (MoveForward) is true then |
||
sphere move FORWARD, Force, duration Duration, animationStyle BEGIN_AND_END_ARBUTLY |
sphere move = FORWARD, Force, duration = Duration, animationStyle = BEGIN_AND_END_ARBUTLY |
||
else |
else |
||
sphere move BACKWARD, Force, duration Duration, animationStyle BEGIN_AND_END_ARBUTLY |
sphere move = BACKWARD, Force, duration = Duration, animationStyle = BEGIN_AND_END_ARBUTLY |
||
if (MoveRight) is true |
if (MoveRight) is true |
||
sphere move RIGHT, Force, duration Duration, animationStyle BEGIN_AND_END_ARBUTLY |
sphere move = RIGHT, Force, duration = Duration, animationStyle = BEGIN_AND_END_ARBUTLY |
||
else |
else |
||
sphere move LEFT, Force, duration Duration, animationStyle BEGIN_AND_END_ARBUTLY |
sphere move = LEFT, Force, duration = Duration, animationStyle = BEGIN_AND_END_ARBUTLY |
||
} |
} |
||
MoveForward |
MoveForward = nextRandomBoolean() |
||
MoveRight |
MoveRight = nextRandomBoolean() |
||
} |
} |
||
</source> |
</source> |
Версия от 12:05, 10 декабря 2017
Одновременное движение объектов
Движение в одном направлении
constant DecimalNumber Force = 0.25
constant DecimalNumber Duration = 0.25
Boolean MoveForward = true
Boolean MoveRight = true
while (true) is true
{
each (Sphere sphere) in new Sphere[] {this.sphere, this.sphere2, this.sphere3} together
do together
{
if (MoveForward) is true then
sphere move = FORWARD, Force, duration = Duration, animationStyle = BEGIN_AND_END_ARBUTLY
else
sphere move = BACKWARD, Force, duration = Duration, animationStyle = BEGIN_AND_END_ARBUTLY
if (MoveRight) is true
sphere move = RIGHT, Force, duration = Duration, animationStyle = BEGIN_AND_END_ARBUTLY
else
sphere move = LEFT, Force, duration = Duration, animationStyle = BEGIN_AND_END_ARBUTLY
}
MoveForward = nextRandomBoolean()
MoveRight = nextRandomBoolean()
}
Броуновское движение
constant DecimalNumber Force <- 0.25
constant DecimalNumber Duration <- 0.25
while true is true
{
each Sphere sphere in new Sphere[] {this.sphere, this.sphere2, this.sphere3} together
do together
{
sphere move FORWARD, Force - nextRandomRealNumberRange(0.0, 2.0 * Force), duration Duration, animationStyle BEGIN_AND_END_ARBUTLY
sphere move RIGHT, Force - nextRandomRealNumberRange(0.0, 2.0 * Force), duration Duration, animationStyle BEGIN_AND_END_ARBUTLY
}
}