Tag Info

New answers tagged

-1

You just need to rotate direction vector A by angle theta, where theta is angle corresponding to your distance on circumference. Because you know full circle is 2 * pi radians and you can calculate the circle's perimeter. Theta is then distance / perimeter * 2pi radians, simplified dist / len(A). In code: double theta = distance / A.Length(); vec2 dirA = A ...


1

I suggest moving the target slowly rather than the angle. Try this: Vector2 Target; // Interp is a value between 0 and 1. When 0, the target never moves. // When 1, the target moves instantaneously. Intermediate values cause the target // to move at different rates. void UpdateTarget(float interp) { Target = interp * Mouse.Position + (1 - interp) * ...


1

I think any linear function would be fine for this. You can keep two variables one for your spaceship's current angle spaceshipAngle = Math.PI*k, and one for the current angle that the user inputs with his cursor cursorAngle = Math.PI*p. And what you do is if (Math.Abs(Math.PI*k, Math.PI*p) < Math.PI) { if (Math.PI*k < Math.PI*p) k += ...


-2

Should a and b be d units apart in a straight line, or along the circumference of the circle? If along a straight line, intersect the circle around point o with radius r, with a circle at point a with radius d. There's two outcomes to this equation, so pick the one you want. If along the circumference, just rotate point a around o by the result of d divided ...


1

Let's say I have three circles. (I'm gonna say circles because if I called them balls, that sentence would sound weird.) What this example is doing is looking if two circles are overlapping. If they overlap, it'll calculate the distance between the two circles, and the required distance based on the radiusses (radii? whatever). It then moves the circles ...


0

I will keep it short and sweet. There are two "servers" running. One locally and one remotely online. The user simply operates the mouse and keyboard to control the game. Input is parsed by the client and converted to commands (e.g. move forward / turn left / jump). The client sends these commands to the local server and remote server. They both process ...


0

buttonDown() and other methods inControllerListener only fired when the key is pressed.If you want constant movement you need a variable and set for example when KeyRight is called and unset when keyRight is released or another key like KeyLeft pressed There is a good sample here ...


0

The server should be authoritative on this matter, the client should never be trusted and each action should be checked by the server. The typical movement scenario would be: player wants to move, so it sends a move message (actual position, direction), and immediately starts the move animation. the server receives the message, it tests if the move was ...


2

Your client never moves you. The server moves you. Think about it this way: A client sends a movement request packet to the server to start moving. The server says sure you can start moving, there's nothing in the way. The server begins moving the player in x direction. The same client ask the server to start moving again. The server says, you're ...


1

Any answer that doesn't link to Glenn Fielder's Fix Your Timestep article isn't an answer at all. So first, read that, because it more than addresses your problem. Note that you do not have to implement his ultimate solution in order to have a reasonably well behaved simulation. Yes, you can use a raw delta time, clamped or otherwise, as other answers have ...


1

This is how I do it in iOS games: // get's called approx every 60th of a second but not always - (void)drawViewLoop { timeThisRound = CFAbsoluteTimeGetCurrent(); deltaTimeThisRound = timeThisRound-lastTime; // don't let the delta get too big. Even if the fps slows way down cap delta at 1/20th of a second if (deltaTimeThisRound > 0.05) { ...


2

Well, I am not sure what language you use for your game so I'll explain it in C++, but you could use something called 'deltatime' Uint32 last = 0; Uint32 delay = 0; void loop() { Uint32 now = SLD_GetTicks(); if(now > last) { delay = now - last; last = now; } moveUp(delay); } void moveUp(Uint32 delay) { ...


0

I have received help from a person on Youtube. He gave me an example, showing the code to be phy_speed_x=-10 for the object to move left or phy_speed_x=+10 to move right, whilst using physics. I was using the wrong code all along!


3

Going 3D when the game is basically a 2D game seems like an overkill. In your place, i'd rather use a 2D engine that handles already tiles and slopes, and just use a few tricks for the parts where a '3D' effect is required. Just a small example, a bridge : So for the player, that would look like : Now you can add some invisible trigger zones that ...


2

Add a logical third dimension and add logic to tiles by type. So a horizontal bridge will allow you to pass from left to right on Z = 1 and from top to bottom on Z = 0.(like flow bridges game) Now change the Z when walking up or down a hill. Allow jumping 1 unit high. That's about it. edit: here is an example tutorial- http://rpgmaker.net/tutorials/163/


-1

I don't understand what you're trying to do, but if you want an object to move back and forth somewhere in your room, you could multiply that object SpeedX variable by -1 in whatever Event you want it to bounce, this way it will invert its horizontal speed and make it go the other way.


2

It sounds like you desire Simple Harmonic Motion; if so, you must apply a force proportional to, but of opposite sign from, the displacement from the origin of the motion to have it be stable. That is to say, apply a force with components Fx = - c * x and Fy = - d * y.


0

The problem is here: if (position.x >= posB.x && position.y >= posB.y) { This will only work if moving in positive X and/or positive Y. When moving the other way posB will be smaller than position and the character will stop right away. Also, you keep adding the new position to position when you should be adding the delta v.set((posA.x + ...



Top 50 recent answers are included