Page 1 of 1

Re: Mouse with Mouse Pointer Coordinates

Posted: Tue Dec 06, 2022 8:02 pm
by mk-soft
I don't see any meaningful executable code here that represents the features you describe.
Where is the rest of the code?

Re: Mouse with Mouse Pointer Coordinates

Posted: Wed Dec 07, 2022 8:16 am
by Bisonte
Are you all like this? Don't you read the posts? Are you all so agressive?
This was not an attack, just a serious question ....

to understand this kind of tip or trick, a running example is needed.

My personal opinion is that querying variables is one of the absolute basics of a programming language.
Therefore, I cannot identify this "trick" as such... sorry.

Moreover, your suggested usage is quite violent ! To get mouse coordinates that make sense, you have to
run your code inside a loop... and already we have a problem, because a Font is loaded continuously...
the hard disk is not standing still, the execution can be very slow (if the user do not have a ssd) and the
memory is running out ;)

And by the way, no one will look at something like this if they have to build a program around it first,
just to see what this code does... An executable example simply belongs to it...

Beginners who don't really have a clue about programming run the risk of getting used to bad and/or wrong
things. This is the reason why mk-soft (and actually everybody else) asks for the rest of the code...

Re: Mouse with Mouse Pointer Coordinates

Posted: Wed Dec 07, 2022 9:15 am
by STARGĂ…TE
Here is an executable example of Lord Santos codes without the continuously loading of fonts:

Code: Select all

Enumeration Window
	#Window
EndEnumeration

Enumeration Sprite
	#Sprite_Cursor
EndEnumeration

Enumeration Font
	#Font_Cursor
EndEnumeration

InitSprite()
InitMouse()
InitKeyboard()

OpenWindow(#Window, 0, 0, 960, 540, "Mouse with Mouse Pointer Coordinates", #PB_Window_ScreenCentered|#PB_Window_MinimizeGadget)
OpenWindowedScreen(WindowID(#Window), 0, 0, WindowWidth(#Window), WindowHeight(#Window))
LoadFont(#Font_Cursor, "Arial", 10)
CreateSprite(#Sprite_Cursor, 48, 48)

Repeat
	
	Repeat
		
		Select WindowEvent()
			Case #PB_Event_None
				Break
			Case #PB_Event_CloseWindow
				Break 2
		EndSelect
		
	ForEver
	
	ExamineMouse()
	If StartDrawing(SpriteOutput(#Sprite_Cursor))
		DrawingFont(FontID(#Font_Cursor))
		LineXY(0,0,20,10)
		LineXY(0,0,10,20)
		DrawText(0, 24, LSet(Str(MouseX())+"-"+Str(MouseY()), 11))
		StopDrawing()
	EndIf
	ExamineKeyboard()
	If KeyboardPushed(#PB_Key_All)
		Break
	EndIf
	
	ClearScreen($000000)
	DisplayTransparentSprite(#Sprite_Cursor, MouseX(), MouseY())
	FlipBuffers()
	
ForEver

End