student question about safe-left? and OnScreen?

7 views
Skip to first unread message

Bob Kahn

unread,
Apr 23, 2019, 12:15:26 PM4/23/19
to Bootstrap-Teachers
Hello, 

I have a student who is wondering why/how safe-left? stops Sam the butterfly from flying off the left side of the screen. 
He understands the boolean nature of asking if x is greater then -50, but has a good question as to how defining safe-left?
stops Sam from going off the screen. 

I understand that Onscreen? works the same way, but why does defining these functions
keep Sam on the screen. Is that the functions NEED to be true? If so, is this programmed in the teachpack?

Thank you,
Bob

Shriram Krishnamurthi

unread,
Apr 23, 2019, 12:27:10 PM4/23/19
to bootstra...@googlegroups.com
Great question. 

Yes, this is programmed into the Teachpack. The Teachpack is looking for these functions, and using them to govern Sam's behavior. 

So there is a slight disconnect between what the student wrote and what happens on the screen. For instance, if there was a buggy program in the Teachpack (maybe it misinterpreted the Boolean and swapped the meaning of true and false), then the student's function can be exactly correct but Sam would be behaving in exactly the wrong way.

Does that make sense?

Shriram

--
You received this message because you are subscribed to the Google Groups "Bootstrap-Teachers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bootstrap-disc...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bob Kahn

unread,
Apr 23, 2019, 12:40:41 PM4/23/19
to bootstra...@googlegroups.com
Thank you, Shriram. 
Yes that makes sense. 

My question is then, what is programmed in the teachpack to make the danger or target stop on left side and reappear on the right? Would this be some type of "if safe-left? is false (meaning not > -50), then make x-coordinate of danger (or target) 690"? 




------------------------
Bob Kahn 
MS Ed Tech Specialist and CS/Robotics Teacher

Brentwood School
100 South Barrington Place 
Los Angeles, CA 90049

“Society grows great when [people] plant trees whose shade they know they'll never sit in." 
         - Greek proverb...maybe. 



You received this message because you are subscribed to a topic in the Google Groups "Bootstrap-Teachers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bootstrap-discuss/IKcw05QHK-w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bootstrap-disc...@googlegroups.com.

Schanzer (Director)

unread,
Apr 23, 2019, 3:50:23 PM4/23/19
to Bootstrap-Teachers
Yes, you're exactly right! It's essentially:

; if the new (x,y) is onscreen, make a posn at that location
; otherwise, make a posn using the old coordinates
(define (move-to new-x new-y old-x old-y)
  (cond
    [(onscreen? new-x new-y) (make-posn new-x new-y)]
    [else (make-posn old-x old-y)]))
Reply all
Reply to author
Forward
0 new messages