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.
0
votes
1answer
59 views
2D vector to Quaternion
I have a 2D vector (with only X and Y), and my engine only supports orientation through Quaternions.
How do I translate a 2D vector to a quaternion?
The X and Y represent the direction (so X = 0 ...
1
vote
1answer
116 views
2D Island generator algorithm - chances of tile becoming land
I am developing my first island generator (in c#). I am using this algorithm as my basic idea :
http://www.funstormgames.com/blog/2012/09/procedural-island-generation-for-ludum-dare-24/
Basically ...
0
votes
0answers
46 views
Smooth Ramp to zonal harmonics
I have written in blitz3D some code to generate arbitrary 2D lighting lookup textures and I'm looking for a way to compress them. The idea is that they look rather smooth and low frequency, there must ...
2
votes
1answer
68 views
Implementing a time scale in game with fixed physics update
I'm currently putting together my game loop based on the "Fix Your Timestep" article at gafferongames.com. This is going fine, but I'm also trying to implement a 'time scale', i.e. a way to control ...
16
votes
3answers
403 views
How can I maintain a rectangular formation when units are added or removed?
I've got bots in a rectangular formation with rows and columns. A problem arises when a bot is added or removed from the formation. When this happens, the bots have to rearrange themselves so that the ...
0
votes
0answers
47 views
Follow sinus with absolute value
I would like to make an arm follow the sinus of the ball. When I add an absolute value to the ball (on the y axis) to get a more realistic bounce, the ball is going 2 times faster.
How could I ask ...
0
votes
1answer
46 views
Trying to convert as3 Matrix to C++ glm matrix
I am trying to convert a library called DragonBones to C++ Opengl which allows you to use Flash based skeletal animation. I'm almost done but I am running into a problem. I am trying to transform the ...
2
votes
0answers
58 views
Display and Hide CCSprite with Genie effect
I am new at cocos2D.
I started to learn cocos2D with simple game from http://www.raywenderlich.com/tutorials#cocos2d tutorial.
Now I'm crazy with animation, so now i want to display CCSprite as OSX ...
3
votes
1answer
93 views
Precalculate the position of a rotating Aircraft
To start honestly, this question is probably mostly handling math. But thats only the road I tried to go and failed miserably, so maybe theres a much more simple way to do.
Ok the game situation is ...
2
votes
1answer
68 views
Transforms in Box2D
I'm attempting to implement a camera in my game. I had it working for regular objects, but I began using Box2D and obviously things changed a bit. I have a Body object that I want to draw at the ...
0
votes
2answers
39 views
Need transform matrix to translate the center of the view to a custom position within the target texture
My problem is as follows:
I want to use a single render target texture for drawing 16 viewports where I want to display the 16 different combinations of the marching squares algorithm with my 3D ...
2
votes
0answers
53 views
Stereo 3D: drawing 2D elements at apparent screen depth
I'm developing an application making use of DirectX11's stereoscopic features. At such I am not relying on nVidia's automatic implementation. That means I have to replicate a way to render 2d elements ...
-3
votes
0answers
116 views
How should I go about coding my own matchmaking algorithm?
I'm currently thinking about adding my own matchmaking algorithm to my game (the games are 1v1). I'm probably going to go with a modified ELO for my needs but this is not what I'm wondering about ...
1
vote
1answer
84 views
Determining explosion radius damage - Circle to Rectangle 2D
One of the Cocos2D games I am working on has circular explosion effects. These explosion effects need to deal a percentage of their set maximum damage to all game characters (represented by ...
1
vote
0answers
51 views
Surface normal to screen angle
I've been struggling to get this working. I simply wish to take a surface normal and convert it to a screen angle.
As an example, assuming we're working with the highlighted surface on the sphere ...
4
votes
1answer
117 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 ...
4
votes
3answers
103 views
Matrix multiplication - Scene Graphs
I wrote a MatrixStack class in C# to use in a SceneGraph. So, to get the world matrix for an object I am suposed to use:
WorldMatrix = ParentWorld * LocalTransform
But, in fact, it only works as ...
1
vote
0answers
64 views
Premultiplying matrices with Perspective destroys them
If I apply world_to_camera, perspective and camera_to_screen to my mesh, everything is okay. But if I premultiply given matrices (i.e. transform = world_to_camera * perpective * camera_to_screen) ...
6
votes
2answers
237 views
Procedural dungeon generation. No corridors, color key doors
I am curious how dungeons like the one in Runescape dungeoneering skill are generated. They basicaly have a 10x10 grid. So theres 100 rooms total. There's starting room and exit room. And each one are ...
0
votes
1answer
61 views
Which is the right way to build a OpenGL Projection Matrix
This time I'm trying to learn the core of matrix transformations. I dont like the idea to using a Math library and dont understand what is hapening on background, because this I'm having some ...
1
vote
1answer
75 views
Making Ball Fling in a Curve Direction
I was wondering how to figuring out how to slice a ball (banana kick) by flinging it curve-ways. However, according to the LibGDX's gesture listener, the method for flinging only focuses on a straight ...
2
votes
0answers
58 views
Quaternion to direction vector - flipping
I've kinda solved this myself by adapting the Camera::setDirection code from OGRE to work for my need:
Now I have the following code:
Vector3 boneDir = getBoneWorldOrientation(mEntity, mHips) * ...
0
votes
0answers
33 views
How do I fire a projectile at where an object will be located in the future? [duplicate]
I'm making a tower defense game where the towers are shooting projectiles at enemies. I do not want to make the projectiles homing, and I want to make sure that when a tower fires a projectile, it ...
0
votes
2answers
72 views
Is this Rotation Matrix correct?
I'm having heavly troubles with setting up a View Matrix and a Projection Matrix. It simply doesnt work. So I think my problem is related to my rotationMatrix function. I'm using this tutorial to ...
0
votes
1answer
141 views
How can I remove the view and projection matrix from ray position to get only the ray model?
I've got a little problem with my picking module and I need your help.
I have a method to project a ray from the camera to a fixed point when I click somewhere. The computed ray looks good, it go to ...
1
vote
2answers
78 views
How do I derive the angular movement for a craft
I have the regular (linear) motion implemented like this:
class Craft{
...
Vector location, velocity, acceleration, angularVelocity, angularAcceleration;
...
//the move class responsible for linear ...
2
votes
1answer
53 views
Getting half plane direction relative from cam position
Im implementing certain Camera movements in my turn based games. I'm able to place and rotate the camera between two units that attack each other. However it will always move to the same "side". Which ...
9
votes
4answers
248 views
Generate equal regions in a hex map
Taking for example large (X by Y) hex map, how can I divide the map into N regions of connected hexes to simulate countries?
The goal is to generate a hex map that looks like a real life map with ...
1
vote
1answer
101 views
How good do I have to be at Math to create a 3D game using three.js? [closed]
A question I've often had, how good at Math do I need to be to create 3 dimensional games? I get along with 2d games just fine. I understand everything I'm doing without problems after practise. ...
3
votes
1answer
147 views
How to account for acceleration when aiming projectiles?
How do I aim a constant speed projectile to hit a target if there is a constant acceleration vector acting on it? (For example, the wind and gravity from Worms.)
1
vote
3answers
77 views
Move from point a, to point b, and determine the accuracy
Let's say I have a circle at point a (0,0), and I wish to move it to point b (23,58), whatever, how can I accurately do this with a speed variation if I wanted. (I'm doing this in javascript).
Every ...
1
vote
2answers
150 views
Calculate object coordinates from window coordinates using inverse projection matrix
What I am trying to to is placing 3D Objects (A Sphere) in the world when I click there.
I am using a perspective projection so the first step after calculating the canonical clip coordinates from ...
0
votes
0answers
42 views
Opengl 3.2 Flickering after smooth animation?
Okay I am new to OpenGL I am getting an odd issue.
I am performing rotation on a bunch of triangles on a scene graph.
The rotation starts off really smooth everything is animating then much later you ...
0
votes
1answer
117 views
Drawing the same scene with perspective then orthographic projections
I have a scene that I'm rendering first with a perspective matrix. I then want to rerender it in a different viewport using an orthographic matrix for a top-down 2D view of the scene. I think I may be ...
7
votes
2answers
291 views
make a sphere rolling on a roulette mesh stop at predetermined place
I have a roulette and a ball(sphere) placed on it. When the game begins the roulette spins. The spinning of the roulette and gravitational forces on the ball makes it roll along the 3d roulette mesh.
...
3
votes
1answer
125 views
Matrix represents same rotation with different euler angles
I have Transform component storing it's rotation as Quaternion.
Transform has set/getEulerAngles (rotation order oy, ox, oz).
I want to rotate object in any direction but while testing I get ...
0
votes
1answer
133 views
Heightmap implementation in javascript question, a 2D water heightmap
I have a height map function from GPU Gems 2 Chapter 18, where they're generating a set of B/W pixels from this equation:
H(x,y,t) = Σi=0N h (
Axi x + Bxi,
Ayi y + Byi,
Ati x + ...
4
votes
1answer
215 views
Picking 3D with OpenGL ES 2
I'm trying to implement picking in my framework but I don't understand how I can do this.
I'm working with:
OpenGL ES 2.
GLM mathematic library.
What I have understand, picking can be made with ...
-1
votes
2answers
79 views
adding space between each bricks in breakOut [closed]
i am trying to create breakout. code below loop though my 2d array(map) and creates bricks. the problem is that i want to add 10 pixels space between each bricks. i was thinking to add ...
-5
votes
2answers
94 views
Should I negate a variable or use absolute value? [closed]
this is how i was chaning ball postion
if(...) //if ball goes to left of screen
dx = -dx
if(...) //if ball goes right of screen
dx = -dx;
i found some people using math.abs to move ball ...
0
votes
1answer
92 views
How to make healthbar size relative to hp
Like in most games with healthbars, the units in my game have a hp_bar object which is a frame, with a slightly smaller rectangle inside which should get smaller (and change color) as a unit loses hp, ...
0
votes
1answer
110 views
Need help with a complex 3d scene (using Ogre and bullet)
In my setup there is a box with a hole on one side, and a freely movable "stick" (or bar, tube). This stick can be inserted/moved through the hole into the box. This hole is exactly as wide as the ...
3
votes
2answers
132 views
What kind of projection is ScreenX=X/Z, ScreenY=Y/Z?
I have an existing class which transforms 3D vectors and projects them on a 2D plane (Camera). The code is all written in C without help from an external library.
To project a single vector (X,Y,Z) ...
2
votes
1answer
142 views
Negative scale in Matrix 4x4
After some rotations and to from quaternion conversions I get negative scale from Matrix 4x4, is it possible? I need that scale to draw sprite on screen so I get sprite flipped,
how to deal with this ...
0
votes
3answers
95 views
Keeping raycast on the same level
I want my raycast to end at certain height(red line). But as the game is 3D and the camera rotates I can't use a fixed magnitude. What I thought was a stroke of genius, I figured I'd project the ...
8
votes
2answers
322 views
Drone targeting
Imagine a "drone" and a target point on a 2d plane. There are eight parameters:
P = my position
Q = target position
V = my velocity
I = my moment of inertia
w = my angular velocity
s = my angular ...
2
votes
1answer
91 views
Rotation independent rotation
I came up with some cube rotating, but I could not make it smooth and easy to use because as the cube turned - the keys that handle the turning changed their purpose. Link to demo. The demo rotation ...
4
votes
2answers
161 views
Getting an angle in degrees from north
This may have been asked already, but I was unable to find it, because I don't really know what I'm looking for. I drew a picture:
I need theta. I've seen various solutions using Vector.Dot, and ...
3
votes
1answer
150 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 ...
0
votes
0answers
53 views
Going from point a to b through a curve using “gravity” [duplicate]
I have enemies and when they die they spawn an energy ball with a given velocity. I want to move this ball to the player using "gravity" to create a curved path. I have a version of the function but ...