# Tagged Questions

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.

202 views

### How to move an object up and down like a wave?

I am trying to move my object up and down using cos and sin, but I have problem understanding how does the sin and cos work, so I can make my object move up and down like a wave frequently Init Time ...
93 views

### How do I smooth out of the effects of a too-sensitive control?

I have a game that takes input from a joystick. If you tilt the joystick right, the ship moves right linearly according to how much the joystick is tilted. So if you tilt the joystick twice as much ...
176 views

### How to detect collision between a camera and a mesh?

I am wondering how you would be able to extract mesh properties (i.e. faces, vertices, and vertex normals) and use them to create a collidable object, one that a camera can't go through ? I am using ...
40 views

### Find angle between two points in java [duplicate]

I am making a very simple game and want the hunter to shoot the dragon when the player touches on the screen. I want the arrow to be craeted at hunterPosition.x and hunterPosition.Y and move towards ...
186 views

### Circle to Circle collision - bad accuracy

Circle1 (blue) is moving and its X and Y bounds are the screen (meaning it bounces off the walls). Circle2 (black) is stationary. Circle1(blue) is supposed to bounce off of Circle2 without ...
80 views

### How to aim with a spaceship in 3D considering its angular momentum?

So I have a spaceship and I have 6 degrees of freedom. At a given moment the following vectors are known of the spaceship: Local forward. Local up. Local sideways (may be implied from the previous ...
134 views

### Math > Logic for a Logarithmic Score Meter

I'm trying to implement a score meter whereby I specify a maximum value (say 15,000) and I can render values on it in a logarithmic manner ie: +------+---+--+-++ +------+---+--+-++ |== ...
190 views

### Project collision shapes to plane for 2.5D collision detection

I am working on a top down 2.5D game. In the game anything that overlaps on the screen should be 'colliding' with each other regardless of whether they are on the same plane in the 3D world. This is ...
113 views

### Bouncing off a circular Boundary with multiple balls?

I am making a game like this : Yellow Smiley has to escape from red smileys, when yellow smiley hits the boundary game is over, when red smileys hit the boundary they should bounce back with the ...
123 views

### Isometric Movement in Javascript In the DOM

I am creating a game using Javascript. I am not using the HTML5 Canvas Element. The game requires both side view controlles, and Isometric controls, hence the movementMode variable. I have got the ...
337 views

### Quaternion LookAt for camera

I am using the following code to rotate entities to look at points. glm::vec3 forwardVector = glm::normalize(point - position); float dot = glm::dot(glm::vec3(0.0f, 0.0f, 1.0f), forwardVector); ...
290 views

### What algorithm to use to fill a KenKen square board with cages?

I am working on recreating KenKen, a popular math puzzle involving a blank grid that is divided into "cages". Each cage is just a collection of adjacent squares and has a clue which is generally a ...
55 views

For a while now I used PCSS for my shadow technique of choice until I discovered a type of percentage closer filtering. This method creates really smooth shadows and with hopes of improving ...
80 views

### Help with timebased scoring algorithm

Im trying to devise an appropriate scoring system for my game. The game in essense has a finite number of tasks to complete (say 20) and the quicker you complete these task, the more points you get. ...
429 views

### Derive a algorithm to match best position

I have pieces in my game which have stats and cost assigned to them and they can only be placed at a certain location. Lets say I have 50 pieces. e.g. Piece1 = 100 stats, 10 cost, Position A. Piece2 ...
328 views

### Slerping rotation mirrors

I rotate my game character to watch at the target using the following code: transform.rotation = Quaternion.Slerp(startQuaternion, lookQuaternion, turningNormalizer*turningSpeed/10f) ...
20k views

### How to develop RPG Damage Formulas?

I'm developing a classical 2d RPG (in a similar vein to final fantasy) and I was wondering if anyone had some advice on how to do damage formulas/links to resources/examples? I'll explain my current ...
153 views

### Vector normalization gives very imprecise results

When I normalize vectors I receive very strange results. The lengths of the normalized vectors range from 1.0 to almost 1.5. The functions are all written by me, but I just can't find a mistake in my ...
179 views

### JavaScript 3D space ship rotation

I am working with a fairly low-level JavaScript 3D API (not Three.js) which uses euler angles for rotation. In most cases, euler angles work quite well for doing things like aligning buildings, ...
102 views

### Automatically zoom out the camera to show all players

I am building a game in XNA that takes place in a rectangular arena. The game is multiplayer and each player may go where they like within the arena. The camera is a perspective camera that looks ...
870 views

### 2D helicopter game, how to create corridor walls?

I'm looking into adapting the classic "helicopter" game (i.e. http://www.addictinggames.com/helicopter.html), but I haven't yet figured out how to create the walls-generation engine. Any pointers ...
266 views

### The physics equation for a perpetual seesaw

I am trying to create a game that involves two or more people jumping on a seesaw and propelling each other in the air. I need help with the physics equations Assume no friction and no air ...
151 views

### How to Construct a Perspective Projection With 4 Vanishing Points

Is it possible to construct a projection matrix which will create a perspective with four (or more) vanishing points? This question have an OpenGL tag, but general insights are welcomed as well.
1k views

### Calculation of Inertia Tensors

Bit of a complex and lengthy question that, I'll admit, I don't quite understand very well yet so I will try and explain as best as I can. Short Version: Is there a general c++/physx formula out ...
215 views

### how to predict enemy postion to shoot bullet same kingdom rush

i'm doing a tower defense game same kingdom rush, enemy can run curve not only linearly. i found this link : 2D tower defense - A bullet to an enemy but this link use only for enemy run linearly. ...
72 views

### Displaying normals of a geometry

I have a rectangle which is created by 2 triangles and it is in x-z plane, and i have object on it. Now, the normals of two triangles (face normals) are y axis i.e. (0,1,0). I want to display normals ...
187 views

### Performing intersection testing in world's or object's space?

Am adding basic ray casting and collision detection for my game, also adding bounding volumes/collision mesh. Given that the ray is cast in world space and each mesh's node can track world ...
157 views

### How do I rotate a camera around the Y axis of the object it's looking at? [duplicate]

I'm making a camera that can currently rotate freely from the back to the front of a target object by giving it an angle and a distance. I do the above with the following code directionVector = ...
163 views

### Box2d making a body follow the mouse accurately

I am trying to make a box2d b2Body follow my mouse position. This is the code I am using at the moment but it is not performing very well: deltaPos = mousePos - body->GetPosition(); deltaPos *= k; ...
136 views

### Calculate when round object is inside an ellipse

I want to calculate in java when a circle is inside an ellipse. I drew an example below: For this particular problem, the top left corner of the field has the position 0.0f, 0.0f. The bottom right ...
100 views

### Convert global rotation into local rotation

I have an object in my game and I have its location, rotation and scaling in separate float[3]. The location rotation and scale are all on the global axis; these do not change based on the objects ...
307 views

### Uncharted 2 tone mapping and an eye adaptation

I found an example of uncharted 2 tone mapping on this site. Here is the code: float A = 0.15; float B = 0.50; float C = 0.10; float D = 0.20; float E = 0.02; float F = 0.30; float W = 11.2; float3 ...
884 views

### What's so different/complicated/useful about vectors?

Forgive me if this isn't considered a real question, but it is something I am genuinely confused about. I constantly hear other game developers talk about how using vectors are very useful, but also ...
368 views

### Make a fake random distribution?

Sometimes a "real" random event seems unfair and makes players frustrated. For instance a enemy has probability of 20% to cause double damage("critical hit"). Thus he could make 4 critical hits in a ...
164 views

### Use quaterions to move the camera direction according to mouse movement

I am trying to use quaterions to move the camera direction vector in the following way. This code is perfectly working glm::quat temp1 = glm::normalize( glm::quat((GLfloat)( ...
27 views

### Is there a transformation or set of transformations that can approximate a “radial scale”?

Is there a way to, with matrices, scale something as if someone were opening a Japanese fan? I'm at a loss of what to call it, so pointers towards avenues of research would be greatly appreciated. If ...
290 views

### GGX specular BRDF is way over 1!

Now, the classic Torrance derivation for roughened surfaces which Cook took into vectorized form yields the familiar parametrization of a specular BRDF where we have the NDF which decides how much ...
265 views

### How do I find the 2D direction to a 3D location?

I'm writing a 3D space flightsim, and I'm trying to display a 2D arrow on screen that points to the player's selected target. To clarify, the arrow needs to point in the direction that the player has ...
150 views

### Method for interpolation between 3+ quaternions?

I'm currently using spherical linear interpolation (slerp) to interpolate between two quaterions with a weighted value. But, I'm having a difficult time coming up with a method to interpolate between ...
316 views

### Unproject mouse position to tile — extremely jumpy position?

I'm trying to unproject the mouse position to get the position on the X-Z plane of a ray cast from the mouse. The camera is fully controllable by the user. Right now, the algorithm I'm using is... ...
103 views

### Velocity deacceleration working incorrectly

Basicly, I've tried to code velocity into my game, which works sort of. The deaccelaration works sort of, but not correctly. The problem is, that the positive values, decreases just fine and dandy to ...
84 views

### Translation over a vector trajectory

I'm working on a particle field system, where the particles can go from a point of the map, to another point of the map, using an angle (with sin and cos). By now, I can calculate the vector by ...
516 views

### Why does the order matter in multiplication of matrixes?

I stumbled on this question because I had the same problem with my camera, and changing the multiplication order worked. I ran into a similar problem when scaling a model. This code produced the ...
325 views

### Modular spaceship control

I am developing a physics based game with spaceships. A spaceship is constructed from circles connected by joints. Some of the circles have engines attached. Engines can rotate around the center ...
60 views

### Translate velocity to mouse curos position

I have particles, with a velocity (x and y) per tick. I would like to to make my cursor a gravity force, so particles fly to the cursor's position. How can I apply gravity (that is towards my cursor ...
272 views

### Shooting many bullets toward the mouse position

I try to shoot a bullet toward the mouse position by this code. float deltaX = mousePosition.x - (aircraft.getPosition().x + aircraft.getLocalBounds().width / 2); float deltaY = mousePosition.y - ...
579 views

### Combining rotation,scaling around a pivot with translation into a matrix

In short: I need to combine rotation (in the form of a quaternion), scaling around a pivot point along with translation into a transformation matrix. The long: I am trying to implement a proprietary ...
171 views

### Java moving image to where it is facing

I am trying to make an Asteroids type game. I searched and tried everything to move an image along its angle (as radiant). Using my knowledge of trigonometry I made the following calculation: x += ...