I think Riven is right, but let me try to be more clear one last time.
A slope in the context of a game will essentially give you an angle. It does not have both X and Y, it is a single value. In order to handle movement on a 2D plane (which is what you have), you need something that has both an X and a Y. In other words, a vector.
Although we’ve mentioned all these things you can do with vectors, the actual vector itself is very very very simple.
public class Vector2D
{
public float x;
public float y;
public Vector2D(float setX, float setY)
{
x = setX;
y = setY;
}
}
Seriously, that’s it. Anything else in a vector class has nothing to do with the actual structure of a vector, instead it has to do with different things you can do with it. Just having these two floats, you can represent absolutely any movement in 2D space, be it left, right, up, down, or in between. And it can cross half a screen or 5000 screens. It’s very simple but can do absolutely anything you want in terms of movement.
So. You create your vector initially with the positions of the mouse and the cannon.
//This will give you a vector that points FROM the cannon TO the mouse. If you subtracted them in reverse order,
//the vector would point in the opposite direction.
Vector2D velocity = new Vector2D(mouse.getX() - cannon.getX(), mouse.getY() - cannon.getY());
//Use the pythagorean theorem to get the length of the vector.
float length = (float) Math.sqrt(velocity.x * velocity.x + velocity.y * velocity.y);
//Normalize the vector (making it have a total length of 1, turning it into a unit vector) using the length we found.
velocity.x /= length;
velocity.y /= length;
//Multiply the unit vector by the power of the cannon, so the more power there is, the further it flies.
velocity.x *= cannonPower;
velocity.y *= cannonPower;
//Finally, create a bullet with the initial velocity of what we just computed.
world.add(new Bullet(cannon.x, cannon.y, velocity));
That’s as much as anyone can baby you. I’ll answer any questions you specifically have about the code mentioned above, but I won’t explain vectors any further (and I doubt anyone else will, either).

