# Tagged Questions

82 views

### Code explanation

Can someone please explain whats going on in this code written by Paul Irish I did not understand the draw(). function draw() { var time = new Date().getTime() * 0.002; var x = Math.sin( ...
481 views

### How do I convert from the global coordinate space to a local space?

Given an entity named EntityA, I want to define a local coordinate space, where the position of EntityA is the origin, its heading vector is the X axis, and the normal of the heading vector is the Y ...
197 views

### How to make a projectile align correctly with the entity that shot it

I'm developing a 2D game. In the game, all entities can rotate 360 degrees. Each entity holds an angle value, and every frame it is drawn rotated around it's center by it's current angle value. For ...
47 views

### Resolving penentration after collision using Separating Axis Thereom

I implemented collision detection in my game using SAT. The detection works, but I'm trying to use the algorithm to figure out the penetration vector of the two OBBs and push them apart (before doing ...
92 views

### Sun & Moon Movement

I'm creating a 2D HTML5 Canvas Game and am stuck on how to go about animating my Sun & Moon. The current setup is basically setting the moon at -1024 on the X-axis and the sun at 0 and animating ...
74 views

### Implementing Camera Zoom in a 2D Engine

I'm currently trying to implement camera scaling/zoom in my 2D Engine. Normally I calculate the Sprite's drawing size and position similar to this pseudo code: render() { var x = sprite.x; ...
2k views

### How can I Intercept object with a circular motion

I am creating a 2d space game and need to make the spaceship intercept a planet. I have working code for straight line intercepts but cannot figure out how to calculate the planets location in a ...
109 views

### Moving turret aiming at moving target

I've found this post Turret Aiming Formula on Reddit and a nice answer a while back. The solution in the answer works great for still sanding turrets but is almost unusable for moving turrets since ...
72 views

### Field of view determination with partially opaque cells

I'm currently implementing the field of view of a player in a 2D-grid based game. I've chosen a standard ray tracing algorithm because he really fits the features needed in my game. However, the ...
57 views

### how to do picking in 2d lwjgl

I searched the whole internet, but I couldn't find something useful. How to do picking (like ray picking) in lwjgl in orthographic mode (2d)? I think this is less confusing than picking in 3d, but I ...
473 views

### Algorithm for randomly generating reachable platforms

I want to randomly generate reachable platforms on the fly for a 2D game. Right now, I am just creating platforms at random x,y positions. Only 4 platforms can exist at once, so once the 5th one is ...
38 views

### Best method for selecting points from a point set - path distance

having a big set of points and a polygonal path what is the best way to select a set of points that are at a certain distance or smaller from the path? Or do I need to iterate thru all points on each ...
227 views

### Square Grid Polygonal Terrain Query algorithm?

I have a square, fixed-grid terrain with one terrain type per grid unit in my game, and I want to do an arbitrary polygonal terrain query which returns all of the grid units enclosed/intersected by ...
131 views

### What are the correct angles in the Top-down perspective?

In the following picture it says that in the Top-down perspective the angles are 90°, but if it would be 90° then you shouldn't see the front of the building and the roof at the same time... So what ...
598 views

### Can I jump from A to B?

I'm making some rudimentary AI for my side-scroller and I need to know whether an AI unit can reach point B from point A simply by taking a jump. Flight trajectory of my characters is a bit unusal as ...
299 views

### Convert atan2 value to standard 360-degree-system value [duplicate]

Lets say I'm using atan2 to get the angle between two vectors. atan2 gives a value in radians. I convert it to degrees using a built in function in Java. This gives me a value between 0 and 180 ...
547 views

### How do I use the dot product to get an angle between two vectors?

I am learning to use normalized vectors in my games. I've learned that in order to know the angle between two vectors, I can use the dot product. This gives me a value between -1 and 1, where 1 ...
425 views

### Calculating 2D Physics Prediction of Shot Angle with Moving Velocity of both targets

I currently have the math right to hit a moving target with 99% accuracy as long as I don't move. When I start moving the aim is nearly 80%, it should also be 99% accuracy because the target is moving ...
107 views

### very simple math destination and speed calculation

My player goes to (destinationX, destinationY) His position is: (x,y) and the player has an update event function update() { this.x = this.x + dx; this.y = this.y + dy; } what is the formula ...
194 views

### How can I implement jumping in a 2D game using bounding box collision?

Problem: I'm trying to implement basic jumping to my 2D game engine, but have failed several times. Basically what I've done so far is disabling gravity and using a separate function moving the player ...
231 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 ...
394 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 += ...
265 views

### How do I get the areas enclosed by an arbitrary 2D shape?

In my game I want users to be able to draw arbitrary 2D shapes of any length around game objects. The shapes must be closed and drawn with a single stroke that does not overlap. For example: I ...
782 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 ...
149 views

### Rotate 2d sprite towards pointer

I'm using Crafty.js and am trying to point a sprite towards the mouse pointer. I have a function for getting the degree between two points and I'm pretty sure it works mathematically (I have it under ...
98 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 ...
782 views

### 2D car physics and high speed turning

I've been looking at the following page, which has been very helpful: http://www.asawicki.info/Mirror/Car%20Physics%20for%20Games/Car%20Physics%20for%20Games.html but have come into problems with the ...
960 views

### 3D isometric depth sorting

How is it possible to depth sort tiles and objects in an isometric environments without any limitations? I've been researching this for a while now and there seems to be no publicly available answers ...
733 views

Possible Duplicate: How to convert mouse coordinates to isometric indexes? Okay, I apologise in advance if I make no sense here. Basically, I've got a simple application that takes in a ...
347 views

### How to do perspective projection “parallax” but without changing the scale or offset of objects?

Hello everyone I have this problem that I have tried everything I could think of. The problem: I am making a 2D game with parallax effect but I am using 3d space so am not simulating the parallax but ...
119 views

### Find the footprint of an isometric entity

I'm working on making a 2D isometric engine in Java. I'm getting into collision detection and I've hit a bit of a problem. Characters in-game are not restricted to movement from tile to tile - they ...
70 views

### Retrieve outer most points on a 2d graph

G'day everyone, I have a 2d graph which has some points plotted on it. What I need to do is get only the outer most points so that I can connect them up (isn't really relevant). What I can't seem ...
2k views

### Scale a normalized 2D vector always to the same length

For any normalized 2D vector, except for ( 0, 0 ), how would I scale the vector to always be the same length? For example: int length = 10; vector v = vector( 0.1, 0.5 ); vector v2 = vector( 0.3, ...
1k views

### Line Intersection from parametric equation

I'm sure this question has been asked before. However, I'm trying to connect the dots by translating an equation on paper into an actual function. I thought It would be interesting to ask here instead ...
989 views

### Re-create 2D side-on wave effect from Worms game

I'm trying to recreate the waves/water effect from Worms ( see here http://youtu.be/S6lrRqst9Z4?t=31s ) From what I understand its not actually a sprite, its procedurally generated by something like a ...
325 views

### Point inside Oriented Bounding Box?

I have an OBB2D class based on SAT. This is my point in OBB method: public boolean pointInside(float x, float y) { float newy = (float) (Math.sin(angle) * (y - center.y) + Math.cos(angle) * ...
1k views

### How can I generate a navigation mesh for a tile grid?

I haven't actually started programming for this one yet, but I wanted to see how I would go about doing this anyway. Say I have a grid of tiles, all of the same size, some traversable and some not. ...
2k views

### Is it possible to map mouse coordinates to isometric tiles with this coordinate system?

I'm trying to implement mouse interaction in a 2D isometric game, but I'm not sure if it's possible given the coordinate system used for tile maps in the game. I've read some helpful things like ...
170 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 ...
245 views

### Constrained/penalized distance function

Assume a character is located on a n by n grid and has to reach a certain entry on that grid. Its current position is (x1,y1). Also on the same grid is an enemy with coordinates (x2,y2). Each step ...
2k views

### How to move a line of sprites in a sine wave?

So, I'm spawning a horizontal line of enemies that I would like to have move in a nice wave. Currently I tried: Enemy.position.X += Enemy.velocity.X; Enemy.position.Y += ...
4k views

### Basics of drawing in 2d with OpenGL 3 shaders

I am new to OpenGL 3 and graphics programming, and want to create some basic 2d graphics. I have the following scenario of how I might go about drawing a basic (but general) 2d rectangle. I'm not ...
535 views

### Trying to understand 2D vector -> projection space conversion

I'm trying to understand how I can transform 2D vectors (x, y) to projection space. Something hasn't quite clicked for me yet. As per my previous question, here's the effect I'm trying to achieve: ...
3k views

### How to calculate shot angle and velocity to hit a moving target?

I am developing a 2D Android game and I am making an aiming algorithm for AI projectiles to hit enemies either following a path, or free moving. At the moment it just calculates where the target will ...
2k views

### Matrix for 2D perspective

I'm trying to determine whether what I'm attempting to achieve is even possible mathematically. I'm obviously not a seasoned game developer so I'm having trouble even coming up with the terminology to ...
344 views

### How to draw equal length line stripes on a parabola?

Simply put I'm making a basketball game. I'm using these equations to predict the ball position and it works fine: x = vx * t y = vy * t + 0.5 * gravity * t * t But I can't find a way to draw equal ...
672 views

### Relating a point after an image is panned and zoomed

For Android, let's say you have a image of a map that you draw inside your view. On this map there are many, many "hot spot" locations where you want your user to be able to select. Given that there ...
1k views

### What is a good way to determine if a vector is between two other vectors?

I could operate with the angles, but I do not have the angles calculated yet (and would like to avoid having to do that). It would be possible to calculate and cache the local-coordinate-frame angles, ...