views:

165

answers:

3

I'm a hobbyist game programmer. I only do 2d games, no 3d stuff. I don't have a math background and lots of things are tripping me up like bullet projections and angles.

I took two college level Algebra courses at the local community college, but really disappointed. I got As in both, but really don't feel like I'm using any of it in my everyday 2d game programming and still stuck on angles/bullet paths, etc

I dropped out this semester to self study. The advisory at the community college said I want to be in Statistics for this and was really pushing me hard to enroll in that class. He said Statistics then Calculus I & II would get me what I needed.

I've been reading up a lot and not so sure on this. I think I should start with a a Geometry book and then move into Trigonometry? Is that the right approach?

Anyone suggest any good self-study starter books?

+4  A: 

I got a lot out of "3D Math Primer for Graphics and Game Development". I know it says 3D but there is a lot of stuff in there for 2D. And the math is fairly simple linear algebra.

dgnorton
Notice that this book is a lot about vectors, and not a lot about trigonometry, and that is the right way to go. Newtonian physics is by far described best using vectors. You will probably need a little trigonometry as well, but only the basic stuff.
eBusiness
+3  A: 

It sounds like statistics is useless for what you want to do. Calculus might be marginally useful, but not until you are really solid with it. You probably need to learn trigonometry more than anything else. I could offer more explicit advice if you give an example of a problem you're trying to solve.

Jonathan
In top down 2d game. Say I have a point x,y (the barrel of a gun). It shots at point x2, y2 (were the user aimed). I can draw a line between them, but don't know how to get the "next point" when moving the bullet. Also once it gets to point x2,y2 it should continue on at same angle if no obstructions. From all these algebra classes I can calculate slope of that line, but after that, not sure what to do. The bullet needs to travel alone that line.
dime
@dime - trigonometry will give you the answer, although in this case it's a pretty simple rise-over-run equation. For every (x2-x) change in X, you have a (y2-y) change in Y. For this specific case, you could also take a look at [Bresenham's Line Algorithm](http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm), which shows you a method of drawing "straight" lines of arbitrary slope on a raster (pixel-based) display.
dash-tom-bang
You should read the first chapter of a first-year physics textbook: kinematics. In this case, you should find a parametric equation of the line: x(t) = x1 + (x2-x1)*t and y(t) = y1 + (y2-y1)*t. Notice at t=0 (x,y)=(x1,y1) and at t=1 (x,y)=(x2,y2). If you pick a value of t between 0 and 1, you'll be at a point on the line between those endpoints. (and t>1 or t<1 will be on the line beyond the endpoints)
Jonathan
+3  A: 

There are a few points here:

1) The statistics suggestion is a complete misdirection, and this advice should be completely ignored, along with the person who gave it to you. Statistics is an interesting topic, but not at all useful in game programming (except maybe for a few esoteric approaches to esoteric topics, maybe, like, drawing clouds).

2) (Not that you seem to but...) it's not uncommon for programmers to make the mistake of assuming that they can just learn everything on the job, but most science topics (including math) can not be effectively learned this way. With these, one needs a much more structured approach, building an elaborate structure of ideas, with each new idea built on top of the previous. You could certainly program games with a few equations that you learned to use from a game programming book, but it's unlikely you'd ever have the ability to solve problems that you hadn't already seen solved somewhere else.

3) The best way to get comfortable with math is to solve lots of problems, and not on the computer, but with pencil and paper. For example, you can easily write a program to test that sin2+cos2=1, but to prove it, you need to understand it.

4) Of the topics you'll need, trig is the most time effective place to start. Geometry would be a bit useful, but probably not so much. Another useful topic is linear algebra. Calculus is also useful for calculating trajectories that have acceleration (and gravity), but it's a much bigger topic and involves so many new ideas that it's probably a bit difficult to pick up on your own. Maybe for this topic it's best to try to glean a few useful approaches and equations.

Final suggestion: I recommend starting with trig, and use a book that gives concise explanations followed by lots of problems that are solved in the back. For example, Schaum's Outline of Trig for $13, would probably be a good choice. You don't need to solve a every problem in the book, but work them until you're comfortable, and then move on.

tom10
@Lo'oris: Instead of just LMAO, how about posting your own answer or at least giving a useful counter example. Your comment gives me no confidence that you know what you're talking about. At the least, I would like to edit my answer, if it's wrong, but you comment doesn't give me much to go on.
tom10
You're right. **Probability** is everywhere in many games, so you have to know that pretty good (drop rates, attack/dodge chance, damage done, etc.); it is strictly related to statistics, so you have to know that too. **Statistics** is *per se* useful to figure out how to tweak those numbers when playtesting. Actually even in rare games without random chance (where you do not use probability), statistics is useful anyway to monitor what the players do.
Lo'oris
I totally agree with the specifics of what you say, and it's a good point, but I don't think it changes my answer. Basically, **incorporating randomness into your game does not mean that you are doing statistics**, and does not require a college course in statistics or a self-study equivalent, but instead, just few ideas that one can quickly figure out on there own. Also, although probability and stats are related topics, stats is “the science of the collection, organization, and interpretation of data” which is only used in games in the most trivial way.
tom10
User Experience testing will require probability and statistics, but it's not used very much at Actual Game Developers. There are some that care about the topic, though, but it's not most games (although it may be the lion's share of the money made in games with things like WOW likely having people focusing on these topics).
dash-tom-bang
+1 for learning on the job. I feel like I really got to understand (basic) calculus on the job, but if it hadn't been for those three terms of it at university I don't think I would have the understanding that I do. Same goes for linear algebra; I could do the work in school and then when I got into games there was a big WTF period of time 'til one day when it clicked.
dash-tom-bang