I'm REALLY new to programming and processing so bare with me.
My problem is in void display and void move
I want the last stated rectangle to shoot from the "gun" and also not be able to be shot again until it has left the screen. I've gotten it to move from one end of the screen to the other, but when i connect it to the mouse coordinates it doesn't move. Please help.
--------------------------
float x;
float y;
float easing = 0.1;
float x1 = x;
float x2 = 100;
float y1 = y;
float Bulletspeed = 50;
color c = color(0,0,0);
PImage dirt;
PFont font;
void setup() {
size(1500,700,P2D);
smooth();
stroke(0);
dirt = loadImage("grass.png");
font = loadFont("font.vlw");
}
void draw(){
noCursor();
background(0);
image(dirt,0,0,1500,700);
Jim(x,y);
textFont(font);
textSize(30);
fill(0,0,0);
text(frameCount,1400,30);
move();
display();
float targetX = mouseX; //float command on x-axis
x += (targetX - x) * easing; //easing x
float targetY = mouseY; //float command on y-axis
y += (targetY - y) * easing; //easing y
}
void Jim(float x,float y) {
fill(200);
strokeWeight(1);
ellipse(x,y,20,20);
strokeWeight(5);//for lines
stroke(200);//for lines
line(x,y+7,x,y+40);//body
line(x+5,y+10,x+10,y+10);//arm
line(x,y+40,x+5,y+45);//frontleg
line(x,y+40,x-5,y+45);//backleg
strokeWeight(0);//for rect
fill(0);//for rect
rotate(0);//for rect
rect(x,y,30,10);//rect
strokeWeight(5);//for line
stroke(200);//for line
line(x+10,y+10,x+5,y+5);//forearm
}
//my problem is in these lines!!!v
void move() {
if (x1 > width == false) {
if (mousePressed && (mouseButton == LEFT)){
x1 = x1 + Bulletspeed;
y1 = 0;
}
}
}
void display() {
if (x1 > width == false) {
if (mousePressed && (mouseButton == LEFT)) {
color(c);
rect(x,y,30,10);
}
}
}
----------------------------------