MouseDeltaX/Y() doesnt work since 4.40

Just starting out? Need help? Post your questions and find answers here.
User avatar
Comtois
Addict
Addict
Posts: 1431
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

MouseDeltaX/Y() doesnt work since 4.40

Post by Comtois »

MouseDeltaX () and MouseDeltaY () are not working properly since version 4.40.
This code works perfectly until version 4.31. it draws a continuous line when i use the left mouse button. Since version 4.40 the line is discontinuous

Code: Select all

InitSprite()
InitKeyboard()
InitMouse()
OpenWindow(0, 0, 0, 800, 600, "MouseDelta")
OpenWindowedScreen(WindowID(0), 0, 0, 800, 600)

Enumeration
  #Fond
  #Souris
  #Temoin
EndEnumeration

CreateSprite(#Fond,800,600)

CreateSprite(#Souris,3,3)
StartDrawing(SpriteOutput(#Souris))
  Box(0,0,3,3,RGB(255,0,0))
StopDrawing()

Repeat
  While WindowEvent()
  Wend  
  FlipBuffers()
  ExamineMouse()
  ExamineKeyboard()
  DisplaySprite(#Fond,0,0)
  DisplaySprite(#Souris, MouseX(), MouseY())
  
  ;trace des formes
  If MouseButton(1)
    StartDrawing(SpriteOutput(#Fond))
    Line(MouseX(),MouseY(),-MouseDeltaX(),-MouseDeltaY(), RGB(255, 255, 255))
    StopDrawing()
  EndIf
  
Until KeyboardPushed(#PB_Key_Escape) 
Please correct my english
http://purebasic.developpez.com/
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: MouseDeltaX/Y() doesnt work since 4.40

Post by IdeasVacuum »

Tried PB4.61 and PB5.11, x86, WinXP. Fails exactly as described.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
STARGÅTE
Addict
Addict
Posts: 2226
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: MouseDeltaX/Y() doesnt work since 4.40

Post by STARGÅTE »

Use LineXY instead Line():

Code: Select all

InitSprite()
InitKeyboard()
InitMouse()
OpenWindow(0, 0, 0, 800, 600, "MouseDelta")
OpenWindowedScreen(WindowID(0), 0, 0, 800, 600)

Enumeration
  #Fond
  #Souris
  #Temoin
EndEnumeration

CreateSprite(#Fond,800,600)

CreateSprite(#Souris,3,3)
StartDrawing(SpriteOutput(#Souris))
  Box(0,0,3,3,RGB(255,0,0))
StopDrawing()

Repeat
  While WindowEvent()
  Wend  
  FlipBuffers()
  ExamineMouse()
  ExamineKeyboard()
  DisplaySprite(#Fond,0,0)
  DisplaySprite(#Souris, MouseX(), MouseY())
  
  ;trace des formes
  If MouseButton(1)
    StartDrawing(SpriteOutput(#Fond))
    LineXY(MouseX(),MouseY(),MouseX()-MouseDeltaX(),MouseY()-MouseDeltaY(), RGB(255, 255, 255))
    StopDrawing()
  EndIf
  
Until KeyboardPushed(#PB_Key_Escape) 
No bug!
See the change-log of Line() parameters
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: MouseDeltaX/Y() doesnt work since 4.40

Post by IdeasVacuum »

Good spot STARGÅTE, your mod version works perfectly 8)
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
Demivec
Addict
Addict
Posts: 4257
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: MouseDeltaX/Y() doesnt work since 4.40

Post by Demivec »

STARGÅTE wrote:No bug!
See the change-log of Line() parameters
Here's another variation of the Line() to achieve the same thing:

Code: Select all

Line(MouseX(),MouseY(),-MouseDeltaX() + Bool(MouseDeltaX() = 0),-MouseDeltaY() + Bool(MouseDeltaY() = 0), RGB(255, 255, 255))
PAPIPP
User
User
Posts: 49
Joined: Mon Aug 17, 2009 10:48 pm
Location: France

Re: MouseDeltaX/Y() doesnt work since 4.40

Post by PAPIPP »

Thank you Stargate
A small modification to delete, press the right.

Code: Select all


InitSprite()
InitKeyboard()
InitMouse()
OpenWindow(0,0,0,800,600,"MouseDelta")
OpenWindowedScreen(WindowID(0),0,0,800,600)

Enumeration
	#Fond
	#Souris
	#Temoin
EndEnumeration

CreateSprite(#Fond,800,600)

CreateSprite(#Souris,3,3)
StartDrawing(SpriteOutput(#Souris))
	Box(0,0,3,3,RGB(255,0,0))
StopDrawing()

Repeat
	While WindowEvent()
	Wend
	FlipBuffers()
	ExamineMouse()
	ExamineKeyboard()
	DisplaySprite(#Fond,0,0)
	DisplaySprite(#Souris,MouseX(),MouseY())
	
	;trace des formes
	If MouseButton( #PB_MouseButton_Left  )
		StartDrawing(SpriteOutput(#Fond))
      LineXY(MouseX(),MouseY(),MouseX()-MouseDeltaX(),MouseY()-MouseDeltaY(),RGB(255,255,255))
		StopDrawing()
	EndIf
		If MouseButton( #PB_MouseButton_Right   )
		StartDrawing(SpriteOutput(#Fond))
      LineXY(MouseX(),MouseY(),MouseX()-MouseDeltaX(),MouseY()-MouseDeltaY(),RGB(0,0,0))
		StopDrawing()
	EndIf

Until KeyboardPushed(#PB_Key_Escape)
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: MouseDeltaX/Y() doesnt work since 4.40

Post by c4s »

...Again a reason why it could be really helpful if there would be an optional compiler info for every significantly (meaning that the function behaves differently than before) changed (and of course used) function. For example somehow like this:
Compiler Info: Line() used, behavior changed in 4.40: Width of 0 not allowed anymore. Use LineXY() instead.
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
Little John
Addict
Addict
Posts: 4773
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: MouseDeltaX/Y() doesnt work since 4.40

Post by Little John »

c4s wrote:...Again a reason why it could be really helpful if there would be an optional compiler info for every significantly (meaning that the function behaves differently than before) changed (and of course used) function.
Agreed.
And until we have that, in the meantime someone could please add information about this problem in this thread: http://purebasic.fr/english/viewtopic.php?f=7&t=54600 8)
Post Reply