Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!

We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Member Since 02 May 2001
Offline Last Active Jul 30 2014 02:40 PM

Topics I've Started

Need help with 2D puddle

24 May 2014 - 03:36 PM

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?


Attached File  puddle.jpg   157.13KB   5 downloads


And here is the puddle texture:


Attached File  puddle.png   4KB   5 downloads

Moving pendulum

23 November 2012 - 01:05 PM

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: http://math.stackexc...th-moving-pivot but that diagram doesn't look correct.That angle between A1 and A is not , but rather (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?

Framerate independent friction

28 April 2012 - 07:22 PM

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:

newVelocity = oldVelocity - oldVelocity * friction * elapsedTime

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:

newVelocity = oldVelocity * exp(-friction * elapsedTime)

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.

How can I improve this song?

13 March 2012 - 10:05 PM

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?


Storing achievement/leaderboard data in iOS

21 February 2012 - 05:13 PM

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?