Construído
en Small y Basic y graduado a Visual Basic
Microsoft Small Basic Program
Listing SFP468
Código Small Basic
Arrow = Shapes.AddImage("http://cdn4.iconfinder.com/data/icons/markerstyle_icons/PNG/64px/arrow-right.png")
Shapes.Move(Arrow,200,200)
While 1 = 1
Program.Delay(5)
difx = GraphicsWindow.MouseX - 200
dify = GraphicsWindow.MouseY - 200
If difx > 0 Then
Angle = Math.GetDegrees(Math.ArcTan(dify / difx))
ElseIf difx < 0 Then
Angle = Math.GetDegrees(Math.ArcTan(dify / difx)) + 180
ElseIf difx = 0 And dify > 0 Then
Angle = 90
EndIf
Shapes.Rotate(Arrow,Angle)
Endwhile
Shapes.Move(Arrow,200,200)
While 1 = 1
Program.Delay(5)
difx = GraphicsWindow.MouseX - 200
dify = GraphicsWindow.MouseY - 200
If difx > 0 Then
Angle = Math.GetDegrees(Math.ArcTan(dify / difx))
ElseIf difx < 0 Then
Angle = Math.GetDegrees(Math.ArcTan(dify / difx)) + 180
ElseIf difx = 0 And dify > 0 Then
Angle = 90
EndIf
Shapes.Rotate(Arrow,Angle)
Endwhile
Código
Visual Basic
Module UntitledModule
Dim Arrow,
difx, dify, Angle As Primitive
Sub Main()
GraphicsWindow.BackgroundColor
= "Yellow"
Arrow = Shapes.AddImage("http://cdn4.iconfinder.com/data/icons/markerstyle_icons/PNG/64px/arrow-right.png")
Shapes.Move(Arrow,
200, 200)
While 1
= 1
Program.Delay(5)
difx = GraphicsWindow.MouseX
- 200
dify = GraphicsWindow.MouseY
- 200
If
difx > 0 Then
Angle =
Microsoft.SmallBasic.Library.Math.GetDegrees(Microsoft.SmallBasic.Library.Math.ArcTan(dify / difx))
ElseIf
difx < 0 Then
Angle =
Microsoft.SmallBasic.Library.Math.GetDegrees(Microsoft.SmallBasic.Library.Math.ArcTan(dify / difx)) + 180
ElseIf
(difx = 0) And (dify > 0) Then
Angle = 90
End
If
Shapes.Rotate(Arrow,
Angle)
End While
End Sub
End Module
No comments:
Post a Comment