private void updatePosition() { RenderCommand rc = RenderCommand.NONE; bool updatedPos = false; while (!(word.empty()) && !updatedPos) { rc = word.dequeue(); switch (rc) { case RenderCommand.FORWARD: case RenderCommand.FORWARD2: float x; float y; double theta = Math.Atan2(pos.y, pos.x); x = (float)(forward * Math.Cos(theta)); y = (float)(forward * Math.Sin(theta)); //Debug.Log("THETA: X: " + x + " Y: " + y); double r = Math.Sqrt(x * x + y * y); x = (float)(r * Math.Cos(startHeading)); y = (float)(r * Math.Sin(startHeading)); //Debug.Log("R: X: " + x + " Y: " + y); pos.x += x; pos.y += y; updatedPos = true; break; case RenderCommand.RIGHT: startHeading += (turn * Math.PI / 180.0); break; case RenderCommand.LEFT: startHeading += (-turn * Math.PI / 180.0); break; case RenderCommand.PUSH: case RenderCommand.POP: case RenderCommand.IGNORE: default: break; } if (word.getSize() == queueSize / 2) { Debug.Log(pos.x + " " + pos.y); } } }