I need your help within the next 7 hours!!! -only just with setting up a button correctly.
in
Programming Questions
•
2 years ago
Hello there! :-)
I am currently sitting here working all I can on getting a hand-in ready for tomorrow (or today - Friday 19th). I have to pass!
I have only just learned working with Processing tonight. I think that what I need help with it is actually quite simple, but I haven't yet fully understood the basics, so your help will be highly appreciated, as I have now been trying to figure it out myself for hours...
I have uploaded two links below. The first one being a short visualized explanation of what I wish to do, and the second being my codes so far.
1 - http://jonasskafte.com/explanation.pdf
2 - http://jonasskafte.com/Mousehole7.zip
I hope to hear back from you soon!
Thanks in advance and kind regards
/Jonas.
Here are my codes so far - please excuse me if they are a bit messy...
I am currently sitting here working all I can on getting a hand-in ready for tomorrow (or today - Friday 19th). I have to pass!
I have only just learned working with Processing tonight. I think that what I need help with it is actually quite simple, but I haven't yet fully understood the basics, so your help will be highly appreciated, as I have now been trying to figure it out myself for hours...
I have uploaded two links below. The first one being a short visualized explanation of what I wish to do, and the second being my codes so far.
1 - http://jonasskafte.com/explanation.pdf
2 - http://jonasskafte.com/Mousehole7.zip
I hope to hear back from you soon!
Thanks in advance and kind regards
/Jonas.
Here are my codes so far - please excuse me if they are a bit messy...
- // A whole to crawl into!
// Jonas Skafte
// http://www.jonasskafte.com
//Images
PImage img;
PImage teddy2;
PImage teddy3;
PImage teddy4;
PImage teddy;
float xpos;
float ypos;
float drag = 30;
//Link
int circleX, circleY; // Position of circle button
int circleSize = 45; // Diameter of circle
color circleColor, baseColor;
color circleHighlight;
color currentColor;
boolean circleOver = false;
void setup() {
size(1152,792);
img = loadImage("hole.jpg");
teddy = loadImage("mouse3.PNG");
teddy2 = loadImage("mouse4.png");
teddy3 = loadImage("Cat.jpg");
xpos = width/2;
ypos = height/2;
circleX = width/2+circleSize/2+10;
circleY = height/2;
circleColor = color(0);
circleHighlight = color(100);
ellipseMode(CENTER);
}
void draw() {
noCursor();
background(0);
image(img,0,0);
float difx = mouseX - xpos-teddy.width/2;
if (abs(difx) > 2) {
xpos = xpos + difx/drag;
xpos = constrain(xpos, 0, width-teddy.width);
if(circleOver) {
fill(circleHighlight);
} else {
fill(circleColor);
}
ellipse(circleX, circleY, circleSize, circleSize);
}
float dify = mouseY - ypos-teddy.height/2;
if (abs(dify) > 1) {
ypos = ypos + dify/drag;
ypos = constrain(ypos, 0, height-teddy.height);
}
// Display the sprite at the position xpos, ypos
image(teddy2, xpos, ypos);
if(mousePressed) {
image(img,0,0);
image(teddy, xpos, ypos);
}
}
1