I teach Processing to grade 7 and 8 students at an international school and have often used
http://sketchpad.cc/ as a way for my students to share their projects on their ePortfolios (upload and embed) but it seems that the site is down and has been for a while. Does anyone know what happened (and if it's possible to retrieve our old projects...) Since it's based on etherpad, is the code available? (I know openprocessing is still a possibility, but I was just wondering about other options.
I figured this one would be easy and I would just need to refresh my memory of basic trig to sort it out but it has turned out to be trickier than I expected.
I want to draw a line between two random points and then have little perpendicular lines, evenly spaced along its length. So it will look sort of like a row of stitches or a zipper.
So, if I have the x1,y1,x2,y2 of the main line and use a for loop to do the x1,y1 of the 'railroad ties'', what formula can I use to get the x2,y2 of those so that they are properly perpendicular to the main line?
Any suggestions would be appreciated. My toddler is really into trains and the idea is to make a little train track then have a couple of rectangles going up and down and then mess about with that in some way.
I wrote a simple little game for my toddler where he has to connect two dots by dragging his finger on the screen. On the computer, it is smooth and responsive. In Android, when you drag the line into the second circle and then release, it won't respond unless you hold your finger there for a few seconds. I tried on a Desire, a Sensation and a Transformer. Same each time. Is this typical or is there something wrong with my code?
float lastX, lastY;
float newX, newY;
float circle1X = random(50, 430);
float circle1Y = random(50, 350);
float circle2X = random(50, 430);
float circle2Y = random(450, 750);
float color1 = random(100);
float color2 = random(100);
float dist1;
float dist2;
int score = 0;
void setup() {
size(480, 800);
background(0);
strokeWeight(10);
stroke(255);
smooth();
textAlign(CENTER);
textSize(40);
}
void mousePressed() {
lastX = mouseX;
lastY = mouseY;
dist1 = dist(circle1X, circle1Y, lastX, lastY);
}
void mouseReleased() {
newX = mouseX;
newY = mouseY;
dist2 = dist(circle2X, circle2Y, newX, newY);
if (dist1 < 50 && dist2 < 50) {
// println("got it!");
color1 = random(100);
color2 = random(100);
circle1X = random(50, 430);
circle1Y = random(50, 350);
circle2X = random(50, 430);
circle2Y = random(450, 750);
score = score + 1;
}
}
void draw() {
background(0);
text(score, 20, 40);
colorMode(HSB, 100);
fill(color1, 80, 80);
ellipse(circle1X, circle1Y, 80, 80);
fill(100);
text("1", circle1X, circle1Y + 15);
fill(color2, 80, 80);
ellipse(circle2X, circle2Y, 80, 80);
fill(100);
text("2", circle2X, circle2Y + 15);
if (mousePressed == true) {
if (dist1 < 50) {
line(circle1X, circle1Y, mouseX, mouseY);
}
}
if (score == 10) {
fill(0);
rect(0, 0, width, height);
fill(100);
text("You Win!", width/2, height/2);
}
}
Of course, any suggestions on how to improve this are also welcome. i am very new to programming and always appreciate tips on how I can improve.
I am a newbie so please bear with me. I am teaching an introduction to programming with a grade 9/10 high school class using Processing and so far things are going swimmingly. In particular, the videos that Hamoid made on funprogramming.org have been a fantastic resource.
So we have run into a wall now with getting audio to work on Android. Only too late did I learn that the Minim library doesn't work in Android. I found a couple of references to other ways that people managed to get audio to work in Android but they were way beyond me and I am hoping someone could walk me through the simplest way to get sounds to play.
The project that I am doing to model images and sound is one that I did for my 1 year old. He taps on the screen and it shows an image of a randomly selected member of the family and plays a little audio clip of my 3 year old saying that person's name. On the desktop, it works fine but in Android, there is no audio library.
Here's the program. If someone could suggest a simple way to modify it so I can get it onto my phone, I would be most grateful. I am hoping that my students can create something similar by the end of the semester. (Any other suggestions are welcome as well, of course. Remembering that we are all beginners with this. I find the best way to learn something myself is to put myself in a situation where I have to teach it to someone else...)