Funktionierende CameraRotate-Funktion
Verfasst: 29.12.2004 16:45
Da die RotateCamera funktion bei mir nicht ganz läuft, habe ich eine eigene geschrieben, die normale Winkel benutzt und somit auch für eine Schussbestimmung nützlich ist (die habe ich auch, wenn interesse besteht):
man kann die Mausabfrage auch rausnehmen, und dann Variablen an die Prozedur übergeben, damit die Funktion wie die andere arbeitet. Hab sie aber so aus meinem Spiel genommen und hatte keine Lust, sie noch umzuschreiben. Das kann jeder selber machen, wie er will.
Code: Alles auswählen
; Autor: OstA (http://thommy-oster.de.vu)
Global CameraRotationX; Global um später Schussrichtung zu bestimmen
Global CameraRotationZ
Procedure.f GSin(winkel.f)
ProcedureReturn Sin(winkel*(2*3.14159265/360))
EndProcedure
Procedure.f GCos(winkel.f)
ProcedureReturn Cos(winkel*(2*3.14159265/360))
EndProcedure
Procedure CamRotate()
ExamineMouse()
x = MouseDeltaX()
y = MouseDeltaY()
If x <> 0
CameraRotationZ - x
If CameraRotationZ > 359
CameraRotationZ = CameraRotationZ-360
ElseIf CameraRotationZ <= 0
CameraRotationZ = 360-CameraRotationZ
EndIf
EndIf
If y <> 0
CameraRotationX - y
If CameraRotationX > 179
CameraRotationX = 179
ElseIf CameraRotationX < 1
CameraRotationX = 1
EndIf
EndIf
CameraLookAt(0, CameraX(0)-10*GCos(CameraRotationZ)*GSin(CameraRotationX), CameraY(0)-10*GSin(CameraRotationZ)*GSin(CameraRotationX), CameraZ(0)-10*GCos(CameraRotationX))
EndProcedure