Man running after a horse then rides the horse, Microworlds Pro 
Author Message
 Man running after a horse then rides the horse, Microworlds Pro

     I have made a few revisions in Dale's "man running after a horse
then rides the horse" procedures, since Will said that it still
wasn't
working for him.
     First, here are my comments about where Dale's procedures (below
mine) might run into trouble:
1) The runner and the horse must be at exactly the same y position in
order for the rider to eventually touch the horse.  It is preferable
if the rider can catch up to the horse from any initial positions on
the screen.
2) If the runner is trying unsuccessfully to catch up to the horse,
eventually you will get a message that MicroWorlds is out of
recursion
space.  This is happening because of how Dale's "go" procedure is
written.  It is a recursive loop, but there is an extra command after
the recursive "go."  Every time that the procedure loops back and
launches "go" again, that unused command gets stored for future use
and takes up memory until eventually the program is out of space.  It
is better to rewrite the procedure using
launch [forever [horse]]
to keep the horse galloping, and the memory problem is avoided.
3) Dale's version uses 6 versions of "runner."  I did not have any
"runner" shapes in MicroWorlds 2.03, but I did have three versions of
"walker" and my version takes advantage of them.  I haven't checked
but think that MicroWorlds Pro might be lacking the horse and walker
shapes, and so it would be necessary to create these shapes in order
for the program to run in that version.  Obviously the same applies
for Will's early version of MicroWorlds.
4) The two turtles were changing shapes so rapidly that they formed a
blur on my screen, so I slowed them down with "wait 1" after each
shape change.  Therefore, I also needed to increase the distance
traveled between each shape change.  I felt it was best to do this
with a speed slider so that the user can vary the speed of the chase.

I did set my t1 (the horse) to run to the right with the command
t1, seth 90
and this only needs to be done initially.   The horse can also be set
to run diagonally with
t1, seth 80
or
t1, seth 100
or something similar.
The heading of t2 (runner) does not need to be set in my version.
If the man ends up ahead of the horse (after the horse wraps around
the screen), then he ends up running backwards towards the horse
until
he jumps on.  So the program works better if the man starts very near
the left edge of the screen (at any height) and the horse is somewhat
to the right of the man but is still left of center to begin with.
It
also looks better if the speed slider is set to a small number to
begin with.  After the man jumps on the horse, the speed can be
gradually increased by clicking near the right edge of the speed
slider so as not to interrupt the animation.  (If you click and drag
the little gizmo on the slider, the animation is temporarily
interrupted.)

Having said all this, the following version works with a slider named
"speed" (minimum value 1, maximum value 50) with a "go" button or by
typing "go" in the command center:

to go
launch [forever [horse]]
chase
end

to horse
t1,
setshape "horse1 fd speed wait 1
setshape "horse2 fd speed wait 1
setshape "horse3 fd speed wait 1
end

to chase
t2, towards "t1
runner
ifelse not touching? "t1 "t2 [chase][ride]
end

to runner
t2,
setshape "walker1 fd speed + 2 wait 1
setshape "walker2 fd speed + 2 wait 1
setshape "walker3 fd speed + 2 wait 1
end

to ride
t2, setsh "walker2
towards "t1 fd distance "t1
seth 0 fd 20 wait 1
ride
end

(Oops, I just realized that my "chase" procedure could also develop
memory problems if it needed to run indefinitely, but it does always
seem to catch the horse and proceed to "ride" before that happens, on
my computer.)

By the way, I did not keep Will's address, so could you please
forward
this to him, Dale, if he is not a regular member of Logo-L?

-Wendy Petti


Quote:
> Well sorta.   What do you think Will?     Dale

> to go
> ifelse not touching? "t1 "t2 [horse runner][stop]
> go
> t2, lt 90 fd 20 rt 90 fd 80
> go2
> end

> to horse
> t1,
> setshape "horse1 fd 1
> setshape "horse2 fd 1
> setshape "horse3 fd 1
> setshape "horse4 fd 1
> end

> to runner
> t2,
> setshape "runner1 fd 2
> setshape "runner2 fd 1
> setshape "runner3 fd 1
> setshape "runner4 fd 1
> setshape "runner5 fd 1
> setshape "runner6 fd 1
> end

> to rider
> t2,
> setshape
> "runner3 fd 4
> end

> to go2
> horse rider
> go2
> end
> ---
> $ dal



Sat, 22 Feb 2003 21:19:23 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Man running after a horse then rides the horse, Microworlds Pro

2. Man running after a horse then rides the horse, Microworlds Pro

3. Dead horse matrix reduction

4. Beating the dead horse again about VB

5. Unir: 1995 Horse Racing

6. again with the old horse ...

7. the old horse ... and redirecting it

8. VO: Beating a dead horse?

9. LOGO-L> horse race

10. LOGO-L> Horsing around in 3D

11. only fools and horses

12. Shared Memory vs. Message Passing (Dead Horse Flogging)

 

 
Powered by phpBB® Forum Software