Make your own free website on Tripod.com
Game Plan Tools Methods Calculations A.I. Development Log Gameplay Code ScreenShots Art
Current code examples: Subject to change!
Not all code is here. When all code is said and done, I will post it here.
Moving forward:
    If diState.Key(200) > 0 Then ' up arrow
    Rise = vecCameraTarget.z - vecCameraSource.z
            Run = vecCameraTarget.X - vecCameraSource.X
                If vecCameraSource.Y <= -9 Then
                vecCameraSource.z = vecCameraSource.z + Rise / 5
                vecCameraTarget.z = vecCameraTarget.z + Rise / 5
                vecCameraSource.X = vecCameraSource.X + Run / 5
                vecCameraTarget.X = vecCameraTarget.X + Run / 5
                End If
                If vecCameraSource.Y > -9 Then
                vecCameraSource.z = vecCameraSource.z + Rise / 5
                vecCameraTarget.z = vecCameraTarget.z + Rise / 5
                vecCameraSource.X = vecCameraSource.X + Run / 5
                vecCameraTarget.X = vecCameraTarget.X + Run / 5
                End If
            D3DXMatrixLookAtLH matView, vecCameraSource, _
                vecCameraTarget, CreateVector(0, 1, 0)
            d3d.Device.SetTransform D3DTS_VIEW, matView
    End If
Turning left:
    If diState.Key(203) > 0 Then ' left arrow
        Theta = Theta + 0.1
            vecCameraTarget.X = R * Cos(Theta) + vecCameraSource.X
            vecCameraTarget.z = R * Sin(Theta) + vecCameraSource.z
            D3DXMatrixLookAtLH matView, vecCameraSource, _
                vecCameraTarget, CreateVector(0, 1, 0)
            d3d.Device.SetTransform D3DTS_VIEW, matView
     End If
3D 2D sprite rotation calculation:
'find deltaX(mech1xdiff) and deltaY(mech1ydiff)
Mech1Xdiff = vecCameraSource.X - Mech1X
Mech1Ydiff = vecCameraSource.z - Mech1Y
If (Mech1Xdiff > 0 And Mech1Ydiff > 0) Then MechTheta = (Atn(Mech1Ydiff / Mech1Xdiff)) * (180 / PI)
If (Mech1Xdiff > 0 And Mech1Ydiff < 0) Then MechTheta = 360 + (Atn(Mech1Ydiff / Mech1Xdiff)) * (180 / PI)
If (Mech1Xdiff < 0 And Mech1Ydiff < 0) Then MechTheta = 180 + (Atn(Mech1Ydiff / Mech1Xdiff)) * (180 / PI)
If (Mech1Xdiff < 0 And Mech1Ydiff > 0) Then MechTheta = 180 + (Atn(Mech1Ydiff / Mech1Xdiff)) * (180 / PI)

MechFrame = Int(MechTheta / 10)