Tag Info

Hot answers tagged

5

While D3D doesn't support quad primitives, there's nothing in principle wrong with continuing to draw them as a triangle list. First thing to realise is that the index buffer used to simulate quads with a triangle list can always remain static, so you can create it once only (during startup), then just reuse it every time you wish to draw. The code to ...


5

There's no documented way to do this in Direct3D; it simply does not have support at the API level for quads as a primitive type. D3D doesn't have an extension mechanism like OpenGL does, but in some cases driver vendors support enabling certain kinds of "extended" features by passing certain combinations of invalid or otherwise-nonsense parameters to ...


3

You get the path the same way you'd move the object when you shoot it. Just have a tight loop that simulates the movement of the object and keep track of the position every so often. Now you have a list of positions, if you draw a dot at each position, you have a dotted line the represents the path of the object if it were to be shot from that angle.


3

You're doing it wrong - very inefficiently. Instead of rendering lightsources to your "lighting framebuffer", render the lighting contribution. That would be a soft disk centered at your light source instead of a single pixel. Example disk: ... and you can render that as a sprite! (Additive blending, clamp to 1 for best results). You can now bind that ...


2

The main importance in a case like this is to be able to use hardware acceleration and being able to upload your map to the GPU for smooth zooming. Usually using a game engine tends to restrict how you access the hardware, whereas using OpenGL/WebGL directly will not get in your way (but also won't assist you with common tasks either). In this case it ...


2

Byte56's answer is very good, especially for the example image given where simulating the movement of each "ball" in the line will work well. I'll give you an alternative idea however which might work better, or might be easier to implement if you are trying to work with a dashed line (with or without animation), something like -- -- -- -- Calculate the ...


2

height map can be the solution? A big b/w image to manipulate the map heights easly wilth an image editor (gimp?). A (selfmade) tool that transform a B/W image (i've done one in c#) into a matrix of floats and save/load it to file concerning your needs. If you need a memory buffer to keep a small part of your big file map , you can consider an aproach ...


2

I was able to solve this using trig instead of vector math. Here's how it looks as a triangle. Notice that since this is meant for a computer coordinate system, the y+ axis is down. Also the angles are as such: x+ = 0°, y+ = 90°, y- = -90°, and x- = ±180° Additionally, we know that line B's angle is ∠B = -10°. The speeds don't matter since they can be ...


2

One simple way of doing it could be to make a few alternate versions of the script and have different AI profiles for the enemies (just give them a random one when created). This way you could have one type that goes straight ahead like you have now, but also others that try to get the player by curving right or left. Maybe even one that makes some random ...


1

You shouldn't use a rotation angles if you can avoid it.* They are a bad representation of directions. If you choose to use them, you will need an inverse trig function. Instead of storing theta, store the pair (cos(theta), sin(theta)). You can combine rotations and directions using the multiplication rules of complex numbers, i.e. (a,b) * (c,d) = (ac - ...


1

First big thing to remember is that collider and trigger events should be called with the "collider other" in the brackets if we want to work with whatever caused the collision or trigger. // trigger event within rope OnTriggerEnter2D(Collider2D other) // send in the other collider (should always work) { if(other.tag = "tagUsedToIdentifyRope") // used a ...


1

Are all coins doing the same animation? You could make a method in the Animation class that takes a coin as an argument, then performs the animation on that coin. Then, on another class, you make a loop that traverses the coin list and calls the method in your Animation class, therefore animating each coin as you go through the list. You can also add delay ...


1

Unity 5 just came out, and they changed the API for a call like object.rigidbody Specifically, every component shortcut other than object.transform has been removed, since the Transform component is the only one that all objects have. All the other shortcuts only applied a fraction of the time. Now you need to access the Rigidbody component using ...


1

I tried to solve it following @david van brink comment. P: intersection point (unknown) S1: car's starting point(2,2 here) S2: canon's starting point(3,12 here) |v1|: car's velocity length (25 here) |v2|: canon ball's velocity length (120 here) a: angle between the car's velocity and the X-axis (10 degrees here... or Pi/18) b: angle between the canon ball's ...


1

Use tile editor to create the map. Normally those allow you to export the map in some format. Then create map loader for that map, that reads the exported file and create object from it, to your game. If you have to use ascii, split those to sections so that "first town" would be saved to txt file "firstTown.txt" and that would contain the number-to-tile ...


1

You can use an image. Each pixel will be a tile and each 32bit color will encode several values like alpha=0 means impassible. Then you can use any image editor that allows you to save in a lossless format and choose the exact color values.


1

This task can be surprisingly difficult in general; it is a variant of the Art gallery problem, and just like that problem, it is made dramatically harder with even slight complexities in the geometry. But if you're willing to accept a flawed, "good enough" solution, here's one: leave a "vision trail", and assess whether there is only one exit that is not ...


1

You don't need anything special to do this. You can "up-convert" a Vector2 to a Vector3 with z = 0 by writing: (Vector3)shapeIn[p]; This will give you your shape in 3D, oriented in the XY plane (vertically, facing the default camera position you'd get for a new scene). (0, 0) in the source shape will map to (0, 0, 0) in the scene. You can now use all the ...


1

I don't see any real problems with your implementation here, but I suspect your problem is buried in angleToPoint(). I couldn't find any mention of it in the CGPoint documentation, so I assume it's something you've implemented yourself. Make sure you're using atan2() or equivalent, not just atan(). However, it'd be easier not to use any trigonometry at all: ...


1

I figured it out! Physics cannot be used with 2D colliders like BoxCollider2D. I switched to Physics2D and everything works fine. Thanks!


1

Every point must be greater then 20 and less then 30 away from each other. Red is the Point. Purple is the radius 20 from point. If any point is placed here it means it is inside the radius of another point. Green is radius 30 from point. White is out side. No points should be placed here because it means that point will be 30 units away from any other ...


1

Your pixelOffset calculations are inconsistent... int pixelOffset = y + normX * 51; is different than... int j = x + normX; int i = y + normY; int pixelOffset = j + i * 51; One uses x * 51 + y and the other uses y * 51 + x. EDIT You are also reusing variable i and y. I think you want your blast circle to be based on your outer y value in addition to ...


1

Looks to me that your intersection code is not returning the correct position of impact. This could due that that when the game checks whether the bullet collide with the object, the bullet is already inside the barrier. You need to modify the intersection code to return the exact moment when the bullet hits the barrier.


1

Assuming case 1 means the center of the circle is in a lateral region, and case 2 means the center of the circle in a corner region, this approach has a problem. Specifically, when the circle is just barely into a corner region, the square is treated as suddenly larger. If the circle was grazing the square, it will suddenly be intersecting. The behavior ...


1

The first thing that comes to my mind would be to render your 3d graphics with a cel shader. I'm not too familiar with the technique, but basically, it makes your 3d models look cartoonish. I think some game companies put a lot of effort in this kind of technique to really give a nice look to their game and they really make it part of the artistic process. ...


1

Calculating the vector that points from a spring at point A = (x0, y0) to a spring at point B = (x1, y1) is simply: v = (x1 - x0, y1 - y0) Assuming no other forces acting on the player, then changing the player's velocity to some scalar multiple of v when they hit spring A would direct them to spring B. If another force like gravity is involved, then, ...



Only top voted, non community-wiki answers of a minimum length are eligible