November 28, 2020, 01:10:47 PM

Author Topic: [bmx] Draw Line With Mouse by IKG [ 1+ years ago ]  (Read 363 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bmx] Draw Line With Mouse by IKG [ 1+ years ago ]
« on: June 29, 2017, 12:28:40 AM »
Title : Draw Line With Mouse
Author : IKG
Posted : 1+ years ago

Description : Click mouse button 1 to place first coordinate. Click mouse button 2 to place the second coordinate which will draw the line.

Code :
Code: BlitzMax
  1. 'Written by David Schwartz - http://www.devdave.net
  2. Graphics 640,480,0
  3.  
  4. SetColor(255,255,255)
  5.  
  6. Global firstmousex = 0
  7. Global firstmousey = 0
  8. Global secondmousex = 0
  9. Global secondmousey = 0
  10. Global first = False
  11. Global second = False
  12.  
  13. Repeat
  14.  
  15. If MouseHit(1) Then
  16.         firstmousex = MouseX()
  17.         firstmousey = MouseY()
  18.         SetColor (255,0,0)
  19.         DrawOval firstmousex,firstmousey,4,4
  20.         SetColor(255,255,255)
  21.         first = True
  22. EndIf
  23.  
  24. If MouseHit(2) Then
  25.         secondmousex = MouseX()
  26.         secondmousey = MouseY()
  27.         SetColor (255,0,0)
  28.         DrawOval secondmousex,secondmousey,4,4
  29.         SetColor(255,255,255)
  30.         second = True
  31. EndIf
  32.  
  33. If first = True And second = True Then
  34.         DrawLine firstmousex,firstmousey,secondmousex,secondmousey
  35.         first = False
  36.         second = False
  37. EndIf
  38.  
  39. Flip
  40.  
  41. Until KeyHit(key_escape)


Comments :


IKG(Posted 1+ years ago)

 Just fooling around with lines..


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal