I'm having problems getting my head around the drag and drop thing i'm playing with.
When i move the mouse fast the box stop moving until i go back and pick it up.
Also if i drag it over anothe box it selects that box too.
Strict
Global Number_of_Items = 10
Type ItemType
Field X#,Y#
Field Size = 25
Global List:TList
Method Draw()
DrawRect( X, Y, Size, Size)
End Method
Method PickUp()
If MouseX()>=X And MouseY()>=Y And MouseX()<=X+Size And MouseY()<=Y+Size And MouseDown(1)
X = MouseX() - Size/2
Y = MouseY() - Size/2
EndIf
End Method
Function Create()
Local NewItem :ItemType
NewItem = New ItemType
NewItem.X = Rand( 5, 800 ); NewItem.Y = Rand( 5, 600 )
If Not List Then List = CreateList()
List.AddLast( NewItem )
EndFunction
Function UpdateAll()
If Not List Return
For Local Item:ItemType = EachIn List
Item.Draw()
Item.PickUp()
Next
EndFunction
End Type
Graphics 800,600
For Local N = 1 To Number_of_Items
ItemType.Create()
Next
While Not KeyDown(Key_Escape)
ItemType.UpdateAll()
Flip;Cls
Wend
Thanks
When i move the mouse fast the box stop moving until i go back and pick it up.
Also if i drag it over anothe box it selects that box too.
Strict
Global Number_of_Items = 10
Type ItemType
Field X#,Y#
Field Size = 25
Global List:TList
Method Draw()
DrawRect( X, Y, Size, Size)
End Method
Method PickUp()
If MouseX()>=X And MouseY()>=Y And MouseX()<=X+Size And MouseY()<=Y+Size And MouseDown(1)
X = MouseX() - Size/2
Y = MouseY() - Size/2
EndIf
End Method
Function Create()
Local NewItem :ItemType
NewItem = New ItemType
NewItem.X = Rand( 5, 800 ); NewItem.Y = Rand( 5, 600 )
If Not List Then List = CreateList()
List.AddLast( NewItem )
EndFunction
Function UpdateAll()
If Not List Return
For Local Item:ItemType = EachIn List
Item.Draw()
Item.PickUp()
Next
EndFunction
End Type
Graphics 800,600
For Local N = 1 To Number_of_Items
ItemType.Create()
Next
While Not KeyDown(Key_Escape)
ItemType.UpdateAll()
Flip;Cls
Wend
Thanks