This is the P2PU Archive. If you want the current site, go to www.p2pu.org!

Programming Visual Media

My recent threads

You haven't posted any discussions yet.

Recently updated threads

Lesson 2 Questions

Go back to: General discussion

Please ask your questions about lesson 2 in this topic.

Thanks!

J.D.

Damiana Gibbons's picture
Damiana Gibbons
Sun, 2010-09-26 23:06

With the mousePressed exercise in Chapter 1, we can only click to make one set of five squares. But, in the first exercise in Chapter 3, we can click around the canvas to make a circle more than once. From the looking the code, they look similar. We've even tried putting the code from Chapter 3's example into the five squares exercise, but we can still only click once. What is the difference in the code between these two that makes it possible to click more than once with the circles but not with the five squares.

J.D. Zamfirescu-Pereira's picture
J.D. Zamfirescu-P...
Mon, 2010-09-27 01:03

(I've renumbered the chapters in lesson 2 to continue from lesson 1 - they're now numbered 4, 5, and 6!)

A complete solution to chapter 4 exercise 7 should draw squares around each click location. Can you paste a link to a sketch so I can take a look?

A few thoughts in the meantime: remember to define a mousePressed function outside all other function bodies; remember that the names mouseX and mouseY must be used each time you want to use the mouse position - you can't use "x = mouseX" and then use "x" repeatedly for the mouse position - the value of x is set just once, and doesn't change even if mouseX later changes.

Sarah's picture
Sarah
Mon, 2010-09-27 05:04

Thanks for responding so promptly! We figured it out, and it was something minor that we had missed -- we forgot to reset SideLength here after the loop: http://studio.sketchpad.cc/p7AIB6Gw6U

J.D. Zamfirescu-Pereira's picture
J.D. Zamfirescu-P...
Mon, 2010-09-27 08:13

Ah cool. :)

Since you don't need to keep SideLength around for more than just one call to fiveSquares (that is, you don't need to keep its value from one set of squares to the next), you can just define and set SideLength *inside* the function fiveSquares. That way you don't need to reset it to 10 at the end of the function.

Glad you got it figured out!!

Damiana Gibbons's picture
Damiana Gibbons
Mon, 2010-09-27 20:45

I agree. Thanks for your prompt and excellent feedback. =)

Jonathan Hanahan's picture
Jonathan Hanahan
Wed, 2010-09-29 05:59

Im working on this lesson a bit but have some moments which are escaping me. In lesson 4.3 i am having issues when I try to replicate a 'squareCount' as 'circleCount'. It returns "can not find anything names circleCount". But also, if I am to pull my function in to the actual processing interface from Lesson 4.1/2 it does the same thing, telling me it can not find anything named square count, yet it will run correctly in the sketchpad code....Is there a reason sketchpad may allow a name while processing does not?

J.D. Zamfirescu-Pereira's picture
J.D. Zamfirescu-P...
Wed, 2010-09-29 20:55

Hi,

Can you share your code so I can take a look?

My guess from your description is that you did not define the type of "circleCount" initially as you did with "squareCount". (This code works in sketchpad but not processing because of a known quirk in sketchpad that lets you use names without defining their type.)

Davide Gomba's picture
Davide Gomba
Wed, 2010-09-29 17:53

hi guys.

Sorry to miss the second lesson.
I've just completed the homeworks.

I wasn't able to complete the last excercise without keeping circle() with no variables.
http://studio.sketchpad.cc/sp/pad/view/0JRAb52dZn/rev.258

I'll come back on this in the next days.
Cheers.

Davide