Arithmetic, geometry, calculus, and all else which resolves the number-crunching necessary in a game. Math questions are those that deal with the formulae and calculations used by the game in various parts.
4
votes
3answers
242 views
How to get distance from point to line with distinction between side of line?
I'm making a 2d racing game. I'm taking the nice standard approach of having a set of points defining the center of the track and detecting whether the car is off the track by detecting its distance ...
4
votes
2answers
296 views
Predictive firing (in a tile-based game)
I have a (turn-based) tile-based game, in which you can shoot at entities.
You can move around with mouse and keyboard, it's all tile-based, except that bullets move "freely".
I've got it all ...
9
votes
1answer
387 views
Algorithm to shoot at a target in a 3d game
For those of you remembering Descent Freespace it had a nice feature to help you aim at the enemy when shooting non-homing missiles or lasers: it showed a crosshair in front of the ship you chased ...
1
vote
2answers
162 views
How to offset particles from point of origin
Hi I'm having troubles off setting particles from a point of origin. I want my particles to spread out after a certain radius from a the point of origin. For example, this is what I have right now:
...
1
vote
2answers
218 views
Tangent to a circle through a point
I'm trying to figure out how to calculate the following angle:
I know center (p1) and radius (r) of a circle. Given a point p3 I want to calculate the angle a such as the tangent (tan) of the circle ...
3
votes
1answer
199 views
D3DXMatrixDecompose gives different quaternion than D3DXQuaternionRotationMatrix
In trying to solve this problem, I tracked down the problem to the conversion of the rotation matrix to quaternion. In particular, consider the following matrix:
-0.02099178 0.9997436 -0.008475631 0
...
2
votes
2answers
276 views
Calculating the correct particle angle in an outwards explosion
I'm creating a simple particle explosion but am stuck in finding the correct angle to rotate my particle. The effect I'm going for is similar to this:
Where each particle is going outwards from the ...
5
votes
2answers
265 views
How to make my character slide (not bounce) off a slope
My character needs to slide and not bounce off a slope.
The solutions I found here use a Reflection vector, but they make my character bouncy when they run downwards a slope.
var reflectVector = ...
3
votes
2answers
297 views
How to derive euler angles from matrix or quaternion?
Currently working on steering behavior for my AI and just hit a little mathematical bump.
I'm in the process of writing an align function, which basically tries to match the agent's orientation with ...
0
votes
1answer
225 views
What are the steps taken by this GLSL code?
1 void main(void)
2 {
3 vec2 pos = mod(gl_FragCoord.xy, vec2(50.0)) - vec2(25.0);
4 float dist_squared = dot(pos, pos);
5
6 gl_FragColor = (dist_squared < 400.0)
7 ? ...
0
votes
1answer
173 views
Getting Center and Radius of Irregural Object
I have drawn an asteroid object manually , and would like to get its center/radius by a specific equation. I think I can get them by calculated and hard-coded values.
The code to draw the asteroid:
...
2
votes
2answers
319 views
Explaining Asteroids Movement code
I'm writing an Asteroids Atari clone, and I want to figure out how the AI for the asteroids is done.
I have came across that piece of code, but I can't get what it does 100%
if ...
3
votes
2answers
205 views
Rotating voxels in 3d space amongst the x axis
I have a very simple voxel engine and so far it works based on coordinates, e.g. x, y, z. I was wondering if there is a formula for rotating groups of voxels/coordinates from the x axis(e.g. [0, 1, ...
8
votes
2answers
290 views
Render 3d object to 2d surface (embedded system)
i am working on an embedded system of a sort, and in some free time i would like to test its drawing capabilities.
System in question is ARM Cortex M3 microcontroller attached to EasyMX Stellaris ...
-1
votes
1answer
279 views
Breakout… Getting the ball reflection X angle when htitting paddle / bricks
Im currently creating a breakout clone for my first ever C# / XNA game. Currently Ive had little trouble creating the paddle object, ball object, and all the bricks. The issue im currently having is ...
0
votes
1answer
143 views
moving in the wrong direction
Solution:
To move a unit forward:
forward = Quaternion(0,0,0,1)
rotation.normalize() # ocassionally
...
pos += ((rotation * forward) * rotation.conjugated()).xyz().normalized() * speed
I think the ...
0
votes
1answer
48 views
applying rotation and speed to move user
My player has a position (vec3), rotation (quaternion) and speed.
I have a fixed time step. At each tick, I work out from key-state etc what rotation and speed adjustments to make.
How do I now ...
3
votes
1answer
191 views
Limit rotation heading by cone/angle
What is a fast way of limiting the heading vector to a certain angle so that it turns in greater distance relative to the limit.
A smaller cone/angle should make the object take a far bigger curve to ...
1
vote
1answer
138 views
Can't work out how matrix is applied to 2D vertices
I have a texture, some 2D vertices, and a matrix. The matrix is used to calculate the texture coordinates for each vertex, but the problem is that the matrix comes with absolutely no documentation and ...
-5
votes
1answer
117 views
is object facing another object or facing it in opposite direction?
In 2d, in degrees, negative degrees possible.
What I want is to rotate the player to face the same direction as the door before opening it, but when I'll do the same again now from the opposite side, ...
2
votes
4answers
397 views
Math and physics, where to start?
the only math I know how is to add the velocity to position. Thats it. i would like to know how to do more stuff, physics, collision detection with stuff other than perfect circles, etc.
But where ...
0
votes
2answers
768 views
OpenGL matrix vs DirectX matrix
I'm working on an animation and model exporter from Maya to use within my game. Currently, models work perfectly, and animations have some issues with the joints. Since Maya works in an OpenGL ...
14
votes
1answer
1k views
How to convert mouse coordinates to isometric indexes?
I draw isometric map with tile 64x32:
const Offset = 160;
int X, Y;
for (int a=0; a < 6; a++)
for (int b=0; b < 6; b++) {
X = a * 32 - b * 32 + Offset;
Y = a * 16 + b * 16;
...
0
votes
0answers
206 views
Java Collision Detection of a Slope using a Gradient [closed]
Im testing out collision detection for a game, The ball is traveling and i need to know when the ball hits a sloped line.
For this example i have used the whole screen, with a sloped line going from ...
0
votes
2answers
478 views
Calculating angle between two vectors to steer towards a target
I have been trying to implement a path following steering behaviour for AI in a 2D racing game.
I have two vectors:
futurePosition represents the predicted future position given the car's current ...
1
vote
0answers
62 views
obb vs obb and resolve/response for 2d space game [duplicate]
Possible Duplicate:
OBB vs OBB Collision Detection
How can i detect if an rotated obb intersects another
rotated obb and resolve it so both obb objects dont go further into each other.
I ...
5
votes
2answers
377 views
How to render metaballs?
How to render metaballs?
I am a Python programmer familiar with the Panda3d and Blender3d APIs. My math kinda sucks, but I know enough to write game logic code and procedural model generation code, ...
6
votes
3answers
471 views
Can a straight line be called a polygon?
According to the definition of Polygon, If a Poly-line's first and last points are connected then it is called Polygon. See the image below. I have P1, .... P5 Polyline. If I draw a line from P5 to ...
1
vote
1answer
219 views
Recreating Doodle Jump in Canvas - Platforms spawning out of reach
I have started to recreate Doodle Jump in HTML using Canvas. Here's my current progress. As you can see, if you play it for a few seconds, some platforms will be out of the player's reach. I don't ...
1
vote
1answer
872 views
global transform to local transform?
If an object is attached to another one and you need to set its position, rotation and scale in global space, what do you do to get the local versions of these values, knowing the same values for the ...
0
votes
3answers
320 views
Learning math from the basic to become a game programmer [closed]
Hi i want to become a game developer. Im currently doing some web programming. I want to learn
game programming. Im not good in math thats why i decided to learn from basic math to be sure i will not ...
0
votes
1answer
353 views
rotate opengl mesh relative to camera
I have a cube in opengl. It's position is determined by multiplying it's specific model matrix, the view matrix, and the projection matrix and then passing that to the shader as per this tutorial ...
0
votes
1answer
210 views
Why is std::atan2 returning -0.0?
Really? Negative zero?!
double Vector2D::GetFacingAngle(const Vector2D& target, const Vector2D& source) {
a2de::Vector2D facingVec(Vector2D(source) - Vector2D(target));
//Negating ...
3
votes
3answers
885 views
Get angle in radians given a point on a circle
I'm working on a dial that rotates around a circle.
This dial should lets you mousemove anywhere in a circle to adjust the position of the dial to a point on the circle with the same angle as the ...
2
votes
2answers
366 views
Rotating an object smoothly
I'm trying to rotate a ship in an asteroid game. What I'm doing is creating a float angle variable and at each time I press left or right buttons, I increase and decrease it, and in the drawing ...
2
votes
1answer
223 views
Detect mouse click on a bezier curve's neighborhood
I'm developing a game in HTML5 and JavaScript using Canvas API for drawing graphics. I want to detect if the user has clicked on a bezier curve which has the line width of 20 pixels (something like ...
4
votes
3answers
138 views
Determine inventory item position shape
Not a great title but couldnt think of a shorter way to describe it.
I am trying to think of the best way to determine the shape of items placed in the players inventory. I guess the best examples ...
1
vote
2answers
272 views
Aligning bullet's position in Asteroid Game
I'm writing an asteroid game and I would like to align the bullets on the ship's tip. I also want when the ship fires, the bullet gets the same orientation(angle, direction) of the ship and also be ...
5
votes
5answers
294 views
How to convert a number from one min\max set to another min\max set?
I'm doing terrain generation and I have a perlin library that is giving me random numbers between -1 and +1. I want to convert this to the scale of 0-255. What is the proper way to do this?
5
votes
1answer
300 views
Predicting physics/trajectory for pool/billiards games
I'm thinking of making a quick proof of concept of a billiard-style game mechanic, where the player has perfect information of what is about to happen.
Here's a good example:
I'm only mildly ...
4
votes
3answers
314 views
Convert point to its barymetric coordinates
I'm making a 2.5D game engine (in JavaScript) and I'm trying to get it to detect whether a block is under the cursor. This would be a simple task were it restricted to single-level isometric ...
0
votes
2answers
170 views
Determining my playable area/field of view
Contrary to what I found searching for the answer, I'm not trying to see whether a character is in view of another character. What I need to find out is the size of the field of view. This is because ...
0
votes
2answers
335 views
Asteroids Ship Movement
I have read source code of asteroids game. I want to know why when updating the ship's position in X, and Y Axis, we must write it in sin and cosine of the current angle. Is it angular velocity ? why ...
1
vote
1answer
343 views
How can I snap a game object's position to a grid?
I'm making a game that involves "falling block" gameplay elements. The problem is, I'm not quite sure how to make it so that the blocks will snap to some kind of grid, in other words, I'm not sure how ...
1
vote
3answers
219 views
Inverting matrix then decomposing gives different quaternion than decomposing then inverting the quat
I'm getting different signs when I convert a matrix to quaternion and invert that, versus when I invert a matrix and then get the quaternion from it:
Quaternion a = Quaternion.Invert(getRotation(m));
...
-1
votes
2answers
262 views
How should I learn about collision detection?
If I want to use physics engine for my game then how should I go to learn collision-detection algorithms?
When I read AI book for games, the book talks about collision detection, so I want to learn ...
1
vote
2answers
170 views
How can I determine the direction of turn?
I want a function that gives me the turn direction for my object (1 or -1)
I have two angles
1 - current rotation(A)
0 <= A <= 360
2 - target rotation(B)
0 <= B <= 360
int turnSide ...
2
votes
1answer
164 views
Electricity and Magnetism: Relevant?
The computer science major at my university requires that I take a sequence in either biology, chemistry, and physics, plus an additional natural science course (which I might fill with meteorology). ...
1
vote
1answer
220 views
Blending colors on Surfaces in PyGame?
So I'm making a game in Python and PyGame. I have aliens and blocks that each adopt one of several colors; rather than make several copies of them in different colors, I plan on making the sprite ...
1
vote
3answers
374 views
Create acceleration with direction
I want to move my object with an acceleration in the proper direction. I'm not good at math so I need some help. The example in Game Maker is:
friction = 0.3;
direction = 180;
speed = 5;
But I'm ...

