For me, the first step is to make a good sketch, then write the position vector and check it against the sketch. Carefully checking it for various angles is so important. When $\vec{r}(t)$ is correct, then take the derivative.
$$\vec{r} = \vec{r}_{pivot} + \vec{r}_{rod} \\
\vec{r}(t) = x_0(t) \hat{i} + (L\sin\theta(t) \hat{i} + L\cos\theta(t) \hat{j}) \\
\vec{v}(t) = [\dot{x}_0(t) + L\dot{\theta}\cos\theta(t)] \hat{i} - L\dot{\theta}\sin\theta(t) \hat{j} \\
\vec{v}\cdot\vec{v} = (\dot{x}_0 + L\dot{\theta}\cos\theta)^2 + L^2\dot{\theta}^2\sin^2\theta \\
v^2 = \dot{x}_0^2 + 2L\dot{x}_0\dot{\theta}\cos\theta + L^2\dot{\theta}^2$$
Having a good expression for the position vector also comes in handy for writing the potential energy function, $PE=-\vec{F}_{gravity}\cdot\vec{r}$.
Clarifications:
The position of the mass $m$ is given by $\vec{r}$, which always points from the origin to the mass at the end of the pendulum rod. There is also a vector $\vec{r}_{pivot}$ that always points from the origin to the pivot point of the pendulum. The position of the pivot is given as always on the $x$-axis at a distance $x_0(t)$ from the origin, so $\vec{r}_{pivot}=x_0(t)\hat{i}$
The vector $\vec{r}_{rod}$ always points along the pendulum rod from the pivot point to the mass no matter what angle, $\theta$, the rod makes with the vertical. The components of $\vec{r}_{rod}$ are found by projecting $\vec{r}_{rod}$ onto the horizontal and vertical axes. The length of $\vec{r}_{rod}$ is always $L$. By our choice of $\theta$, the vertical projection is $L\cos\theta$ and the horizontal projection is $L\sin\theta$.
$\theta$ is the angle that the rod makes with the vertical line through the pivot point. This is an important point for two reasons. First, $\theta$ is often used as the polar coordinate about the origin, but here it is a generalized coordinate that indicates the rotation of the pendulum rod about its pivot point. Second, we have chosen $\theta$ so that it is zero when the pendulum is in equilibrium. We could have used a different angle, such as the angle $\phi$ between the rod and horizontal, say, but then we would have a different expression for $v^2$.
Thus, the vector from the origin to the mass is the sum of the vector from the origin to the pivot and the vector from the pivot to the mass.
As for the formula for the potential energy, let $\vec{F}$ be the gravitational force on mass $m$ at position $\vec{r}$ in a uniform gravitational field. We can calculate the force two ways. One is simply $\vec{F}=mg\hat{j}$, with the unit vector $\hat{j}$ pointing down along the positive $y$-axis. The other is $\vec{F}=-\vec{\nabla}{V(\vec{r})}$, where $V(\vec{r})$ is the potential energy function. Since the gravitational field is uniform, $\vec{F}$ has no $\vec{r}$ dependence. It is not difficult to let $V(\vec{r})=-\vec{F}\cdot\vec{r}$ and verify that $$-\vec{\nabla}{V(\vec{r})} = -\vec{\nabla}{(-\vec{F} \cdot \vec{r})}=(\vec{F} \cdot \vec{\nabla})\vec{r} = \vec{F} $$
Therefore $V(\vec{r}) = -\vec{F} \cdot \vec{r}$ satisfies our one requirement for it to be the potential energy function. When we have a complicated expression for $\vec{r}$ and we need the potential energy, this is a very handy formula. Two warnings, however: First, our force $\vec{F}$ must be the same everywhere, no $\vec{r}$ dependence, which is often the case, for this formula to be valid. Second, the potential energy is not a unique quantity, so we might not get the exact same function as someone else, the difference usually being an additive constant. We are free to add or subtract any constant we want to our potential energy.
Best Answer
In case you really need to simulate accurate physics, you can use the solution given below.
In the picture above, vector $A = g-a$ where $g$ is acceleration due to gravity, and $a$ is the acceleration of mouse which you need to compute in real time. You will have to translate $g=9.8m/s^2$ into $pixel/s^2$ and store as a constant. For $A$, you need to calculate $A_x$ and $A_y$ based on the last two frames.
We need to find $\alpha(t)$.
We have $\beta=tan^{-1}\frac{A_x}{A_y}$ and $A_1=|A|\cos(\alpha-\beta)$. Angular acceleration will be $-A_1/h$ ($h$ will vary from bird to bird).
You will need to solve the differential equation $\frac{d^2\alpha}{dt^2}=A_1/h$ in real time to make the bird swing realistically.
The obvious way to solve the differential equation numerically is given below -
Store angular velocity $\omega=\frac{d}{dt}\alpha$. At each frame of the animation, assuming $\Delta t$ time has passed since last frame, do