We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Heey guys,
My program shows the picture I set the cursor to be, but the picture is pixely, contains colors that aren't in the original picture and gets distorted at times. Since, apparantly the mouse isn't visible when you take a screenshot I don't know how to show you. I thought I would just show you most of the code, since I'm a beginner and might leave stuff out that actually causes the problem.
//Intialize picture aimingpoint
PImage aimingpoint;
//define class object
hare one;
//define boolean for pulling gun
boolean pull;
int width = 600;
int height = 600;
float middleX = width/2;
float middleY = height/2;
//Define values for position and size hunters
float xPosHunter1 = 0;
float yPosHunter1 = 0;
float xPosHunter2 = -200;
float yPosHunter2 = 0;
int radHunter = 10;
int deadlyDistance = 150;
//Define animalspeed
int animalSize = 10;
float hareSpeed = 1;
void setup() {
size(width, height);
smooth();
//Define hare one
one = new hare(100, 1);
aimingpoint = loadImage("aimingpoint.png");
}
void draw() {
//calculate angle between the line that goes fromthe origin to the mouse and postive x-axis
//I posted a question about this on forum.processing.org: https://forum.processing.org/two/discussion/14433/rotate-line-in-such-a-way-that-one-point-is-in-the-middle-of-the-canvas-and-other-follows-the-mouse#latest
background(255);
//Move origing to the middle of the canvas.
translate(0.5 * width, 0.5 * height);
//Flip the canvas in the x-axis so that the axis system is like a 'normal' one.
scale(1, -1);
//draw mouse as aimingpoint
//http://stackoverflow.com/questions/12539840/change-mouse-cursor-in-processing
cursor(aimingpoint, 16, 16);
// ellipseMode(CENTER);
// ellipse(mouseX, mouseY, 5, 5);
// noFill();
// ellipse(mouseX, mouseY, 30, 30);
if ((keyPressed == true && key == 'p' || key == 'P') && mousePressed == true && distanceOriginMouse() <= deadlyDistance){
background(0, 255, 0);
}
else if ((keyPressed == true && key == 'p' || key == 'P') && mousePressed == true && distanceOriginMouse() > 0.5 * deadlyDistance){
background(255,0,0);
}
//draw gun when p is pressed
if (keyPressed == true && key == 'p' || key == 'P') {
pushMatrix();
rotate(-angleMouse());
line(0, 0, 40, 0);
popMatrix();
}
ellipseMode(RADIUS);
//draw deadly
noFill();
ellipse(0,0,deadlyDistance, deadlyDistance);
fill(255);
//Draw Hare1
one.show();
one.move();
pushMatrix();
rotate(radians(135));
line(0,0,500,0);
popMatrix();
stroke(0);
//Hunter1
ellipse(xPosHunter1, yPosHunter1, radHunter, radHunter);
//Hunter2
ellipse(xPosHunter2, yPosHunter2, radHunter, radHunter);
//if (mousePressed == true && mouseButton == LEFT && mouseX >=) {
}
The picture is 16 x 16 pixels, so that probably causes the pixelyness, but if I take a larger picture, processing won't show the entire picture anymore.
Hope you guys can help out!
-Bodhidharma482
Answers
you need to post the image you are using, or link to it.
I am no longer in need of the answer to this question.
Thanks for the effort however!
Best wishes