# Tag Info

0

In our game we use the level like in the Pokémon formula, but use other stats like strength and so on that increases the damage more. But the Main point is that the stats & level aren't so important for damage. They are just percentage values and the real damage comes from items. 0,5% of 100 damage are the same like 5% of 10 damage - so the percentage ...

0

Your main problem is that you have two objects (ships) and they move with different speeds and a third object that speeds up over time and you want to know the point where you have to aim to hit the ship. With this question you get the same question like military programmers - and you have a lot of variables and never a 100% chance to know the real point. ...

1

This is intentional, because making levels important is not the goal. Usually for RPGs there are two conflicting design goals: to give players freedom in how they play (and therefore how much grinding/side-quests to do, and hence their XP), and to make sure the difficulty of the game scales predictably for the length of the game. You don't want to make the ...

2

I suspect the method actually used doesn't actually rely on parallel projection and it only seems so through the approximation of the article writer and subsequent translation. The problem with bringing a parallel projection into this is you'll attenuate perspective, which is not what you may want. At any rate the method I describe here achieves the same ...

-1

I randomly found another one using this formula:

1

So firstly, I'd like to apologize if my question was poorly worded or if it was just confusing in general. I think I've figured out the proper solution now. It took a while because I had passed it off earlier after trying it and not immediately seeing desired results (I needed to basically remake my wooden manikin object from scratch). Basically, I found ...

1

The robust solution is to build a frustum of planes symbolising the camera and check the plane against all of them. The first part involves creating the frustum which can be a bit tricky if you're lacking in basic linear algebra; Start with transposing the matrix you're using to transform from worldspace to projected space, the reason for this is because ...

2

The way to "look around" in a 3d environment is to "rotate your camera". Your assumption to "move the objects around the camera" probably comes from the fact that when you render your scene, the MVP (model-view-projection) matrix stack transforms all your objects. Human beings like to think in what they figure out. And their world is in 3d, and when they ...

8

The point P to be transformed is, in homogenous coordinates: ( 50 ) ( 40 ) ( 1 ) The homogenous transformation matrix M is (using cos(pi/4) = sin(pi/4) = 0.7071): ( 0.7071 0.7071 -42.426 ) (-0.7071 0.7071 14.142 ) ( 0 0 1 ) noting that (40+20) * 0.7071 = 42.426 and (40-20) * 0.7071 = 14.142 and using the identity proved in my ...

0

I found that I needed to tighten the near and far values and ensure that the unproject function's near/far plane input matches the projection matrix that is also fed into the unproject function. Remember, the projection matrix which helped form your 'viewProj' variable also contains near and far plane values. For me, this resolved the exact symptoms you ...

1

If I understood what you're asking ,after you get your toEdge point , you need Intersection of a Line and a Rectangle to get intersection point. Then calculte distance from start point to intersection point.

4

A coder's guide to spline-based procedural geometry is a video from Unity event Unite 2015. In the video, the presenter gives visual explanation of how splines can be created and modified. Then, he goes on to give code examples for the same. Very informative. The video is for Unity3D, but the algorithms presented can be adapted to any platform.

3

As you will easily find out, the most straight-forward solution is to run multiple times an algorithm that checks whether there is an intersection between the segment formed by Point1 and Point2 (let's call them p1 and p2) and the ones formed by each of the vertices of the rectangle (let's call them r1, r2, r3 and r4). A clean implementation ...

0

