Get the mouse x , y? NOT SOLVED

Well i get this:
(before i changed static x,y to not static)

(after)

GitHub for the code

i dont know why is it doing this? I want it to go at any angle? why it doesn’t ?

Edit: Everything !

Intrestingly your code snippets miss exactly the parts that would allow us to help you, namely the declarations of your various x and y variables…

I have posted everything now!

LOL - still the same - the declaration of x and y is still nowhere too be seen…

The Entity ? :


package Entity;

import java.awt.Graphics2D;
import java.awt.Rectangle;

public class Entity extends Rectangle{
	
	public static double x,y;
	public double drawX;
	public double drawY;
	public int width,height;
	
	public Entity(int x,int y, int width,int height){
		this.x = x;
		this.y = y;
		this.width = width;
		this.height = height;
	}
	
	public void setX(int x){
		this.x = x;
	}
	
	public void setY(int y){
		this.y = y;
	}
	
	public void setWidth(int width){
		this.width = width;
	}
	
	public void setHeight(int height){
		this.height = height;
	}
	
	public void tick(){
		
	}
	
	public void render(Graphics2D g){
		
	}
}


Could you please explain the relevant code and break it down? I at least don’t feel like reading through ~200 lines of someone else’s code to solve what is most likely a basic problem, no offense.

Edit:
Read up on static. Those static x and y variables are… Like nails on a chalkboard. I don’t think you understand what you’re doing there.

Thank you! But why is it doing that?

Static creates one instance of the variable for the entire program at runtime. Only one instance. So whenever you change a static variable, any objects that utilize that variable will also be affected. Sounds weird so let me give you an example.

You have an Entity class with the static variables x and y. You create two instances of the Entity variable. Both entities now have the same x and y variables because they are static and so if you change the x and y in one entity, the x and y variables in the other will change also to be the exact same. Essentially you are sharing a variable between multiple objects when you use the static keyword.

Hope that actually made sense.

If you are talking about the it only shooting at certain angles, most of the time something is getting changed to a int were it should be a double.

It’s not solved :(!

:emo: Well you helped but the code is still not working
i still get chunks

Source on GitHub