Skip to main content
7 events
when toggle format what by license comment
May 4, 2013 at 18:17 comment added user30340 I actually just saw your comment. Sorry. I have removed that line and used a negative value like so. The problem, however, is still present. I also made sure that the addition of negative values works as expected, which it does. So the problem must be somewhere in the implementation I'm using, not in the vector class itself.
May 4, 2013 at 18:11 comment added user30331 If you want to move at a constant speed, you'll want that line for both key presses. If you want acceleration, however, you'll need to do as I explained above.
May 4, 2013 at 18:09 comment added user30340 That's also from said book. I'm using this project pretty much as a playground. This particular line is supposed to set the accerlaration to zero. It does have a slight effect but it's not really related to this problem.
May 4, 2013 at 18:09 comment added user30331 Okay, now I know what's going on. When you mult acceleration by 0, you're getting rid of it for good. That's not the idea behind acceleration. It's meant to keep going even when you're not pressing a button. Like a falling object, it keeps getting faster and faster, and doesn't continue at the same speed. What you want to do is get rid of that mult line, and make the opposite direction invoke a negative value. This will give you the acceleration effect.
May 4, 2013 at 18:03 comment added user30331 Yes, adding a negative number is the same as subtracting a positive number. Doing it this way SHOULD be fine. What's with this line though? acceleration.mult(0);
May 4, 2013 at 17:59 comment added user30340 The .add() method takes numbers as well as a vector object. It is really nothing fancy and should actually take negative values just fine. Adding a negative value should be the same as subtracting a positive one, right? However, as soon as I use negative values, the vectors continue to increase or decrease exponentially, leading to a pretty much uncontrollable object. It's on c9.io, I can post the address if you don't mind the horrible state of code. :)
May 4, 2013 at 17:42 history answered user30331 CC BY-SA 3.0