You can use the Line-Line intersection formula, Line-line intersection. If you consider a class Line class that is made up of two Vector2s you can calculate, using the above formula, the intersection between them. class Line { public Vector2 a; public Vector2 b; public Line(Vector2 a, Vector2 b) { this.a = a; this.b = b; } ...

0

Technically, you have a line expressed as a series of points. Then, you express the rectangle as bounded constraints. Then you would create sub-lines from the original lines by the bounded constraints. Depending on your own algorithm, this may have different effects, but this is the general idea.

0

One easy approach is: check intersection with each rectangle line. Here follow my lua code for that (Line line intersection) function getVec2(x_,y_) vec2={} vec2.x=x_ vec2.y=y_ function vec2:dist() --set relative position return math.sqrt(vec2.x*vec2.x + vec2.y*vec2.y) end function vec2:sqrdist() --set relative position ...

11

This is to add to @Philipp's answer. Also, what advantages do you gain using three points on a 2D plane? You don't really need quaternions if all you're interested is in rotating on the plane, i.e. about the z axis. In this case, all you need is the yaw angle, and you can exploit the fact that successive rotations about the z axis commute. So you can ...

1

Based on you comments, it seems that you're storing the orientation of the object as a set of Euler angles, and in/decrementing the angles when the player rotates the object. That is, you have something like this pseudocode: // in player input handling: if (axis == AXIS_X) object.angleX += dir; else if (axis == AXIS_Y) object.angleY += dir; else if (axis ...

37

Mathematically, a quaternion is a complex number with 4 dimension. But in game development, Quaternions are often used to describe a rotation in 3d space by encoding: a rotation axis (in form of a 3-dimensional vector) how far to turn around that axis Note that this information is encoded with sines and cosines inside the quaternion, so in general you ...

3

Say, your circle is at 100, 120 and has radius 25. Say, your object is at x, y and has radius 9. So, the distance between the centers of the two is: sqrt((100 - x)^2 + (120 - y)^2) which means that the distance between their boundaries is d = sqrt((100 - x)^2 + (120 - y)^2) - 25 - 9 Now, if this distance is less than zero, we know that objects are ...

1

If your levels are procedural / infinite, then the using the chosen method is good. If you have a limited set of levels (i.e., only 10), then just associate the track choice with the level, hard-coded or preferably stored in the data that is loaded per level.

4

I don't know enough haxe to make this code better, but I would probably just do var tracklist = [3, 1, 1, 2, 2]; gamePlayTrackId = tracklist[waveId % 5]; You can probably improve this by making tracklist static or any number of ways. I'm still learning though, so look at the comments before you implement anything.

1

You need to combine a modulo (for the wrap-around) and a division (for the duplication of tracks). With some testing I got to: static function track(level:Int):Int { return Math.ceil(((level - 1) % 5 + 1) / 2); } (live example on Try Haxe) The idea is to divide a wrap-around, adjusting for no zeros. There might be a way to simplify this though.

6

This question would probably be better suited at StackOverflow. That being said: You are using the wrong modulo. Pseudocode: n = waveID % 5; n == 0 => Track3 n == 1 || n == 2 => Track1 n == 3 || n == 4 => Track2 If you use modulo you always have to use the size of you collection/repeating pattern (in this case 5). Furthermore I would recommend ...

2

You're getting problems with higher numbers being multiples of more than one of the numbers you check. 6 is not just going to trip the last else, it will also trip the % 3 == 0 one. I might do it this way: StartGame() { m_musicLevel = 1; m_track = playGameplayMusic(1); } NextLevel() { m_musicLevel++; if(m_musicLevel > 5) { ...

0

Right, if you keep rotating a matrix, say, by 1 degree around some axis, after 360 successive steps, it will be almost back where you started, but not exactly. You'll see some 0.999xxx and some 1.00xxx's and the like. Same with quaternions. But it takes a while before these are significant. One approach that I like is occasional renormalization. Just ...

2

Short answer: To store position, use a single vec3. To store rotation, use a quaternion and normalize it after every multiplication or after every n (1-1000) multiplications. You shall only use mat4s when it comes to drawing or transforming lots of vertices: Convert vec3+quaternion pair to mat4 and pass it to your shader or use it to transform vertices ...

0

Could someone explain why and now numerical errors can build over time using quaternions? "float is not real" Floating point types are an approximation of real numbers implementable on binary machines. For example: there is a real number 0.1, however, there is no IEEE-754 floating point number that is exactly 0.1, as this value cannot be represented ...

-1

I used an A* search algorithm. If your game is rendering tiles, then use this to determine if the tiles are solid or not. It creates a path of "passable" tiles for the enemy to follow the player around walls, in the shortest distance. It could easily be adapted for detecting if the surrounding tiles are solid or not (see through or not). Basically, you need ...

2

If I understood what you're asking , you can start from Spherical coordinate system Very pseudo code to "list" a sphere from top to bottom: Let r be radius. Let PI = 3.14... Let's use degrees. For theta =0..180 For phi =0..360 List.add(PolarToCartesian(r,theta,phi)) Where PolarToCartesian: x=r * sin(toRad(theta)) * cos(toRad(phi)) y=r * ...

0

Found what was wrong. The overall system works perfectly, its just that The m_rotationX angle was being calculated incorrectly. instead of m_rotationX = degrees(atan2f( lookDir.y, lookLengthOnXZ )); it should have been m_rotationX = -degrees(atan2f( lookDir.y, lookLengthOnXZ )); //(missed the minus sign.) and The order in which the rotations ...

1

I've done this before. The easiest method is to simulate the projectile, record points along its trajectory and note the closest point to the target. What I then do is get the target's location + (target velocity * time taken to reach closest point*) to get the location it would be by the time the projectile reached it. All you need to do then is Math.atan2 ...

2

This is the concept: You add "rotation movement" and "linear movement" together, and you get "rolling movement". Once you calculated all vectors for rotation movement, then you can simply add linear vectors to your results.

0

Check this out, it may help: http://gizma.com/easing/ The best way to do this, if you're not changing the destinations every frame, is to once calculate the positions, and store it in an array. Then use the values from that array. This is a great optimization because you won't have to call the math functions every frame.

1

You could try something like this int hp = 15; for(int i = 0; i < hp/2; i++) System.out.println("Heart"); if(hp % 2 == 1) System.out.println("Half Heart"); Just replace the print calls with your graphics calls.

1

the page where you probably get that image states : "The four red dots show the data points and the green dot is the point at which we want to interpolate." So, you know the values at Q12,Q22,Q11,Q21 , and yoi want interpolate the value at point P

2

You seem to have taken the image on Wikipedia, on the bilinear interpolation page. The legend of that image says [...] the green dot is the point at which we want to interpolate. So the P is at first a point from which we want to find the value. You submit a set of coordinates to the interpolation function (x, y), and it spits you a scalar (a single ...

2

All the math involved here is very important to know for all sorts of reasons, some of them applicable to game development. BUT This is a game development site, not a math site. So let's discuss how these things work not as algorithmic series, but as sets, because that is the sort of math that applies to leveling in games you might actually develop to ...

Top 50 recent answers are included