<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>On Apr 17, 2014, at 11:31 PM, Zee Ken <<a href="mailto:udaybhasker552009@gmail.com">udaybhasker552009@gmail.com</a>> wrote:</div><div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div><div>Where do I use the <span style="font-family:courier new,monospace">place-image</span> option to place the <span style="font-family:courier new,monospace">myself, shark, food1, food2</span> images at required positions? Do I give that in the <span style="font-family:courier new,monospace">initial-world</span>?<br></div></div></div></blockquote><div><div>You use the <font face="Courier New">on-redraw</font> option to big-bang to tell big-bang what image to display in the window, and you supply some kind of <font face="Courier New">render-world</font> function like this:</div><div><div><font face="Courier New">(define (render-world w) ; w should be an instance of the world structure</font></div><div><font face="Courier New"> ...</font><span style="font-family: 'Courier New';">)</span></div></div><div><br></div><div><font face="Courier New">(on-redraw render-world)</font></div><div><br></div><div>By the way this has nothing to do with the <font face="Courier New">initial-world</font>, except that the first image it displays is the result of calling <font face="Courier New">(render-world initial-world)</font>, but you don’t have to worry about that. </div><div><br></div></div><blockquote type="cite"><div dir="ltr"><div>The <span style="font-family:courier new,monospace">define-struct</span> has to be exactly as you showed right? Or do I have to give the positions by using the <span style="font-family:courier new,monospace">make-posn</span> there?<br></div></div></blockquote><div>The <font face="Courier New">define-struct</font> does not have to be exactly as I showed. It could be anything that can represent where the objects in the program are. It doesn’t even have to be a structure. It could be a list of the posns, or a string that contains that information, or even a number that you can somehow decode to get the posns, but a structure is more convenient (at least for this program). </div><div><br></div><div>And you do not have to give the positions by using the make-posn there either. Instead, you put the initial positions into big-bang like this:</div><div><span style="font-family: 'Courier New';">(big-bang width height 1/30</span></div><div><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New';">(make-world (</span><font face="Courier New">make-posn </font><span style="font-family: 'Courier New';">550 550</span><font face="Courier New">)</font></div><div><font face="Courier New"> </font><span style="font-family: 'Courier New';">(</span><font face="Courier New">make-posn </font><span style="font-family: 'Courier New';">200 250</span><font face="Courier New">)</font></div><div><font face="Courier New"> </font><span style="font-family: 'Courier New';">(</span><font face="Courier New">make-posn </font><span style="font-family: 'Courier New';">100 550</span><span style="font-family: 'Courier New';">)</span></div><div><font face="Courier New"> </font><span style="font-family: 'Courier New';">(</span><font face="Courier New">make-posn </font><span style="font-family: 'Courier New';">550 400</span><font face="Courier New">)</font><font face="Courier New">))</font></div><div>Or probably something more like this would be better:</div><div><div><font face="Courier New">(define myself-initialposition (make-posn 550 550))</font></div><div><font face="Courier New">(define food1-initialposition (make-posn 200 250))</font></div><div><font face="Courier New">(define food2-initialposition (make-posn 100 550))</font></div><div><font face="Courier New">(define shark1-initialposition (make-posn 550 400))</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">(define initial-world</font></div><div><font face="Courier New"> (make-world myself-initialposition</font></div><div><font face="Courier New"> food1-initialposition</font></div><div><font face="Courier New"> food2-initialposition</font></div><div><font face="Courier New"> shark1-initialposition))</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">(big-bang width height 1/30 initial-world)</font></div></div><br><blockquote type="cite"><div dir="ltr">How do I manipulate images if all I am entering are the positions? Where do I instantiate the <span style="font-family: 'courier new', monospace;">place-image</span> procedure?</div></blockquote><div>You manipulate instances of the world structure, and then make a render-world function to translate those <font face="Courier New">world</font> structs into images for it to display in the window:</div><div><div><div><font face="Courier New">(define (render-world w) ; w should be an instance of the world structure</font></div><div><font face="Courier New"> ...) ; this should produce the image that it would display</font></div></div><div><br></div><div><font face="Courier New">(on-redraw render-world) ; this tells big-bang to use the render-world function make the image (maybe that’s </font></div><div><font face="Courier New"> ; what you were thinking of when you asked where you instantiate the place-image </font></div><div><font face="Courier New"> ; procedure)</font></div></div></div><br><div>By the way the <font face="Courier New">render-world</font> function should use the <font face="Courier New">place-image</font> function somewhere to generate the image, but you don’t instantiate the place-image procedure or anything like that. </div><div><br></div><div><br></div></body></html>