Tagged Questions
4
votes
5answers
184 views
Implementing vector based movement in a 2d environment
Good evening.
I apologize if the title is a bit vague, I really could not come up with anything better.
I am currently reading a book called the nature of code and as a side project, I am working on ...
3
votes
3answers
255 views
Tetris - Rotations using Linear Algebra (Rotation Matrices)
I'm making Tetris in Java and am at the point of rotations... Originally I was hardcoding each rotation:
if (direction.equals("right")) {
if (shape.equals("Bar")) {
if ...
0
votes
1answer
119 views
Character movement relative to cursor position
I want my top-down shooter character to move towards the mouse when pressing the up arrow and strafe relative at right angles to it when pressing the left and right arrow keys.
I can't figure out how ...
-1
votes
3answers
313 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, ...
1
vote
2answers
587 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 ...
4
votes
1answer
1k views
How do I rotate a sprite so that it is 'pointing' in the direction it is moving
I have a sprite, e.g a missile, heading in a certain direction (using a velocity vector).
How do I figure out its how much to rotate it so that it gets drawn 'pointing' in the direction it is ...
1
vote
1answer
182 views
Viewport.Unproject - Checking if a model intersects a large sprite
Let's say I have a sprite, drawn like this:
spriteBatch.Draw(levelCannons[i].texture, levelCannons[i].position, null, alpha, levelCannons[i].rotation, Vector2.Zero, scale, SpriteEffects.None, 0);
...
2
votes
1answer
279 views
android game-logic for shooter
Im creating a 2d game for android.
I'll just get right to it. I have a sprite controlled by a joystick that needs to shoot, sofar Ive managed to get direction and movement on my bullet, but then I ...
2
votes
2answers
377 views
android 2d bullet-spawn (shooting)
This will be a quick question since Im pretty sure I'm overlooking something small that I for some reason cant see.
My sprite is moved using a joystick, and I want my sprite to be able to shoot. I've ...
2
votes
6answers
973 views
How to implement object velocity as a vector
I'm working on a Breakout game, and want to change the ball's movement code from how I currently do it, to something based on vectors (as I feel learning and implementing movement based on vectors ...
5
votes
3answers
611 views
Split a 2D scene in layers or have a z coordinate
I am in the process of writing a 2D game engine, and a dilemma emerged. Let me explain the situation...
I have a Scene class, to which various objects can be added (Drawable, ParticleEmitter, ...
1
vote
1answer
397 views
Transform 3d viewport vector to 2d vector
I am playing around with 3d transformations and came along an issue.
I have a 3d vector already within the viewport and need to transform it to a 2d vector. (let's say my screen is 10x10)
Does that ...
1
vote
2answers
1k views
Calculating the 2D edge normals of a triangle
What's a reliable way to calculate a 2D normal vector for each edge of a triangle, so that each normal is pointing outwards from the triangle?
To clarify, given any triangle - for each edge (e.g ...
3
votes
4answers
625 views
Is it better to track rotation with a vector or a float?
In XNA, you can see that to draw a rotated sprite with SpriteBatch, you'll need a float describing the angle in radians.
I'm used to making games in OpenGL. I just want a rapid prototyping ...
4
votes
1answer
471 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, ...
19
votes
2answers
1k views
Calculating the rotational force of a 2D sprite
I am wondering if someone has an elegant way of calculating the following scenario.
I have an object of (n) number of squares, random shapes, but we will pretend they are all rectangles.
We are ...
4
votes
2answers
1k views
How to calculate the vector of an interception?
Given are a twodimensional space, and 1 friendly spaceship standing still, one foe is moving NOT directly to the friendly ship with known actual position, speed and direction.
The friendly ship wants ...
5
votes
1answer
952 views
Rotate object to face player
This is probably a simple vector question, but I'm not sure how to do it.
I have an object at vector position (ox,oy). Potentially every update, the user walks around the screen, and will be at ...
2
votes
1answer
363 views
Calculating camera zoom value (top-down)
I need some help in 'camera maths'. I have a birds eye view of two characters. One character is static and the other can move. I would like the camera to always show both characters in full and, in ...
12
votes
4answers
8k views
How can I calculate the angle between two 2D vectors?
I am working on some movement AI where there are no obstacles and movement is restricted to the XY plane. I am calculating two vectors, v, the facing direction of ship 1, and w, the vector pointing ...
