BradDaBug

Member
  • Content count

    3935
  • Joined

  • Last visited

Community Reputation

913 Good

About BradDaBug

  • Rank
    Contributor
  1. Confused about linear forces and rotation

    Thanks! Apparently my intuitions were completely wrong.   I still don't really get why the friction would matter. The friction is the same in both scenarios (right?) and the linear forces are the same (right?). I'm unable to intuit.
  2. I'm sure this has been asked 10000s of times before, but I can't find a good explanation.   I saw some code in Box2D for applying a linear impulse (force works similarly) that looks like this (paraphrasing the code): ApplyImpulse(Vector2 impulse, Vector2 position) {     linear_velocity += impulse / mass;     angular_velocity += Cross(impulse, position - center_of_body) / momentOfInertia; } But I don't understand how this works. I have a pen on my desk, and when I apply a force near the center the entire pen moves but doesn't rotate. If I apply the same force at the tip of the pen it rotates but doesn't really move. It looks like this code would handle the pushing-the-pen-near-the-center case, but move the pen way too much in the other case. But then everything that I've read says that this is correct and it's just how it works.   I don't get it.
  3. Advertising Through YouTubers

    Maybe I'm stupid, but I don't understand the math. 100,000 * 0.5% * $20 = $10,000, not $40,000. Edit: OIC, he's saying a 0.5% conversion rate on EACH of the four videos.
  4. Need help with 2D puddle

    I darkened and smoothed it, and now I'm feeling a bit better about it. It's a big improvement over what I had. But it still doesn't look quite right. It looks like a dried wax seal rather than a puddle of goo. I think I'll try to smooth out the edges a bit to make it look more wet and gooey.   [attachment=21881:puddle4.jpg]
  5. Need help with 2D puddle

    It's flat circle.   Here is another attempt. I based it on the blood decal, so it fits a little better, but it doesn't really look like a puddle. It looks more like... I'm not sure. But I think I'm going in the right direction. I just wish I knew how to make it look more puddle-y. Should the interior be smoother? And making a green puddle contrast against the green grass is tricky.   [attachment=21846:puddle3.jpg]
  6. Need help with 2D puddle

    I like that a bit better than what I have. Here is my attempt (The dark spots aren't part of the decal. That's a bit of green smoke left by a kitten before it dissolved):   [attachment=21825:puddle2.jpg]   But there's still something off about it. It could just be that it doesn't jibe with the blood. The blood is a little more realistic but the goop is very stylized.
  7. Need help with 2D puddle

    In my game kittens can dissolve into a puddle of goop, but I'm not happy with how the puddles look. You can see below.   I'm not sure what I can do to make them look better. How can I represent a puddle in this stylized way that matches the rest of the game on completely flat terrain? Any ideas?   [attachment=21819:puddle.jpg]   And here is the puddle texture:   [attachment=21820:puddle.png]
  8. Moving pendulum

    I think that diagram may have been more confusing than helpful (plus I found at least one bug in my code). After some more work I came up with this, and it seems to work ALMOST correctly (in 2 dimensions, even), except when I really start slinging the cursor around. It seems like the pendulum bob should be held straight out by centrifugal force, but instead it kind of starts jumping around erradically until it looses some velocity and settles down. [source lang="csharp"]private void update(float elapsedTime, int x, int y) { // figure out the current mouse velocity Vector3 vel = new Vector3(); vel.X = x - _position.X; vel.Y = 0; vel.Z = y - _position.Z; vel /= elapsedTime; // compare the current velocity with the old to calculate acceleration Vector3 acceleration = (vel - _oldVelocity) / elapsedTime; acceleration.Y = -90000.0f * elapsedTime; _oldVelocity = vel; // calculate the XY plane angular velocity float accelerationZ = acceleration.Z; acceleration.Z = 0; float b = (float)Math.Atan2(acceleration.Y, acceleration.X); float a = acceleration.Length() * (float)Math.Cos(b - (_bobAngle.X - MathHelper.PiOver2)); _bobAngularVelocity.X += a / _springLength * elapsedTime; // calculate the YZ plane angular velocity acceleration.Z = accelerationZ; acceleration.X = 0; b = (float)Math.Atan2(acceleration.Y, accelerationZ); a = acceleration.Length() * (float)Math.Cos(b - (_bobAngle.Y - MathHelper.PiOver2)); _bobAngularVelocity.Y += a / _springLength * elapsedTime; // apply damping _bobAngularVelocity -= _bobAngularVelocity * 2.0f * elapsedTime; // apply velocity _bobAngle.X += _bobAngularVelocity.X * elapsedTime; _bobAngle.Y += _bobAngularVelocity.Y * elapsedTime; _bobAngle.X = MathHelper.WrapAngle(_bobAngle.X); _bobAngle.Y = MathHelper.WrapAngle(_bobAngle.Y); _position.X = x; _position.Z = y; }[/source]
  9. Moving pendulum

    I thought this would be simpler than it has turned out to be. Imagine a string with a heavy weight at one end that's attached to the mouse cursor, and as the player moves the mouse cursor the weight at the end of the string should sway and oscilate around. Creating a simple pendulum is easy, but making the pendulum and the weight move around in response to the movement of the pendulum.... I'm not having any luck. I found this: [url="http://math.stackexchange.com/questions/3072/pendulum-with-moving-pivot"]http://math.stackexc...th-moving-pivot[/url] but that diagram doesn't look correct.That angle between A1 and A is not [eqn]a - \beta[/eqn], but rather [eqn]\pi/2 - a - \beta[/eqn] (right?). Anyway, here is a snippet of code but it doesn't work. The bob doesn't behave at all like what I want. I call this method each frame, and the coordinates represent the mouse coordinates. I'm not using _bobAngle.Y yet, so ignore the fact that I'm not calculating it. I'm just trying to get the bob to behave correctly in 1 dimension before I work on the second. [source lang="csharp"]private void update(float elapsedTime, int x, int y) { // figure out the current mouse velocity Vector3 vel = new Vector3(); vel.X = x - _position.X; vel.Y = 0; vel.Z = y - _position.Z; vel *= elapsedTime; // compare the current velocity with the old to calculate acceleration Vector3 acceleration = (vel - _oldVelocity) / elapsedTime; acceleration.Y = -5.0f * elapsedTime; _oldVelocity = vel; float b2 = (float)Math.Atan2(acceleration.X, -acceleration.Y); float a1 = acceleration.Length() * (float)Math.Cos(MathHelper.PiOver2 - Utils.AngleDiff(_bobAngle.X, b2)) * 1.0f; _bobAngularVelocity.X += a1 / _springLength * elapsedTime; // apply damping _bobAngularVelocity -= _bobAngularVelocity * 0.01f * elapsedTime; // apply velocity _bobAngle.X += _bobAngularVelocity.X * elapsedTime; _bobAngle.Y += _bobAngularVelocity.Y * elapsedTime; _bobAngle.X = MathHelper.WrapAngle(_bobAngle.X); _bobAngle.Y = MathHelper.WrapAngle(_bobAngle.Y); _position.X = x; _position.Z = y; } private Vector2 calcBobPosition() { Vector2 p = new Vector2(); p.X = _position.X + _springLength * (float)Math.Sin(_bobAngle.X); p.Y = _position.Z + _springLength * (float)Math.Sin(_bobAngle.Y); return p; } [/source] Can anyone tell what I'm doing wrong?
  10. I noticed that my game runs a bit differently when running at 60 FPS on my PC and 30 FPS on my phone, and I traced it down to the friction code. I'm applying friction like this: [CODE]newVelocity = oldVelocity - oldVelocity * friction * elapsedTime[/CODE] The results are not consistent between 60 Hz and 30 Hz. But then I thought about how continuous compound interest is calculated, and I came up with this: [CODE]newVelocity = oldVelocity * exp(-friction * elapsedTime)[/CODE] It works perfectly, at least on paper. Has anyone else ever used an approach like this? Or is there a better way to do it? Edit: I should mention that the game is using a fixed time step. At 30 Hz it's 1/30 seconds and at 60 Hz it's 1/60.
  11. I know absolutely nothing about music composition, and yet I'm attempting to write a song be the theme for a game I'm working on. I was thinking of the old Harvest Moon SNES game when I wrote it, since that's kind of the idea I'm trying to get across. Anyway, how can I improve the song? It seems so basic and flat. What does it need? [url="http://fwheel.net/music/pollo.mp3"]clicky[/url]
  12. I'm starting work on a leaderboard and achievement system for my iOS game, and one thing all the documentation suggests is to save leaderboard/achievement data locally in case submitting it to the Game Center fails, and then the next time the game is able to connect it can send the leaderboard/achievement data at that point, so the user doesn't lose any data. OK, but how do I store the data? Is NSUserDefaults good enough? Is there a better/more secure way to store the data?
  13. [SlimDX] How to speed up my engine?

    I found this and implemented it, and it seems plenty fast enough to use at run time. And even though all I've done so far is change my code to set the lightmap texture parameter just once instead of again and again for each surface I'm already seeing something close to a 2x speed increase. I'm putting a 1 pixel gutter around each lightmap inside the atlas, and sometimes it's possible to see it. I guess I need a bigger gutter. But anyway, thanks!
  14. [SlimDX] How to speed up my engine?

    No, it's 3D. I don't really know how I could batch my draw calls any further. The main thing taking so much time is rendering the room geometry. It's made up of lots of little surfaces, and each surface has its own combination of texture and lightmap, so I have to be able to render each surface separately so I can set those textures (right?).
  15. I've been working on a viewer/remake-of-the-engine for Gabriel Knight 3, but I'm having some serious performance issues, especially with the Direct3D 9 renderer, especially on this Intel integrated chip inside this laptop. I wouldn't really be worried about this, except that the original GK3 runs beautifully on this laptop. I want my engine to run as close to the performance of the original game as possible. I've been using SlimTune to profile the engine, and it looks like over 45% of the time is spent inside Device.DrawPrimitives(). Another 10% is inside Direct3D9Effect.SetParameter() (when I set my texture parameters, specifically), and another 7% inside Direct3D9Effect.CommitParams(). Is there anything I can do? The only thing I can think of is to somehow reduce the number of DrawPrimitive() calls, but I'm already doing basic frustum culling.