Ja sitten väännin sen pohjalta funktion.
Code: Select all
'Made by MaGetzUb
SCREEN 400, 300, 32, 2
Repeat
Color 0, 255, 255
DSG_Line(200, 150, MouseX(), MouseY())
Color 255, 255, 255
Text 0, 0, FPS()
DrawScreen
Forever
Function DSG_Line(AloitusX, AloitusY, LopetusX, LopetusY, Buffer = 0)
If Not Buffer Then Buffer = SCREEN()
rgb = getRGB(3) + getRGB(2) Shl 8 + getRGB(1) Shl 16
Hyppy = False
ErotusX = LopetusX - AloitusX
If ErotusX > 0 Then
HyppyX = 1
Else
HyppyX = -1
EndIf
ErotusY = LopetusY - AloitusY
If ErotusY > 0 Then
HyppyY = 1
Else
HyppyY = -1
EndIf
ErotusX = Abs(ErotusX)
ErotusY = Abs(ErotusY)
If ErotusY > ErotusX Then
Hyppy = True
RdX = AloitusX
AloitusX = AloitusY
AloitusY = RdX
RdX = ErotusX
ErotusX = ErotusY
ErotusY = RdX
RdX = HyppyX
HyppyX = HyppyY
HyppyY = RdX
EndIf
Erotus = (ErotusY * 2) - ErotusX
Lock Buffer
For i = 0 To ErotusX
If Hyppy Then
PutPixel2 AloitusY, AloitusX, rgb, Buffer
Else
PutPixel2 AloitusX, AloitusY, rgb, Buffer
EndIf
While Erotus => 0
AloitusY = AloitusY + HyppyY
Erotus = Erotus - (ErotusX * 2)
Wend
AloitusX = AloitusX + HyppyX
Erotus = Erotus + (ErotusY * 2)
Next i
PutPixel2 LopetusX, LopetusY, rgb, Buffer
Unlock Buffer
EndFunction