reset password
Author Message
Amedrano
Posts: 80
Posted 12:56 Oct 23, 2015 |

when we call:

> (animate create-scene)

animate calls the function (create-scene)

(define (create-scene y-pos)
  (let* ([scene (empty-scene WIDTH HEIGHT)] 
         [x-pos (/ WIDTH 2)]
         [y-pos (min y-pos LOWEST-Y-POS)]
         )
    (place-image FALLING-OBJECT x-pos y-pos scene)))
(define FALLING-OBJECT (circle 25 'solid 'blue))

and "(create-scene)" requires the argument "y-pos"

My question is when/where does it get that argument when we call "(animate create-scene)"?

layla08
Posts: 70
Posted 14:14 Oct 23, 2015 |

The the interactions panel, when you type in:

> (my-animate (list HIGHEST-Y-POS LOWEST-Y-POS) create-scene up-and-down at-bottom?)

Whatever you decide to put in the section in bold corresponds with what you named y-pos. Is that what you are asking?

Last edited by layla08 at 14:15 Oct 23, 2015.
Amedrano
Posts: 80
Posted 14:44 Oct 23, 2015 |
layla08 wrote:

The the interactions panel, when you type in:

> (my-animate (list HIGHEST-Y-POS LOWEST-Y-POS) create-scene up-and-down at-bottom?)

Whatever you decide to put in the section in bold corresponds with what you named y-pos. Is that what you are asking?

Yes thank you but it seems I'm still confused... If you look at the example Dr. Abbott provides he says

;; To run the system call 
;;    > (animate create-scene)    
;; This call passes the function create-scene to animate, which is a built-in function.
;; animate "ticks" 28 times a second and calls (create-scene y-pos) each time
;; We take y-pos to represent the y position — counting down from the top.
;; Run at prompt: > (animate create-scene)         

I'm not sure of another way to ask my question but to say... Is the reason the "create-scene" function receives an argument due to providing "big-bang" an initial state? and if so where was it provided in the example above...because we call "(animate create-scene)" not ' (my-animate (list HIGHEST-Y-POS LOWEST-Y-POS) create-scene up-and-down at-bottom?)"

Thanks again.

Last edited by Amedrano at 14:46 Oct 23, 2015.
rabbott
Posts: 1649
Posted 19:30 Oct 23, 2015 |

When you call 

> (animate create-scene)

animate calls big-bang and passes it create-scene as the function to call when it wants an image to show. 

When big-bang calls a function it passes the function the world state. In the case of animate the world state is a single number, which we are interpreting as the y-pos

The broader answer is that the first argument to big-bang is the initial world state. In my-animate on the wiki page, the first argument to big-bang is HIGHEST-Y-POS, which is where we want the ball to start. That single number is the world state for this example. 

The key to all of this is the world state. big-bang passes it to each of the functions it calls.

Last edited by rabbott at 19:30 Oct 23, 2015.
Amedrano
Posts: 80
Posted 20:05 Oct 23, 2015 |
rabbott wrote:

When you call 

> (animate create-scene)

animate calls big-bang and passes it create-scene as the function to call when it wants an image to show. 

When big-bang calls a function it passes the function the world state. In the case of animate the world state is a single number, which we are interpreting as the y-pos

 

So in this example, which was in the first part of the lecture notes not "my-animate", what Precisely is the "world state"?