Winkelberechnung
Übersicht

![]() |
JulzBetreff: Winkelberechnung |
![]() Antworten mit Zitat ![]() |
---|---|---|
Code: [AUSKLAPPEN] Graphics 800,600,1,2 SetBuffer BackBuffer() cross = LoadImage("cross.bmp") player = LoadImage("play.bmp") x = 400 y = 400 winkel# = 0 test# = 0 Repeat Cls If KeyDown(205) Then x = x + 1 If KeyDown(203) Then x = x - 1 If KeyDown(208) Then y = y + 1 If KeyDown(200) Then y = y - 1 If MouseX() > x And MouseY() > y xk = MouseX() - x yk = MouseY() - y test = Tan(yk / xk) winkel = ATan(test) EndIf If MouseX() < x And MouseY() > y xk = x - MouseX() yk = MouseY() - y test = Tan(yk / xk) winkel = ATan(test) EndIf If MouseX() > x And MouseY() < y xk = MouseX() - x yk = y - MouseY() test = Tan(yk / xk) winkel = ATan(test) EndIf If MouseX() < x And MouseY() < y xk = x - MouseX() yk = y - MouseY() test = Tan(yk / xk) winkel = ATan(test) EndIf DrawImage player,x,y MaskImage cross,0,136,255 DrawImage cross,MouseX(),MouseY() Print xk Print yk Print winkel Flip Until KeyDown(1) Kann mir einer sagen wieso der den winkel falsch berechnet ? Ich hab den per Print extra unten an den bildschirmrand geschrieben, aber irgendwie kommen da ziemlich komische werte raus...weiß einer warum ? oder kann mir helfen ? ich bedanke mich im vorraus |
||
![]() |
Hummelpups |
![]() Antworten mit Zitat ![]() |
---|---|---|
-_-
Oh man........ - du musst nicht in der Schleife masken. - Wie wäre es mit einer FUnktion um den WInkel zu berechnen? - Print inner Loop!!!!!!!! Oo oO Oo oO Oo oO - Was is das für eine Maskcolor???? - Warum den Umweg über variablen xk und yk??? Die verbrauchen sinnlose 8 Byte speicher! Am besten du fängst nochmal neu an zu lernen! Code: [AUSKLAPPEN] Graphics 800,600,16,2
SetBuffer BackBuffer() cross = LoadImage("cross.bmp") player = LoadImage("play.bmp") MaskImage cross,0,136,255 x = 400 y = 400 winkel# = 0 test# = 0 Repeat Cls If KeyDown(205) Then x = x + 1 If KeyDown(203) Then x = x - 1 If KeyDown(208) Then y = y + 1 If KeyDown(200) Then y = y - 1 If MouseX() > x And MouseY() > y xk = MouseX() - x yk = MouseY() - y EndIf If MouseX() < x And MouseY() > y xk = x - MouseX() yk = MouseY() - y EndIf If MouseX() > x And MouseY() < y xk = MouseX() - x yk = y - MouseY() EndIf If MouseX() < x And MouseY() < y xk = x - MouseX() yk = y - MouseY() EndIf winkel=ATan2(y-MouseY(),x-MouseX()) DrawImage player,x,y DrawImage cross,MouseX(),MouseY() Text 10,10,(winkel+270)Mod 360 Flip Until KeyDown(1) So, einigermaßen besser. IMurDOOM |
||
blucode - webdesign - Ressource - NetzwerkSim
BlitzBasic 2D - BlitzMax - MaxGUI - Monkey - BlitzPlus |
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group