Ok so i felt like i should know how to do this using the formula y-y1 = m(x-x1) So I have a stationary object (refered to as sX and sY) and the moving object (mX, and mY) and two cordinates for the projectile (bulletX and bulletY) i know these are bad variable names but just using for the sake of this postI am shooting the projectile from the stationary object to the moving object

The part I dont understand is what to assign to the value of bulletX since I cant use this code as the value of bulletX has not yet been assigned. Keep in mind im only 14 lol Just to refrase I am trying to move an image across a line designated in the code above which moves the image from a stationary object to a moving object the target

I give out medals and use google, I ask questions for clarity. I know this might be hard for you to understand but as a kid I like understanding things, i am naturally curious and want to know everything. this is tough for me but I am attempting it. whats the fun of doing something easy?

I give out medals and use google, I ask questions for clarity. I know this might be hard for you to understand but as a kid I like understanding things, i am naturally curious and want to know everything. this is tough for me but I am attempting it. whats the fun of doing something easy?

I'm 27 myself, I began writing program back when Windows 3.11 was new - back then everything was hard, AND I didn't have the internet, much less google, to help me out; just dusty books. I already explained how you need to come up with your answer, and what branch of math it is; but do not expect me to teach the entire mathematical subject to you in a forum. Also, do not get mad at me because you are trying to make waffles with a screwdriver and I'm telling you to use a spatula. I HIGHLY recommend you visit this site:

Sign up, start with basic addition/subtraction, and work your way up the tree (when you register it will give you a skill tree from basic to stupid complex types of math) until your brain starts hurting. They have amazingly well done videos for just about every subject. Since you need to get trigonometry under your belt, simply follow the skill tree and work your way up to it. It's not going to happen in a day, but you already stated you wanted to learn... this is how.

I'm not getting mad at you I know this is something you can not teach me I was just curious if you could do this in linear algebra as that was something I had learned and I thought it could be done in that. Anyway thanks for the help i appreciate it

Expanding on that a bit: Linear Algebra is any and all operations you do on a vector space, but still you need some kind of basic operations on the components of the vector space for it to be meaningful, and of course you need to learn those operations. In the case of 3d graphics, the operations we're concerned with are trigonometry.

To build on that...the original usefulness of complex numbers (the second algebra to be known) was the ability to avoid classic geometry and trig..in the sense the geometric and trig meaning is built-in to the algebra itself, not that you don't need a basic understand of these topics.

I give out medals and use google, I ask questions for clarity. I know this might be hard for you to understand but as a kid I like understanding things, i am naturally curious and want to know everything. this is tough for me but I am attempting it. whats the fun of doing something easy?

You'll understand things a lot better if you figure them out yourself, and I have no idea why this is even remotely tough for you. Like I said, you've been given the source, it doesn't get much easier than that.

I have never learned trig so some of this stuff is confusing.... is there any simpler way to do this in linear algebra?

Right back at you. There's no need for any trigonometry here! Just create a direction vector and normalize it to get a velocity directly. Oh, did I mention that it's a lot faster too than using atan2() + sin() + cos()?

Now I feel stupid for just now seeing that.. I use the distance formula myself a lot but never though about creating a directional vector and using it that way. Seems obvious now.. There's always room for improvement I guess

You don't even need sin or cos to know future positions of projectiles. You just need a position, and a direction in which the projectile will move.

Its easier to just use vector maths for 2D projectiles. A vector is represented exactly as a coordinate, but it represents length and direction. So, if you have a bullet at position (4, 5) and its direction is (1, 0), the bullet will move to the right by 1 coordinate every frame.

If you have a direction of (1, 1), it won't be moving exactly 1 coordinate spot per "frame". You need to normalize the vector, which means get the length of the vector, and divide all the components (x and y) by the length. Then you can multiply both of these values to achieve speed in the bullet.

Use something like this:

1 2 3 4 5 6 7

Vector2Dpos = newVector2D(4, 5);Vector2Ddir = newVector2D(1, 1);

dir.normalize();dir.multiply(2);

pos.add(dir);

Using slope to do stuff is kind of complicated, and I feel that vectors can be achieved to do much more. =D

Complex numbers can be really helpful in understand 2D transformations...the sad problem is that there are very few good explanations laying around. Complex numbers are pretty much only talked about (for geometry) in dealing with classic (aka nasty/hairy) geometry problems and not basic common stuff...and there's a silly insistence on sticking to the absurd notion of square roots of negative numbers (which is misleading).

Using slope to do stuff is kind of complicated, and I feel that vectors can be achieved to do much more. =D

Just thought I'd mention that from a computer science point of view, mathematical entities (e.g. Vectors, Matrices, etc) should always be represented by immutable objects except if it would hurt performance. You may notice that classes like Integer, Long, BigInteger, BigDecimal, etc. are all immutable. For simple code it doesn't make much of a difference but if you do complex vector math, mutable vectors can make the code really messy.

Are you suggesting to make an immutable Matrix class...? Has anyone ever done that?

And yes, it always hurts performance, which is why it would be madness to make vector classes immutable, let alone matrices.

Sun's vecmath classes are mutable, but create many objects under the hood. It may look like a great compromise but in the end it's the reason nobody uses it. It's slow and puts incredible stress on the garbage collector.

Hi, appreciate more people! Σ ♥ = ¾Learn how to award medals... and work your way up the social rankings!

Just thought I'd mention that from a computer science point of view, mathematical entities (e.g. Vectors, Matrices, etc) should always be represented by immutable objects ...

That's utter nonsense. Stop listening to whomever told you that. Beside java doesn't even have immutable object (no...it really doesn't). The widespread usefulness of immutables took a huge blow in the 80s with the introduction of SSA form, but even before that this statement would still be nonsense.

There's the ideal situation, in which object creation and collection is free and immutability solves many problems (mainly in multithreading), and there is this annoying requirement of games to be running at a rock solid 60Hz.

Hi, appreciate more people! Σ ♥ = ¾Learn how to award medals... and work your way up the social rankings!

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org