Created
October 5, 2020 00:38
-
-
Save gretaf007/5b6403125bec34f10192fab80ec97fd2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Greta Villani | |
Coding | |
Rory Soloman | |
September 29 2020 | |
I was trying to have the circles bounce back down from the top, but I couldn't grasp how | |
to do that from the class notes. | |
""" | |
c1 = color(100, 200, 255) | |
c2 = color (10, 0, 300) | |
circleS = (350) | |
circleDirection = 1 | |
circleM = (350) | |
def setup(): | |
size(600, 600) | |
stroke(155, 155, 255, 50) | |
frameRate(24) | |
def draw(): | |
size(600, 600) | |
#dark sky color | |
fill(c2) | |
rect(0,0,600,317) | |
#light sky color | |
fill(c1) | |
rect(0,0, 600, 317) | |
#moon | |
fill(209) | |
circle(120, circleM, 65) | |
global circleM | |
global circleDirection | |
circleM = circleM + circleDirection | |
if circleM > width: | |
circleDirection = -1 | |
#sun | |
fill(255, 150, 0) | |
circle(450, circleS, 65) | |
global circleS | |
global circleDirection | |
circleS = circleS + circleDirection | |
if circleS > width: | |
circleDirection = -1 | |
photo = loadImage("Valley-Taurus-Mountains-Turkey.jpg") | |
image(photo, 0, 315) | |
Hi Greta. You're very very close to figuring this out, so I'm going to point you to this section of the Week 4 class notes. I recommend that you carefully read through these two bits of pseudocode, the code snippet that comes next, and the accompanying explanation.
In that example, I was talking about horizontal movement, so I was using the words "left" and "right". But you are talking about vertical movement, so wherever I say "right", you could think about the bottom of the draw window, and wherever I say "left", you could think about the top of the draw window.
Try reading through that, pay attention to the code in blue, and see if you can make a similar addition to your code.
Great work so far!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@rors
I meant to ask this last week, but I don't think I fully grasped how to have an object bounce off the frame and move back again. We did it in class going horizontally and I tried to transfer that to happen vertically, but I couldn't get it to work.