Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Spatial
Nov 15, 2007

Are you sure you didn't mean to post that in the coding horrors thread?

Adbot
ADBOT LOVES YOU

Spatial
Nov 15, 2007

emanresu tnuocca posted:

I probably shouldn't do the arcsin/arccos.
I'll go one further: you shouldn't use angles at all. Angles are a horrendous way to represent direction, the only upside is familiarity with the bare numbers.

Vectors make everything much easier. In the general case you could use the reflection formula for light to bounce vectors around. In this special case where the walls are always at 90 degree angles you can turn your intuition directly into code: just as you said, when a circle hits a wall its motion on the contacting axis is negated. When the motion is a vector that's just negating a variable. :buddy:

Spatial
Nov 15, 2007

If they all implement some common interface, you can make an ArrayList<CommonInterface> and put any implementing class in there.

e: soo late. :shobon:

Spatial
Nov 15, 2007

Zaphod42 posted:

You don't want to manually code all those positioning values and stuff.
You do if you want anything worthwhile. But use MigLayout so it's nice and easy to code.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply