Created
February 21, 2023 00:53
-
-
Save EllaY44/82ea05aeb18cc78d142b35419d218942 to your computer and use it in GitHub Desktop.
homework week 4 question
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
global circleX, direction | |
circleX = 500 | |
direction = 8 | |
global circletwoX, directiontwo | |
circletwoX = 450 | |
directiontwo = 3 | |
global circlethreeX, directionthree | |
circlethreeX = 550 | |
directionthree = 6 | |
def setup(): | |
size (600, 600) | |
noStroke | |
def draw(): | |
global circleX, direction | |
background(255, 255, 255) | |
img = loadImage("cat-raster-image.png") | |
image(img, 0, 0, 600, 600) | |
fill(165, 131, 98) | |
ellipse(circleX, 500, 50, 50) | |
circleX = circleX + direction | |
if circleX > 500: | |
direction = -15 | |
if circleX < 120: | |
direction = 15 | |
global circletwoX, directiontwo | |
fill(252, 222, 240) | |
ellipse(circletwoX, 450, 60, 60) | |
circletwoX = circletwoX + directiontwo | |
if circletwoX > 520: | |
directiontwo = -10 | |
if circletwoX < 150: | |
directiontwo = 10 | |
fill(236, 214, 255) | |
circle(335, 350, 35) | |
if mousePressed: | |
global circlethreeX, directionthree | |
fill(176, 211, 252) | |
ellipse(circlethreeX, 550, 40, 40) | |
circlethreeX = circlethreeX + directionthree | |
if circlethreeX > 600: | |
directionthree = -10 | |
if circlethreeX < 0: | |
directionthree = 10 |
Also line 16 is missing the parenthesis ()
. It should look like this:
noStroke()
I'm also surprised this did not generate an error.
Hello,
All those corrections worked; thank you! @rors
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice work so far. Remember what I was saying in class about using
loadImage()
in Processing's "active" mode?You should move line 21 into
def setup()
, makeimg
global in bothsetup()
anddraw()
. I think that will probably fix your problem but if not we can debug it further from there.If you want to see some code snippets illustrating what I mean have a look at the "Review" section in the Week 4 class notes.
Also, probably unrelated but line 43 needs to be indented by 4 spaces to align with the preceding lines. I'm actually surprised that this doesn't give an error.
Good luck and let me know if this works.