Dieses Programm stellt ein Dreieck dar, welches man verändert. Es werden viele Werte berechnet. Seht es euch doch selber an:
BlitzBasic: [AUSKLAPPEN] [EINKLAPPEN] Graphics 640,480 SetBuffer BackBuffer() HidePointer() AppTitle \"Dreieck-Simulation\"
Global aX# = 100 Global aY# = 100 Global bX# = 300 Global bY# = 200 Global cX# = 80 Global cY# = 100 Global x = 320 Global y = 240 Global a# Global b# Global c# Global alpha# Global beta# Global gamma# Global AF# Global hC#
Repeat Cls Line aX#,aY#,bX#,bY# Line bX#,bY#,cX#,cY# Line cX#,cY#,aX#,aY# Text bX#+15,bY#-10, \"B\" Text aX#+15,aY#-10, \"A\" Text cX#+15,cY#-10, \"C\" a# = GetSideA() b# = GetSideB() c# = GetSideC() DrawInfoSites() DoMouse() DrawInfo() DrawInfoAngle() DrawInfoFlaeche() DrawButtons() Flip Color 255,255,255 Until KeyDown(1)
End
Function DoMouse()
x = MouseX() y = MouseY()
Rect x,y,10,10
If RectsOverlap(x,y,5,5,aX#,aY#,5,5) Then Oval aX#-5,ay#-5,10,10,0 Color 0,0,255 Text aX#+15,aY#-10, \"A\" If MouseDown(1) Then Oval aX#-5,aY#-5,10,10 PressA = 1 EndIf EndIf
If PressA = 1 Then aX# = MouseX() aY# = MouseY() If MouseDown(1) = 0 Then PressA = 0 EndIf EndIf
If RectsOverlap(x,y,5,5,bX#,bY,5,5) Then Oval bX#-5,by#-5,10,10,0 Color 0,0,255 Text bX#+15,bY#-10, \"B\" If MouseDown(1) Then Oval bX#-5,bY#-5,10,10 PressB = 1 EndIf EndIf
If PressB = 1 Then bX# = MouseX() bY# = MouseY() If MouseDown(1) = 0 Then PressB = 0 EndIf EndIf
If RectsOverlap(x,y,5,5,cX#,cY,5,5) Then Oval cX#-5,cy#-5,10,10,0 Color 0,0,255 Text cX#+15,cY#-10, \"C\" If MouseDown(1) Then Oval cX#-5,cY#-5,10,10 PressC = 1 EndIf EndIf
If PressC = 1 Then cX# = MouseX() cY# = MouseY() If MouseDown(1) = 0 Then PressC = 0 EndIf EndIf Color 255,255,255 End Function
Function DrawInfo()
Text 125,400, \"A(\"+(aX#)+\"|\"+(aY#)+\")\" Text 125,412, \"B(\"+(bX#)+\"|\"+(bY#)+\")\" Text 125,424, \"C(\"+(cX#)+\"|\"+(cY#)+\")\"
Text 1,400, \"a=\"+(a#*0.353)+\"mm\" Text 1,412, \"b=\"+(b#*0.353)+\"mm\" Text 1,424, \"c=\"+(c#*0.353)+\"mm\"
End Function
Function GetSideA()
SideA = cX# - bX# If SideA < 0 Then SideA = SideA*-1 EndIf
SideB = cY#-bY# If SideB < 0 Then SideB = SideB*-1 EndIf
Return Sqr((SideA^2) + (SideB^2) )
End Function
Function GetSideB()
SideA = cX# - aX# If SideA < 0 Then SideA = SideA*-1 EndIf
SideB = cY#-aY# If SideB < 0 Then SideB = SideB*-1 EndIf
Return Sqr((SideA^2) + (SideB^2) )
End Function
Function GetSideC()
SideA = aX# - bX# If SideA < 0 Then SideA = SideA*-1 EndIf
SideB = aY#-bY# If SideB < 0 Then SideB = SideB*-1 EndIf
Return Sqr((SideA^2) + (SideB^2) )
End Function
Function DrawInfoSites()
xLine = (cx#+bx#)/2 yLine = (cy#+by#)/2 Text xLine,yLine, \"a\"
xLine = (cx#+ax#)/2 yLine = (cy#+ay#)/2 Text xLine,yLine, \"b\"
xLine = (ax#+bx#)/2 yLine = (ay#+by#)/2 Text xLine,yLine, \"c\"
End Function
Function DrawInfoAngle()
alpha# = (((b^2)+(c^2)-(a^2))/(2*b*c))
Text 1,436, \"Alpha=\"+ACos(alpha#)+\"°\"
beta# = (((c^2)+(a^2)-(b^2))/(2*c*a))
Text 1,448, \"Beta=\"+ACos(beta#)+\"°\"
gamma# = (((a^2)+(b^2)-(c^2))/(2*b*a))
Text 1,460, \"Gamma=\"+ACos(gamma#)+\"°\"
End Function
Function DrawInfoFlaeche()
hC# = b#*Sin(ACos(alpha#)) AF#=(hC#*c)/2 Text 400,400, \"Fläche=\"+AF#+\"mm²\"
End Function
Function SetRight()
aX# = 100 bX# = 100 cX# = 300
aY# = 100 bY# = 300 cY# = 300
End Function
Function SetDouble()
aX# = 100 bX# = 300 cX# = 200 aY# = 300 bY# = 300 cY# = 100
End Function
Function SetGleich() aX# = 100 bX# = 300 cX# = 200 aY# = 300 bY# = 300 cY# = 127 End Function
Function DrawButtons()
Rect 400,20,200,20,0 Text 402,22, \"Rechtwinkeliges Dreieck\" If RectsOverlap(x,y,1,1,400,20,200,20) Then Color 0,0,255 Rect 400,20,200,20,0 If MouseDown(1) Then Color 0,255,0 Rect 400,20,200,20,0 SetRight() EndIf EndIf Color 255,255,255 Rect 400,50,220,20,0 Text 402,52, \"Gleichschenkeliges Dreieck\" If RectsOverlap(x,y,1,1,400,50,220,20) Then Color 0,0,255 Rect 400,50,220,20,0 If MouseDown(1) Then Color 0,255,0 Rect 400,50,220,20,0 SetDouble() EndIf EndIf Color 255,255,255 Rect 400,100,200,20,0 Text 402,100, \"Gleichseitiges Dreieck\" If RectsOverlap(x,y,1,1,400,100,200,20) Then Color 0,0,255 Rect 400,100,200,20,0 If MouseDown(1) Then Color 0,255,0 Rect 400,100,200,20,0 SetGleich() EndIf EndIf
End Function
Erweiterungen kommen noch!
|