<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Sorry, I forget to give you the chapter and the book.<br>
Im talking about this chapter <br>
<h5>2.5.2<tt> </tt><a name="(part._progstructs)"></a>Programming
with Structures Which can be found at this url:
<a class="moz-txt-link-freetext" href="http://www.ccs.neu.edu/home/matthias/HtDP2e/htdp2e-part1.html#%28part._structure%29">http://www.ccs.neu.edu/home/matthias/HtDP2e/htdp2e-part1.html#%28part._structure%29</a></h5>
<p><br>
Roelof<br>
<br>
</p>
Op 30-3-2012 9:32, Roelof Wobben schreef:
<blockquote cite="mid:4F756184.3010000@home.nl" type="cite">Hello,
<br>
<br>
I try to make the ufo exercise work on this chapter :
<br>
<br>
So I have this :
<br>
<br>
; visual constants
<br>
(define MTS (empty-scene 100 100))
<br>
(define BLU (place-image (rectangle 25 25 "solid" "blue") 50 50
MTS))
<br>
<br>
(define-struct velocity (dx dy))
<br>
; A Velocity is a structure: (make-vel Number Number)
<br>
; interp. (make-vel d e) means that the object moves d steps
<br>
; along the horizontal and e steps along the vertical per tick
<br>
<br>
<br>
(define-struct ufo (loc vel))
<br>
; A UFO is a structure: (make-ufo Posn Velocity)
<br>
; interp. (make-ufo p v) is at location p
<br>
; moving at velocity v
<br>
(define v1 (make-velocity 8 -3))
<br>
(define v2 (make-velocity -5 -3))
<br>
(define p1 (make-posn 22 80))
<br>
(define p2 (make-posn 30 77))
<br>
(define u1 (make-ufo p1 v1))
<br>
(define u2 (make-ufo p1 v2))
<br>
(define u3 (make-ufo p2 v1))
<br>
(define u4 (make-ufo p2 v2))
<br>
<br>
; UFO -> UFO
<br>
; move the ufo u, i.e., compute its new location in one clock
<br>
; tick from now and leave the velocity as is
<br>
<br>
(define (ufo-move u)
<br>
(make-ufo
<br>
(posn+ (ufo-loc u) (ufo-vel u))
<br>
(ufo-vel u)))
<br>
<br>
(define (posn+ p v)
<br>
(make-posn (+ (posn-x p) (velocity-dx v))
<br>
(+ (posn-y p) (velocity-dy v))))
<br>
<br>
(define (show-ufo ufo)
<br>
(place-image BLU (ufo-loc u) MTS))
<br>
<br>
(define (game ufo)
<br>
(big-bang ufo (on-tick ufo move u) (on-draw show-ufo)))
<br>
<br>
<br>
But still I can't get the show-ufo work.
<br>
I my opinion ufo loc represent the position on the screen so the x
and y position.
<br>
Is this right ?
<br>
<br>
I find this a very confusing exercise and I hope someone can give
me tips how to solve this without given the answer to the pogramm.
<br>
<br>
Roelof
<br>
<br>
____________________
<br>
Racket Users list:
<br>
<a class="moz-txt-link-freetext" href="http://lists.racket-lang.org/users">http://lists.racket-lang.org/users</a>
<br>
<br>
</blockquote>
<br>
</body>
</html>