Tag Info

New answers tagged

1

Here's one very simple way to do it: package; import flixel.FlxG; import flixel.FlxSprite; class Player extends FlxSprite { public static inline var VELOCITY:Float = 4; public function new() { super(); // enforce subpixel-rendering for smoother movement pixelPerfectRender = false; } override public function ...


3

If vector (x,y) is a tangent vector of your curve, then the normal vector is simply (y,-x). So you just need to find a tangent vector, and it all depends on how exactly you define the curve. If your curve comes from a parametric representation p(t) = (x(t),y(t)) which is sufficiently continuous, then a good approximation of the tangent vector at t is, given ...


0

There are two questions here: How to assign the fewest number of checkpoints, so that every vertex is within at most T distance from some checkpoint. How to spread those checkpoints as evenly as possible. Question 1 turns out to have a linear-time solution: First, fix some root node arbitrarily. If this is a level, then some start/spawn point makes a ...


0

I propose a recursive pseudo code aproach to use while creating the tree Keep track of placed check points in a listlike structure: stacked_check_point_collection here comes the recursive method: create_node(last_check_point_distance, current_node) //recursive method add current_node to tree; if last_chec_point_distance > T { /*check other ...


3

Looking at your image gives an idea of how this should work. Two points are apparent: Endpoint nodes (those with only one connected neighbour) are the least likely to have checkpoints, since they share with the fewest other nodes; endpoint nodes will in fact only contain a checkpoint iff they are isolated as a degenerate DAG, i.e. they have no neighbours ...


0

Test only (projected.W < 0), not (Z < 0 || W < 0). In some clip space formulations (cough OpenGL cough), the visible range includes positive and negative Z values, whereas W is always positive in front of the camera and negative behind.


0

An example of a suitable system for a racing game ranking system can be seen in Microsofts Forza Drivatar System. The system in question is not used for ranking, but for simulating a players driving style. However I would assume that such a system could be employed in order to rank players on their driving. This is by no means perfect, however it is one such ...


1

Given the three vectors [camera position], [camera direction] and [object position]. Compute the dot product of [camera direction] and [object position]-[camera position]. If the result is negative, the object is behind the camera. Given that I understood your code right it would be: if((PositionX - Camera.PositionX) * Camera.LookAtX + (PositionY - ...


1

How about doing it a bit differently? Start as usual and render all markers within viewport. If a marker is outside of the viewport - proceed: Get positions of the marker A Get position of the camera B (maybe slightly in front of it) Calculate 3D vector AB between these two Convert and normalize that vector into 2D screen bounds (A will be in view center ...


0

Quaternion.LookRotation(forward, up) has a nifty property: it rotates z+ exactly to forward it rotates y+ as close as possible to up (given the constraint on z+) (You might not be used to up, since it silently defaults to (0, 1, 0) if you leave this parameter out) What we want here (and this comes up pretty often) is the reverse: we want y+ controlled ...


2

oldRange = oldMax - oldMin newRange = newMax - newMin newValue = ((oldValue - oldMin) * newRange / oldRange) + newMin Hope this helps.


0

I don't understand phython but a simple but not very flexible solution is to use annidated if like this one: float ProbDensityFunction () { value = random(); if (value > .1) value = random(); else if (value > .2) value = random(); ... else if (random()>.9) ...


2

You're only getting angles in the top-right quadrant because you're taking the absolute value of dy & dx. The sign information is important for determining what quadrant atan2 should return. What I'd recommend instead is using vector normalization, rather than trigonometry. dx = touch.x - startPosFrontJoystick.x; dy = invY - startPosFrontJoystick.y; ...


0

How about a trivial power function? Take a random number in the 0 to 1 interval, raise it to the power "needed". This is easy to calculate and different selections of exponent will give you the loot-rarity you want.


2

Let's rephrase your question: Given a rotation R, and a position p, we would like the rotated point p' to lie along the Z-axis (also known as the center of the camera). For this, we can use linear algebra: Compose the rotation matrix R from your euler angles. Solve the problem Rd = [0 0 1]^T, or | 0 | d = inv(R) | 0 | | 1 | d is ...


1

Here is my gaussian distrib. in 0..1 in c# With reference Note: r is the Random class istance. private double nextGaussian(double mean,double variance ) { // http://stackoverflow.com/questions/218060/random-gaussian-variables //with mean = 0.5 and variance = 0.5 we get uniform distribution over [0..1] double u1 = r.NextDouble(); ...



Top 50 recent answers are included